zstd-ruby 1.3.3.0 → 1.3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +1 -1
  3. data/ext/zstdruby/libzstd/BUCK +13 -0
  4. data/ext/zstdruby/libzstd/README.md +32 -25
  5. data/ext/zstdruby/libzstd/common/bitstream.h +1 -1
  6. data/ext/zstdruby/libzstd/common/compiler.h +25 -0
  7. data/ext/zstdruby/libzstd/common/cpu.h +216 -0
  8. data/ext/zstdruby/libzstd/common/error_private.c +1 -0
  9. data/ext/zstdruby/libzstd/common/fse.h +1 -1
  10. data/ext/zstdruby/libzstd/common/fse_decompress.c +2 -2
  11. data/ext/zstdruby/libzstd/common/huf.h +114 -89
  12. data/ext/zstdruby/libzstd/common/pool.c +46 -17
  13. data/ext/zstdruby/libzstd/common/pool.h +18 -9
  14. data/ext/zstdruby/libzstd/common/threading.h +12 -12
  15. data/ext/zstdruby/libzstd/common/zstd_errors.h +16 -7
  16. data/ext/zstdruby/libzstd/common/zstd_internal.h +4 -5
  17. data/ext/zstdruby/libzstd/compress/fse_compress.c +19 -11
  18. data/ext/zstdruby/libzstd/compress/huf_compress.c +160 -62
  19. data/ext/zstdruby/libzstd/compress/zstd_compress.c +973 -644
  20. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +281 -34
  21. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +80 -62
  22. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +11 -4
  23. data/ext/zstdruby/libzstd/compress/zstd_fast.c +87 -71
  24. data/ext/zstdruby/libzstd/compress/zstd_fast.h +10 -6
  25. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +333 -274
  26. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +33 -16
  27. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +305 -359
  28. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +64 -21
  29. data/ext/zstdruby/libzstd/compress/zstd_opt.c +194 -56
  30. data/ext/zstdruby/libzstd/compress/zstd_opt.h +17 -5
  31. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +1131 -449
  32. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +32 -16
  33. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +390 -290
  34. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +777 -439
  35. data/ext/zstdruby/libzstd/dictBuilder/cover.c +11 -8
  36. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +83 -50
  37. data/ext/zstdruby/libzstd/dictBuilder/zdict.h +44 -43
  38. data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +2 -0
  39. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +42 -118
  40. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +2 -2
  41. data/ext/zstdruby/libzstd/legacy/zstd_v07.c +2 -2
  42. data/ext/zstdruby/libzstd/zstd.h +254 -254
  43. data/lib/zstd-ruby/version.rb +1 -1
  44. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1b5fcad8a810e6565963ca4bd38db6723e579f84
4
- data.tar.gz: 059c0bfd179080c58371dc513e7aa088fdd67db8
2
+ SHA256:
3
+ metadata.gz: 100c4ca359fb8109a629f142d814ecd3fe1ff6854b6dead6c4f90a36f80f51c7
4
+ data.tar.gz: 5303f715113cae2061b9b837ad7e7b8fd29b31b0b493c856a669327ef17fe773
5
5
  SHA512:
6
- metadata.gz: f7273691052d4aa702351531f1dc314a9f99b460269a65c3b448b71da813315d07a00c60e4b6005e8377e5535e2f245777afecbf4b443d7058df6ac4f77f695a
7
- data.tar.gz: ff0aa695180188f1f7919415dec65e9a01756a8481446f4f02298e6b131eea2ca42f3da61c316fcaa9e92d07eb07a988a5e8e0c9091c9b60d169d477b19436b8
6
+ metadata.gz: 56af4d5c91af2fb6e70abdd970b5992751df49c234998ff127595c02c048439a3fccb98222a943581d539b98f98be3cd4804ad5b83bb20b04e4d5cfed2bac855
7
+ data.tar.gz: b34865a20495d4aa35c0740bf92a340d325ce1829d52d4dca8872243e16681263cb81e6d668431fe3b657d738d7099968ca16ebb399cede9497099bbea3077a2
data/README.md CHANGED
@@ -9,7 +9,7 @@ See https://github.com/facebook/zstd
9
9
  Fork from https://github.com/jarredholman/ruby-zstd.
10
10
 
11
11
  ## Zstd version
12
- v1.3.3 (https://github.com/facebook/zstd/tree/v1.3.3)
12
+ v1.3.4 (https://github.com/facebook/zstd/tree/v1.3.4)
13
13
 
14
14
  ## Installation
15
15
 
@@ -25,6 +25,9 @@ cxx_library(
25
25
  name='decompress',
26
26
  header_namespace='',
27
27
  visibility=['PUBLIC'],
28
+ headers=subdir_glob([
29
+ ('decompress', '*_impl.h'),
30
+ ]),
28
31
  srcs=glob(['decompress/zstd*.c']),
29
32
  deps=[
30
33
  ':common',
@@ -80,6 +83,15 @@ cxx_library(
80
83
  ]),
81
84
  )
82
85
 
86
+ cxx_library(
87
+ name='cpu',
88
+ header_namespace='',
89
+ visibility=['PUBLIC'],
90
+ exported_headers=subdir_glob([
91
+ ('common', 'cpu.h'),
92
+ ]),
93
+ )
94
+
83
95
  cxx_library(
84
96
  name='bitstream',
85
97
  header_namespace='',
@@ -196,6 +208,7 @@ cxx_library(
196
208
  deps=[
197
209
  ':bitstream',
198
210
  ':compiler',
211
+ ':cpu',
199
212
  ':entropy',
200
213
  ':errors',
201
214
  ':mem',
@@ -2,16 +2,19 @@ Zstandard library files
2
2
  ================================
3
3
 
4
4
  The __lib__ directory is split into several sub-directories,
5
- in order to make it easier to select or exclude specific features.
5
+ in order to make it easier to select or exclude features.
6
6
 
7
7
 
8
8
  #### Building
9
9
 
10
- `Makefile` script is provided, supporting the standard set of commands,
11
- directories, and variables (see https://www.gnu.org/prep/standards/html_node/Command-Variables.html).
10
+ `Makefile` script is provided, supporting all standard [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions),
11
+ including commands variables, staged install, directory variables and standard targets.
12
12
  - `make` : generates both static and dynamic libraries
13
13
  - `make install` : install libraries in default system directories
14
14
 
15
+ `libzstd` default scope includes compression, decompression, dictionary building,
16
+ and decoding support for legacy formats >= v0.4.0.
17
+
15
18
 
16
19
  #### API
17
20
 
@@ -27,29 +30,37 @@ Optional advanced features are exposed via :
27
30
  - `ZSTD_STATIC_LINKING_ONLY` : if this macro is defined _before_ including `zstd.h`,
28
31
  it unlocks access to advanced experimental API,
29
32
  exposed in second part of `zstd.h`.
30
- These APIs shall ___never be used with dynamic library___ !
31
- They are not "stable", their definition may change in the future.
33
+ These APIs are not "stable", their definition may change in the future.
34
+ As a consequence, it shall ___never be used with dynamic library___ !
32
35
  Only static linking is allowed.
33
36
 
34
37
 
35
38
  #### Modular build
36
39
 
40
+ It's possible to compile only a limited set of features.
41
+
37
42
  - Directory `lib/common` is always required, for all variants.
38
43
  - Compression source code lies in `lib/compress`
39
44
  - Decompression source code lies in `lib/decompress`
40
45
  - It's possible to include only `compress` or only `decompress`, they don't depend on each other.
41
46
  - `lib/dictBuilder` : makes it possible to generate dictionaries from a set of samples.
42
- The API is exposed in `lib/dictBuilder/zdict.h`.
43
- This module depends on both `lib/common` and `lib/compress` .
44
- - `lib/legacy` : source code to decompress older zstd formats, starting from `v0.1`.
45
- This module depends on `lib/common` and `lib/decompress`.
46
- To enable this feature, it's necessary to define `ZSTD_LEGACY_SUPPORT = 1` during compilation.
47
- Typically, with `gcc`, add argument `-DZSTD_LEGACY_SUPPORT=1`.
48
- Using higher number limits the number of version supported.
49
- For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats starting from v0.2+".
50
- The API is exposed in `lib/legacy/zstd_legacy.h`.
51
- Each version also provides a (dedicated) set of advanced API.
52
- For example, advanced API for version `v0.4` is exposed in `lib/legacy/zstd_v04.h` .
47
+ The API is exposed in `lib/dictBuilder/zdict.h`.
48
+ This module depends on both `lib/common` and `lib/compress` .
49
+ - `lib/legacy` : source code to decompress legacy zstd formats, starting from `v0.1.0`.
50
+ This module depends on `lib/common` and `lib/decompress`.
51
+ To enable this feature, it's required to define `ZSTD_LEGACY_SUPPORT` during compilation.
52
+ Typically, with `gcc`, add argument `-DZSTD_LEGACY_SUPPORT=1`.
53
+ Using higher number limits versions supported.
54
+ For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats >= v0.2.0".
55
+ `ZSTD_LEGACY_SUPPORT=3` means : "support legacy formats >= v0.3.0", and so on.
56
+ Starting v0.8.0, all versions of `zstd` produce frames compliant with specification.
57
+ As a consequence, `ZSTD_LEGACY_SUPPORT=8` (or more) doesn't trigger legacy support.
58
+ Also, `ZSTD_LEGACY_SUPPORT=0` means "do __not__ support legacy formats".
59
+ Once enabled, this capability is transparently triggered within decompression functions.
60
+ It's also possible to invoke directly legacy API, as exposed in `lib/legacy/zstd_legacy.h`.
61
+ Each version also provides an additional dedicated set of advanced API.
62
+ For example, advanced API for version `v0.4` is exposed in `lib/legacy/zstd_v04.h` .
63
+ Note : `lib/legacy` only supports _decoding_ legacy formats.
53
64
 
54
65
 
55
66
  #### Multithreading support
@@ -57,19 +68,16 @@ Optional advanced features are exposed via :
57
68
  Multithreading is disabled by default when building with `make`.
58
69
  Enabling multithreading requires 2 conditions :
59
70
  - set macro `ZSTD_MULTITHREAD`
60
- - on POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc` for example)
71
+ - on POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
61
72
 
62
73
  Both conditions are automatically triggered by invoking `make lib-mt` target.
63
74
  Note that, when linking a POSIX program with a multithreaded version of `libzstd`,
64
75
  it's necessary to trigger `-pthread` flag during link stage.
65
76
 
66
- Multithreading capabilities are exposed via :
67
- - private API `lib/compress/zstdmt_compress.h`.
68
- Symbols defined in this header are currently exposed in `libzstd`, hence usable.
69
- Note however that this API is planned to be locked and remain strictly internal in the future.
70
- - advanced API `ZSTD_compress_generic()`, defined in `lib/zstd.h`, experimental section.
71
- This API is still considered experimental, but is designed to be labelled "stable" at some point in the future.
72
- It's the recommended entry point for multi-threading operations.
77
+ Multithreading capabilities are exposed
78
+ via [advanced API `ZSTD_compress_generic()` defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/dev/lib/zstd.h#L919).
79
+ This API is still considered experimental,
80
+ but is expected to become "stable" at some point in the future.
73
81
 
74
82
 
75
83
  #### Windows : using MinGW+MSYS to create DLL
@@ -92,7 +100,6 @@ The compiled executable will require ZSTD DLL which is available at `dll\libzstd
92
100
 
93
101
  Obsolete API on their way out are stored in directory `lib/deprecated`.
94
102
  At this stage, it contains older streaming prototypes, in `lib/deprecated/zbuff.h`.
95
- Presence in this directory is temporary.
96
103
  These prototypes will be removed in some future version.
97
104
  Consider migrating code towards supported streaming API exposed in `zstd.h`.
98
105
 
@@ -426,7 +426,7 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
426
426
  * Refill `bitD` from buffer previously set in BIT_initDStream() .
427
427
  * This function is safe, it guarantees it will not read beyond src buffer.
428
428
  * @return : status of `BIT_DStream_t` internal register.
429
- * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
429
+ * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
430
430
  MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
431
431
  {
432
432
  if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
@@ -63,6 +63,31 @@
63
63
  # endif
64
64
  #endif
65
65
 
66
+ /* target attribute */
67
+ #ifndef __has_attribute
68
+ #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
69
+ #endif
70
+ #if defined(__GNUC__)
71
+ # define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
72
+ #else
73
+ # define TARGET_ATTRIBUTE(target)
74
+ #endif
75
+
76
+ /* Enable runtime BMI2 dispatch based on the CPU.
77
+ * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
78
+ */
79
+ #ifndef DYNAMIC_BMI2
80
+ #if (defined(__clang__) && __has_attribute(__target__)) \
81
+ || (defined(__GNUC__) \
82
+ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) \
83
+ && (defined(__x86_64__) || defined(_M_X86)) \
84
+ && !defined(__BMI2__)
85
+ # define DYNAMIC_BMI2 1
86
+ #else
87
+ # define DYNAMIC_BMI2 0
88
+ #endif
89
+ #endif
90
+
66
91
  /* prefetch */
67
92
  #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
68
93
  # include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
@@ -0,0 +1,216 @@
1
+ /*
2
+ * Copyright (c) 2018-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under both the BSD-style license (found in the
6
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7
+ * in the COPYING file in the root directory of this source tree).
8
+ * You may select, at your option, one of the above-listed licenses.
9
+ */
10
+
11
+ #ifndef ZSTD_COMMON_CPU_H
12
+ #define ZSTD_COMMON_CPU_H
13
+
14
+ /**
15
+ * Implementation taken from folly/CpuId.h
16
+ * https://github.com/facebook/folly/blob/master/folly/CpuId.h
17
+ */
18
+
19
+ #include <string.h>
20
+
21
+ #include "mem.h"
22
+
23
+ #ifdef _MSC_VER
24
+ #include <intrin.h>
25
+ #endif
26
+
27
+ typedef struct {
28
+ U32 f1c;
29
+ U32 f1d;
30
+ U32 f7b;
31
+ U32 f7c;
32
+ } ZSTD_cpuid_t;
33
+
34
+ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
35
+ U32 f1c = 0;
36
+ U32 f1d = 0;
37
+ U32 f7b = 0;
38
+ U32 f7c = 0;
39
+ #ifdef _MSC_VER
40
+ int reg[4];
41
+ __cpuid((int*)reg, 0);
42
+ {
43
+ int const n = reg[0];
44
+ if (n >= 1) {
45
+ __cpuid((int*)reg, 1);
46
+ f1c = (U32)reg[2];
47
+ f1d = (U32)reg[3];
48
+ }
49
+ if (n >= 7) {
50
+ __cpuidex((int*)reg, 7, 0);
51
+ f7b = (U32)reg[1];
52
+ f7c = (U32)reg[2];
53
+ }
54
+ }
55
+ #elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__)
56
+ /* The following block like the normal cpuid branch below, but gcc
57
+ * reserves ebx for use of its pic register so we must specially
58
+ * handle the save and restore to avoid clobbering the register
59
+ */
60
+ U32 n;
61
+ __asm__(
62
+ "pushl %%ebx\n\t"
63
+ "cpuid\n\t"
64
+ "popl %%ebx\n\t"
65
+ : "=a"(n)
66
+ : "a"(0)
67
+ : "ecx", "edx");
68
+ if (n >= 1) {
69
+ U32 f1a;
70
+ __asm__(
71
+ "pushl %%ebx\n\t"
72
+ "cpuid\n\t"
73
+ "popl %%ebx\n\t"
74
+ : "=a"(f1a), "=c"(f1c), "=d"(f1d)
75
+ : "a"(1)
76
+ :);
77
+ }
78
+ if (n >= 7) {
79
+ __asm__(
80
+ "pushl %%ebx\n\t"
81
+ "cpuid\n\t"
82
+ "movl %%ebx, %%eax\n\r"
83
+ "popl %%ebx"
84
+ : "=a"(f7b), "=c"(f7c)
85
+ : "a"(7), "c"(0)
86
+ : "edx");
87
+ }
88
+ #elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__)
89
+ U32 n;
90
+ __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx");
91
+ if (n >= 1) {
92
+ U32 f1a;
93
+ __asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx");
94
+ }
95
+ if (n >= 7) {
96
+ U32 f7a;
97
+ __asm__("cpuid"
98
+ : "=a"(f7a), "=b"(f7b), "=c"(f7c)
99
+ : "a"(7), "c"(0)
100
+ : "edx");
101
+ }
102
+ #endif
103
+ {
104
+ ZSTD_cpuid_t cpuid;
105
+ cpuid.f1c = f1c;
106
+ cpuid.f1d = f1d;
107
+ cpuid.f7b = f7b;
108
+ cpuid.f7c = f7c;
109
+ return cpuid;
110
+ }
111
+ }
112
+
113
+ #define X(name, r, bit) \
114
+ MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) { \
115
+ return ((cpuid.r) & (1U << bit)) != 0; \
116
+ }
117
+
118
+ /* cpuid(1): Processor Info and Feature Bits. */
119
+ #define C(name, bit) X(name, f1c, bit)
120
+ C(sse3, 0)
121
+ C(pclmuldq, 1)
122
+ C(dtes64, 2)
123
+ C(monitor, 3)
124
+ C(dscpl, 4)
125
+ C(vmx, 5)
126
+ C(smx, 6)
127
+ C(eist, 7)
128
+ C(tm2, 8)
129
+ C(ssse3, 9)
130
+ C(cnxtid, 10)
131
+ C(fma, 12)
132
+ C(cx16, 13)
133
+ C(xtpr, 14)
134
+ C(pdcm, 15)
135
+ C(pcid, 17)
136
+ C(dca, 18)
137
+ C(sse41, 19)
138
+ C(sse42, 20)
139
+ C(x2apic, 21)
140
+ C(movbe, 22)
141
+ C(popcnt, 23)
142
+ C(tscdeadline, 24)
143
+ C(aes, 25)
144
+ C(xsave, 26)
145
+ C(osxsave, 27)
146
+ C(avx, 28)
147
+ C(f16c, 29)
148
+ C(rdrand, 30)
149
+ #undef C
150
+ #define D(name, bit) X(name, f1d, bit)
151
+ D(fpu, 0)
152
+ D(vme, 1)
153
+ D(de, 2)
154
+ D(pse, 3)
155
+ D(tsc, 4)
156
+ D(msr, 5)
157
+ D(pae, 6)
158
+ D(mce, 7)
159
+ D(cx8, 8)
160
+ D(apic, 9)
161
+ D(sep, 11)
162
+ D(mtrr, 12)
163
+ D(pge, 13)
164
+ D(mca, 14)
165
+ D(cmov, 15)
166
+ D(pat, 16)
167
+ D(pse36, 17)
168
+ D(psn, 18)
169
+ D(clfsh, 19)
170
+ D(ds, 21)
171
+ D(acpi, 22)
172
+ D(mmx, 23)
173
+ D(fxsr, 24)
174
+ D(sse, 25)
175
+ D(sse2, 26)
176
+ D(ss, 27)
177
+ D(htt, 28)
178
+ D(tm, 29)
179
+ D(pbe, 31)
180
+ #undef D
181
+
182
+ /* cpuid(7): Extended Features. */
183
+ #define B(name, bit) X(name, f7b, bit)
184
+ B(bmi1, 3)
185
+ B(hle, 4)
186
+ B(avx2, 5)
187
+ B(smep, 7)
188
+ B(bmi2, 8)
189
+ B(erms, 9)
190
+ B(invpcid, 10)
191
+ B(rtm, 11)
192
+ B(mpx, 14)
193
+ B(avx512f, 16)
194
+ B(avx512dq, 17)
195
+ B(rdseed, 18)
196
+ B(adx, 19)
197
+ B(smap, 20)
198
+ B(avx512ifma, 21)
199
+ B(pcommit, 22)
200
+ B(clflushopt, 23)
201
+ B(clwb, 24)
202
+ B(avx512pf, 26)
203
+ B(avx512er, 27)
204
+ B(avx512cd, 28)
205
+ B(sha, 29)
206
+ B(avx512bw, 30)
207
+ B(avx512vl, 31)
208
+ #undef B
209
+ #define C(name, bit) X(name, f7c, bit)
210
+ C(prefetchwt1, 0)
211
+ C(avx512vbmi, 1)
212
+ #undef C
213
+
214
+ #undef X
215
+
216
+ #endif /* ZSTD_COMMON_CPU_H */
@@ -29,6 +29,7 @@ const char* ERR_getErrorString(ERR_enum code)
29
29
  case PREFIX(parameter_outOfBound): return "Parameter is out of bound";
30
30
  case PREFIX(init_missing): return "Context should be init first";
31
31
  case PREFIX(memory_allocation): return "Allocation error : not enough memory";
32
+ case PREFIX(workSpace_tooSmall): return "workSpace buffer is not large enough";
32
33
  case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
33
34
  case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
34
35
  case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
@@ -345,7 +345,7 @@ size_t FSE_countFast(unsigned* count, unsigned* maxSymbolValuePtr, const void* s
345
345
  */
346
346
  size_t FSE_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize, unsigned* workSpace);
347
347
 
348
- /*! FSE_count_simple
348
+ /*! FSE_count_simple() :
349
349
  * Same as FSE_countFast(), but does not use any additional memory (not even on stack).
350
350
  * This function is unsafe, and will segfault if any value within `src` is `> *maxSymbolValuePtr` (presuming it's also the size of `count`).
351
351
  */
@@ -139,8 +139,8 @@ size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned
139
139
  { U32 u;
140
140
  for (u=0; u<tableSize; u++) {
141
141
  FSE_FUNCTION_TYPE const symbol = (FSE_FUNCTION_TYPE)(tableDecode[u].symbol);
142
- U16 nextState = symbolNext[symbol]++;
143
- tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32 ((U32)nextState) );
142
+ U32 const nextState = symbolNext[symbol]++;
143
+ tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32(nextState) );
144
144
  tableDecode[u].newState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize);
145
145
  } }
146
146