extzstd 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/contrib/zstd/CHANGELOG +188 -1
  4. data/contrib/zstd/CONTRIBUTING.md +157 -74
  5. data/contrib/zstd/LICENSE +4 -4
  6. data/contrib/zstd/Makefile +81 -58
  7. data/contrib/zstd/Package.swift +36 -0
  8. data/contrib/zstd/README.md +59 -35
  9. data/contrib/zstd/TESTING.md +2 -3
  10. data/contrib/zstd/appveyor.yml +49 -136
  11. data/contrib/zstd/lib/BUCK +5 -7
  12. data/contrib/zstd/lib/Makefile +87 -181
  13. data/contrib/zstd/lib/README.md +23 -6
  14. data/contrib/zstd/lib/common/allocations.h +55 -0
  15. data/contrib/zstd/lib/common/bits.h +200 -0
  16. data/contrib/zstd/lib/common/bitstream.h +33 -59
  17. data/contrib/zstd/lib/common/compiler.h +115 -45
  18. data/contrib/zstd/lib/common/cpu.h +1 -1
  19. data/contrib/zstd/lib/common/debug.c +1 -1
  20. data/contrib/zstd/lib/common/debug.h +1 -1
  21. data/contrib/zstd/lib/common/entropy_common.c +15 -37
  22. data/contrib/zstd/lib/common/error_private.c +9 -2
  23. data/contrib/zstd/lib/common/error_private.h +82 -3
  24. data/contrib/zstd/lib/common/fse.h +9 -85
  25. data/contrib/zstd/lib/common/fse_decompress.c +29 -111
  26. data/contrib/zstd/lib/common/huf.h +84 -172
  27. data/contrib/zstd/lib/common/mem.h +58 -49
  28. data/contrib/zstd/lib/common/pool.c +37 -16
  29. data/contrib/zstd/lib/common/pool.h +9 -3
  30. data/contrib/zstd/lib/common/portability_macros.h +156 -0
  31. data/contrib/zstd/lib/common/threading.c +68 -14
  32. data/contrib/zstd/lib/common/threading.h +5 -10
  33. data/contrib/zstd/lib/common/xxhash.c +7 -809
  34. data/contrib/zstd/lib/common/xxhash.h +5568 -167
  35. data/contrib/zstd/lib/common/zstd_common.c +1 -36
  36. data/contrib/zstd/lib/common/zstd_deps.h +1 -1
  37. data/contrib/zstd/lib/common/zstd_internal.h +64 -150
  38. data/contrib/zstd/lib/common/zstd_trace.h +163 -0
  39. data/contrib/zstd/lib/compress/clevels.h +134 -0
  40. data/contrib/zstd/lib/compress/fse_compress.c +69 -150
  41. data/contrib/zstd/lib/compress/hist.c +1 -1
  42. data/contrib/zstd/lib/compress/hist.h +1 -1
  43. data/contrib/zstd/lib/compress/huf_compress.c +773 -251
  44. data/contrib/zstd/lib/compress/zstd_compress.c +2650 -826
  45. data/contrib/zstd/lib/compress/zstd_compress_internal.h +509 -180
  46. data/contrib/zstd/lib/compress/zstd_compress_literals.c +117 -40
  47. data/contrib/zstd/lib/compress/zstd_compress_literals.h +16 -6
  48. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +28 -19
  49. data/contrib/zstd/lib/compress/zstd_compress_sequences.h +1 -1
  50. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +33 -305
  51. data/contrib/zstd/lib/compress/zstd_compress_superblock.h +1 -1
  52. data/contrib/zstd/lib/compress/zstd_cwksp.h +266 -85
  53. data/contrib/zstd/lib/compress/zstd_double_fast.c +369 -132
  54. data/contrib/zstd/lib/compress/zstd_double_fast.h +3 -2
  55. data/contrib/zstd/lib/compress/zstd_fast.c +722 -258
  56. data/contrib/zstd/lib/compress/zstd_fast.h +3 -2
  57. data/contrib/zstd/lib/compress/zstd_lazy.c +1105 -360
  58. data/contrib/zstd/lib/compress/zstd_lazy.h +41 -1
  59. data/contrib/zstd/lib/compress/zstd_ldm.c +272 -208
  60. data/contrib/zstd/lib/compress/zstd_ldm.h +3 -2
  61. data/contrib/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
  62. data/contrib/zstd/lib/compress/zstd_opt.c +324 -197
  63. data/contrib/zstd/lib/compress/zstd_opt.h +1 -1
  64. data/contrib/zstd/lib/compress/zstdmt_compress.c +109 -53
  65. data/contrib/zstd/lib/compress/zstdmt_compress.h +9 -6
  66. data/contrib/zstd/lib/decompress/huf_decompress.c +1071 -539
  67. data/contrib/zstd/lib/decompress/huf_decompress_amd64.S +576 -0
  68. data/contrib/zstd/lib/decompress/zstd_ddict.c +4 -4
  69. data/contrib/zstd/lib/decompress/zstd_ddict.h +1 -1
  70. data/contrib/zstd/lib/decompress/zstd_decompress.c +507 -82
  71. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +962 -310
  72. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +14 -3
  73. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +54 -6
  74. data/contrib/zstd/lib/deprecated/zbuff.h +1 -1
  75. data/contrib/zstd/lib/deprecated/zbuff_common.c +1 -1
  76. data/contrib/zstd/lib/deprecated/zbuff_compress.c +24 -4
  77. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +3 -1
  78. data/contrib/zstd/lib/dictBuilder/cover.c +44 -32
  79. data/contrib/zstd/lib/dictBuilder/cover.h +6 -5
  80. data/contrib/zstd/lib/dictBuilder/divsufsort.c +1 -1
  81. data/contrib/zstd/lib/dictBuilder/fastcover.c +24 -16
  82. data/contrib/zstd/lib/dictBuilder/zdict.c +88 -95
  83. data/contrib/zstd/lib/legacy/zstd_legacy.h +8 -1
  84. data/contrib/zstd/lib/legacy/zstd_v01.c +16 -53
  85. data/contrib/zstd/lib/legacy/zstd_v01.h +1 -1
  86. data/contrib/zstd/lib/legacy/zstd_v02.c +24 -69
  87. data/contrib/zstd/lib/legacy/zstd_v02.h +1 -1
  88. data/contrib/zstd/lib/legacy/zstd_v03.c +25 -72
  89. data/contrib/zstd/lib/legacy/zstd_v03.h +1 -1
  90. data/contrib/zstd/lib/legacy/zstd_v04.c +23 -69
  91. data/contrib/zstd/lib/legacy/zstd_v04.h +1 -1
  92. data/contrib/zstd/lib/legacy/zstd_v05.c +35 -85
  93. data/contrib/zstd/lib/legacy/zstd_v05.h +1 -1
  94. data/contrib/zstd/lib/legacy/zstd_v06.c +42 -87
  95. data/contrib/zstd/lib/legacy/zstd_v06.h +1 -1
  96. data/contrib/zstd/lib/legacy/zstd_v07.c +35 -82
  97. data/contrib/zstd/lib/legacy/zstd_v07.h +1 -1
  98. data/contrib/zstd/lib/libzstd.mk +214 -0
  99. data/contrib/zstd/lib/libzstd.pc.in +4 -3
  100. data/contrib/zstd/lib/module.modulemap +35 -0
  101. data/contrib/zstd/lib/{dictBuilder/zdict.h → zdict.h} +202 -33
  102. data/contrib/zstd/lib/zstd.h +922 -293
  103. data/contrib/zstd/lib/{common/zstd_errors.h → zstd_errors.h} +27 -8
  104. data/ext/extconf.rb +7 -6
  105. data/ext/extzstd.c +13 -10
  106. data/ext/libzstd_conf.h +0 -1
  107. data/ext/zstd_decompress_asm.S +1 -0
  108. metadata +16 -5
@@ -1,6 +1,6 @@
1
1
  /* ******************************************************************
2
2
  * Common functions of New Generation Entropy library
3
- * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
  *
5
5
  * You can contact the author at :
6
6
  * - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
@@ -19,8 +19,8 @@
19
19
  #include "error_private.h" /* ERR_*, ERROR */
20
20
  #define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */
21
21
  #include "fse.h"
22
- #define HUF_STATIC_LINKING_ONLY /* HUF_TABLELOG_ABSOLUTEMAX */
23
22
  #include "huf.h"
23
+ #include "bits.h" /* ZSDT_highbit32, ZSTD_countTrailingZeros32 */
24
24
 
25
25
 
26
26
  /*=== Version ===*/
@@ -38,28 +38,6 @@ const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
38
38
  /*-**************************************************************
39
39
  * FSE NCount encoding-decoding
40
40
  ****************************************************************/
41
- static U32 FSE_ctz(U32 val)
42
- {
43
- assert(val != 0);
44
- {
45
- # if defined(_MSC_VER) /* Visual */
46
- unsigned long r=0;
47
- return _BitScanForward(&r, val) ? (unsigned)r : 0;
48
- # elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
49
- return __builtin_ctz(val);
50
- # elif defined(__ICCARM__) /* IAR Intrinsic */
51
- return __CTZ(val);
52
- # else /* Software version */
53
- U32 count = 0;
54
- while ((val & 1) == 0) {
55
- val >>= 1;
56
- ++count;
57
- }
58
- return count;
59
- # endif
60
- }
61
- }
62
-
63
41
  FORCE_INLINE_TEMPLATE
64
42
  size_t FSE_readNCount_body(short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
65
43
  const void* headerBuffer, size_t hbSize)
@@ -107,7 +85,7 @@ size_t FSE_readNCount_body(short* normalizedCounter, unsigned* maxSVPtr, unsigne
107
85
  * repeat.
108
86
  * Avoid UB by setting the high bit to 1.
109
87
  */
110
- int repeats = FSE_ctz(~bitStream | 0x80000000) >> 1;
88
+ int repeats = ZSTD_countTrailingZeros32(~bitStream | 0x80000000) >> 1;
111
89
  while (repeats >= 12) {
112
90
  charnum += 3 * 12;
113
91
  if (LIKELY(ip <= iend-7)) {
@@ -118,7 +96,7 @@ size_t FSE_readNCount_body(short* normalizedCounter, unsigned* maxSVPtr, unsigne
118
96
  ip = iend - 4;
119
97
  }
120
98
  bitStream = MEM_readLE32(ip) >> bitCount;
121
- repeats = FSE_ctz(~bitStream | 0x80000000) >> 1;
99
+ repeats = ZSTD_countTrailingZeros32(~bitStream | 0x80000000) >> 1;
122
100
  }
123
101
  charnum += 3 * repeats;
124
102
  bitStream >>= 2 * repeats;
@@ -183,7 +161,7 @@ size_t FSE_readNCount_body(short* normalizedCounter, unsigned* maxSVPtr, unsigne
183
161
  * know that threshold > 1.
184
162
  */
185
163
  if (remaining <= 1) break;
186
- nbBits = BIT_highbit32(remaining) + 1;
164
+ nbBits = ZSTD_highbit32(remaining) + 1;
187
165
  threshold = 1 << (nbBits - 1);
188
166
  }
189
167
  if (charnum >= maxSV1) break;
@@ -217,7 +195,7 @@ static size_t FSE_readNCount_body_default(
217
195
  }
218
196
 
219
197
  #if DYNAMIC_BMI2
220
- TARGET_ATTRIBUTE("bmi2") static size_t FSE_readNCount_body_bmi2(
198
+ BMI2_TARGET_ATTRIBUTE static size_t FSE_readNCount_body_bmi2(
221
199
  short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
222
200
  const void* headerBuffer, size_t hbSize)
223
201
  {
@@ -258,7 +236,7 @@ size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
258
236
  const void* src, size_t srcSize)
259
237
  {
260
238
  U32 wksp[HUF_READ_STATS_WORKSPACE_SIZE_U32];
261
- return HUF_readStats_wksp(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, wksp, sizeof(wksp), /* bmi2 */ 0);
239
+ return HUF_readStats_wksp(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, wksp, sizeof(wksp), /* flags */ 0);
262
240
  }
263
241
 
264
242
  FORCE_INLINE_TEMPLATE size_t
@@ -299,21 +277,21 @@ HUF_readStats_body(BYTE* huffWeight, size_t hwSize, U32* rankStats,
299
277
  ZSTD_memset(rankStats, 0, (HUF_TABLELOG_MAX + 1) * sizeof(U32));
300
278
  weightTotal = 0;
301
279
  { U32 n; for (n=0; n<oSize; n++) {
302
- if (huffWeight[n] >= HUF_TABLELOG_MAX) return ERROR(corruption_detected);
280
+ if (huffWeight[n] > HUF_TABLELOG_MAX) return ERROR(corruption_detected);
303
281
  rankStats[huffWeight[n]]++;
304
282
  weightTotal += (1 << huffWeight[n]) >> 1;
305
283
  } }
306
284
  if (weightTotal == 0) return ERROR(corruption_detected);
307
285
 
308
286
  /* get last non-null symbol weight (implied, total must be 2^n) */
309
- { U32 const tableLog = BIT_highbit32(weightTotal) + 1;
287
+ { U32 const tableLog = ZSTD_highbit32(weightTotal) + 1;
310
288
  if (tableLog > HUF_TABLELOG_MAX) return ERROR(corruption_detected);
311
289
  *tableLogPtr = tableLog;
312
290
  /* determine last weight */
313
291
  { U32 const total = 1 << tableLog;
314
292
  U32 const rest = total - weightTotal;
315
- U32 const verif = 1 << BIT_highbit32(rest);
316
- U32 const lastWeight = BIT_highbit32(rest) + 1;
293
+ U32 const verif = 1 << ZSTD_highbit32(rest);
294
+ U32 const lastWeight = ZSTD_highbit32(rest) + 1;
317
295
  if (verif != rest) return ERROR(corruption_detected); /* last value must be a clean power of 2 */
318
296
  huffWeight[oSize] = (BYTE)lastWeight;
319
297
  rankStats[lastWeight]++;
@@ -337,7 +315,7 @@ static size_t HUF_readStats_body_default(BYTE* huffWeight, size_t hwSize, U32* r
337
315
  }
338
316
 
339
317
  #if DYNAMIC_BMI2
340
- static TARGET_ATTRIBUTE("bmi2") size_t HUF_readStats_body_bmi2(BYTE* huffWeight, size_t hwSize, U32* rankStats,
318
+ static BMI2_TARGET_ATTRIBUTE size_t HUF_readStats_body_bmi2(BYTE* huffWeight, size_t hwSize, U32* rankStats,
341
319
  U32* nbSymbolsPtr, U32* tableLogPtr,
342
320
  const void* src, size_t srcSize,
343
321
  void* workSpace, size_t wkspSize)
@@ -350,13 +328,13 @@ size_t HUF_readStats_wksp(BYTE* huffWeight, size_t hwSize, U32* rankStats,
350
328
  U32* nbSymbolsPtr, U32* tableLogPtr,
351
329
  const void* src, size_t srcSize,
352
330
  void* workSpace, size_t wkspSize,
353
- int bmi2)
331
+ int flags)
354
332
  {
355
333
  #if DYNAMIC_BMI2
356
- if (bmi2) {
334
+ if (flags & HUF_flags_bmi2) {
357
335
  return HUF_readStats_body_bmi2(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, workSpace, wkspSize);
358
336
  }
359
337
  #endif
360
- (void)bmi2;
338
+ (void)flags;
361
339
  return HUF_readStats_body_default(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, workSpace, wkspSize);
362
340
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under both the BSD-style license (found in the
@@ -27,9 +27,11 @@ const char* ERR_getErrorString(ERR_enum code)
27
27
  case PREFIX(version_unsupported): return "Version not supported";
28
28
  case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
29
29
  case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
30
- case PREFIX(corruption_detected): return "Corrupted block detected";
30
+ case PREFIX(corruption_detected): return "Data corruption detected";
31
31
  case PREFIX(checksum_wrong): return "Restored data doesn't match checksum";
32
+ case PREFIX(literals_headerWrong): return "Header of Literals' block doesn't respect format specification";
32
33
  case PREFIX(parameter_unsupported): return "Unsupported parameter";
34
+ case PREFIX(parameter_combination_unsupported): return "Unsupported combination of parameters";
33
35
  case PREFIX(parameter_outOfBound): return "Parameter is out of bound";
34
36
  case PREFIX(init_missing): return "Context should be init first";
35
37
  case PREFIX(memory_allocation): return "Allocation error : not enough memory";
@@ -38,17 +40,22 @@ const char* ERR_getErrorString(ERR_enum code)
38
40
  case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
39
41
  case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
40
42
  case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
43
+ case PREFIX(stabilityCondition_notRespected): return "pledged buffer stability condition is not respected";
41
44
  case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
42
45
  case PREFIX(dictionary_wrong): return "Dictionary mismatch";
43
46
  case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
44
47
  case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
45
48
  case PREFIX(srcSize_wrong): return "Src size is incorrect";
46
49
  case PREFIX(dstBuffer_null): return "Operation on NULL destination buffer";
50
+ case PREFIX(noForwardProgress_destFull): return "Operation made no progress over multiple calls, due to output buffer being full";
51
+ case PREFIX(noForwardProgress_inputEmpty): return "Operation made no progress over multiple calls, due to input being empty";
47
52
  /* following error codes are not stable and may be removed or changed in a future version */
48
53
  case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
49
54
  case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
50
55
  case PREFIX(dstBuffer_wrong): return "Destination buffer is wrong";
51
56
  case PREFIX(srcBuffer_wrong): return "Source buffer is wrong";
57
+ case PREFIX(sequenceProducer_failed): return "Block-level external sequence producer returned an error code";
58
+ case PREFIX(externalSequences_invalid): return "External sequences are not valid";
52
59
  case PREFIX(maxCode):
53
60
  default: return notErrorCode;
54
61
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under both the BSD-style license (found in the
@@ -21,8 +21,10 @@ extern "C" {
21
21
  /* ****************************************
22
22
  * Dependencies
23
23
  ******************************************/
24
- #include "zstd_deps.h" /* size_t */
25
- #include "zstd_errors.h" /* enum list */
24
+ #include "../zstd_errors.h" /* enum list */
25
+ #include "compiler.h"
26
+ #include "debug.h"
27
+ #include "zstd_deps.h" /* size_t */
26
28
 
27
29
 
28
30
  /* ****************************************
@@ -73,6 +75,83 @@ ERR_STATIC const char* ERR_getErrorName(size_t code)
73
75
  return ERR_getErrorString(ERR_getErrorCode(code));
74
76
  }
75
77
 
78
+ /**
79
+ * Ignore: this is an internal helper.
80
+ *
81
+ * This is a helper function to help force C99-correctness during compilation.
82
+ * Under strict compilation modes, variadic macro arguments can't be empty.
83
+ * However, variadic function arguments can be. Using a function therefore lets
84
+ * us statically check that at least one (string) argument was passed,
85
+ * independent of the compilation flags.
86
+ */
87
+ static INLINE_KEYWORD UNUSED_ATTR
88
+ void _force_has_format_string(const char *format, ...) {
89
+ (void)format;
90
+ }
91
+
92
+ /**
93
+ * Ignore: this is an internal helper.
94
+ *
95
+ * We want to force this function invocation to be syntactically correct, but
96
+ * we don't want to force runtime evaluation of its arguments.
97
+ */
98
+ #define _FORCE_HAS_FORMAT_STRING(...) \
99
+ if (0) { \
100
+ _force_has_format_string(__VA_ARGS__); \
101
+ }
102
+
103
+ #define ERR_QUOTE(str) #str
104
+
105
+ /**
106
+ * Return the specified error if the condition evaluates to true.
107
+ *
108
+ * In debug modes, prints additional information.
109
+ * In order to do that (particularly, printing the conditional that failed),
110
+ * this can't just wrap RETURN_ERROR().
111
+ */
112
+ #define RETURN_ERROR_IF(cond, err, ...) \
113
+ if (cond) { \
114
+ RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", \
115
+ __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
116
+ _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
117
+ RAWLOG(3, ": " __VA_ARGS__); \
118
+ RAWLOG(3, "\n"); \
119
+ return ERROR(err); \
120
+ }
121
+
122
+ /**
123
+ * Unconditionally return the specified error.
124
+ *
125
+ * In debug modes, prints additional information.
126
+ */
127
+ #define RETURN_ERROR(err, ...) \
128
+ do { \
129
+ RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
130
+ __FILE__, __LINE__, ERR_QUOTE(ERROR(err))); \
131
+ _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
132
+ RAWLOG(3, ": " __VA_ARGS__); \
133
+ RAWLOG(3, "\n"); \
134
+ return ERROR(err); \
135
+ } while(0);
136
+
137
+ /**
138
+ * If the provided expression evaluates to an error code, returns that error code.
139
+ *
140
+ * In debug modes, prints additional information.
141
+ */
142
+ #define FORWARD_IF_ERROR(err, ...) \
143
+ do { \
144
+ size_t const err_code = (err); \
145
+ if (ERR_isError(err_code)) { \
146
+ RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", \
147
+ __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
148
+ _FORCE_HAS_FORMAT_STRING(__VA_ARGS__); \
149
+ RAWLOG(3, ": " __VA_ARGS__); \
150
+ RAWLOG(3, "\n"); \
151
+ return err_code; \
152
+ } \
153
+ } while(0);
154
+
76
155
  #if defined (__cplusplus)
77
156
  }
78
157
  #endif
@@ -1,7 +1,7 @@
1
1
  /* ******************************************************************
2
2
  * FSE : Finite State Entropy codec
3
3
  * Public Prototypes declaration
4
- * Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
6
6
  * You can contact the author at :
7
7
  * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
@@ -53,34 +53,6 @@ extern "C" {
53
53
  FSE_PUBLIC_API unsigned FSE_versionNumber(void); /**< library version number; to be used when checking dll version */
54
54
 
55
55
 
56
- /*-****************************************
57
- * FSE simple functions
58
- ******************************************/
59
- /*! FSE_compress() :
60
- Compress content of buffer 'src', of size 'srcSize', into destination buffer 'dst'.
61
- 'dst' buffer must be already allocated. Compression runs faster is dstCapacity >= FSE_compressBound(srcSize).
62
- @return : size of compressed data (<= dstCapacity).
63
- Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
64
- if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression instead.
65
- if FSE_isError(return), compression failed (more details using FSE_getErrorName())
66
- */
67
- FSE_PUBLIC_API size_t FSE_compress(void* dst, size_t dstCapacity,
68
- const void* src, size_t srcSize);
69
-
70
- /*! FSE_decompress():
71
- Decompress FSE data from buffer 'cSrc', of size 'cSrcSize',
72
- into already allocated destination buffer 'dst', of size 'dstCapacity'.
73
- @return : size of regenerated data (<= maxDstSize),
74
- or an error code, which can be tested using FSE_isError() .
75
-
76
- ** Important ** : FSE_decompress() does not decompress non-compressible nor RLE data !!!
77
- Why ? : making this distinction requires a header.
78
- Header management is intentionally delegated to the user layer, which can better manage special cases.
79
- */
80
- FSE_PUBLIC_API size_t FSE_decompress(void* dst, size_t dstCapacity,
81
- const void* cSrc, size_t cSrcSize);
82
-
83
-
84
56
  /*-*****************************************
85
57
  * Tool functions
86
58
  ******************************************/
@@ -91,20 +63,6 @@ FSE_PUBLIC_API unsigned FSE_isError(size_t code); /* tells if a return
91
63
  FSE_PUBLIC_API const char* FSE_getErrorName(size_t code); /* provides error code string (useful for debugging) */
92
64
 
93
65
 
94
- /*-*****************************************
95
- * FSE advanced functions
96
- ******************************************/
97
- /*! FSE_compress2() :
98
- Same as FSE_compress(), but allows the selection of 'maxSymbolValue' and 'tableLog'
99
- Both parameters can be defined as '0' to mean : use default value
100
- @return : size of compressed data
101
- Special values : if return == 0, srcData is not compressible => Nothing is stored within cSrc !!!
102
- if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression.
103
- if FSE_isError(return), it's an error code.
104
- */
105
- FSE_PUBLIC_API size_t FSE_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
106
-
107
-
108
66
  /*-*****************************************
109
67
  * FSE detailed API
110
68
  ******************************************/
@@ -164,8 +122,6 @@ FSE_PUBLIC_API size_t FSE_writeNCount (void* buffer, size_t bufferSize,
164
122
  /*! Constructor and Destructor of FSE_CTable.
165
123
  Note that FSE_CTable size depends on 'tableLog' and 'maxSymbolValue' */
166
124
  typedef unsigned FSE_CTable; /* don't allocate that. It's only meant to be more restrictive than void* */
167
- FSE_PUBLIC_API FSE_CTable* FSE_createCTable (unsigned maxSymbolValue, unsigned tableLog);
168
- FSE_PUBLIC_API void FSE_freeCTable (FSE_CTable* ct);
169
125
 
170
126
  /*! FSE_buildCTable():
171
127
  Builds `ct`, which must be already allocated, using FSE_createCTable().
@@ -241,23 +197,7 @@ FSE_PUBLIC_API size_t FSE_readNCount_bmi2(short* normalizedCounter,
241
197
  unsigned* maxSymbolValuePtr, unsigned* tableLogPtr,
242
198
  const void* rBuffer, size_t rBuffSize, int bmi2);
243
199
 
244
- /*! Constructor and Destructor of FSE_DTable.
245
- Note that its size depends on 'tableLog' */
246
200
  typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be more restrictive than void* */
247
- FSE_PUBLIC_API FSE_DTable* FSE_createDTable(unsigned tableLog);
248
- FSE_PUBLIC_API void FSE_freeDTable(FSE_DTable* dt);
249
-
250
- /*! FSE_buildDTable():
251
- Builds 'dt', which must be already allocated, using FSE_createDTable().
252
- return : 0, or an errorCode, which can be tested using FSE_isError() */
253
- FSE_PUBLIC_API size_t FSE_buildDTable (FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
254
-
255
- /*! FSE_decompress_usingDTable():
256
- Decompress compressed source `cSrc` of size `cSrcSize` using `dt`
257
- into `dst` which must be already allocated.
258
- @return : size of regenerated data (necessarily <= `dstCapacity`),
259
- or an errorCode, which can be tested using FSE_isError() */
260
- FSE_PUBLIC_API size_t FSE_decompress_usingDTable(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, const FSE_DTable* dt);
261
201
 
262
202
  /*!
263
203
  Tutorial :
@@ -320,24 +260,16 @@ If there is an error, the function will return an error code, which can be teste
320
260
  unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, unsigned minus);
321
261
  /**< same as FSE_optimalTableLog(), which used `minus==2` */
322
262
 
323
- /* FSE_compress_wksp() :
324
- * Same as FSE_compress2(), but using an externally allocated scratch buffer (`workSpace`).
325
- * FSE_COMPRESS_WKSP_SIZE_U32() provides the minimum size required for `workSpace` as a table of FSE_CTable.
326
- */
327
- #define FSE_COMPRESS_WKSP_SIZE_U32(maxTableLog, maxSymbolValue) ( FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) + ((maxTableLog > 12) ? (1 << (maxTableLog - 2)) : 1024) )
328
- size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
329
-
330
- size_t FSE_buildCTable_raw (FSE_CTable* ct, unsigned nbBits);
331
- /**< build a fake FSE_CTable, designed for a flat distribution, where each symbol uses nbBits */
332
-
333
263
  size_t FSE_buildCTable_rle (FSE_CTable* ct, unsigned char symbolValue);
334
264
  /**< build a fake FSE_CTable, designed to compress always the same symbolValue */
335
265
 
336
266
  /* FSE_buildCTable_wksp() :
337
267
  * Same as FSE_buildCTable(), but using an externally allocated scratch buffer (`workSpace`).
338
- * `wkspSize` must be >= `FSE_BUILD_CTABLE_WORKSPACE_SIZE(maxSymbolValue, tableLog)`.
268
+ * `wkspSize` must be >= `FSE_BUILD_CTABLE_WORKSPACE_SIZE_U32(maxSymbolValue, tableLog)` of `unsigned`.
269
+ * See FSE_buildCTable_wksp() for breakdown of workspace usage.
339
270
  */
340
- #define FSE_BUILD_CTABLE_WORKSPACE_SIZE(maxSymbolValue, tableLog) (sizeof(unsigned) * (maxSymbolValue + 2) + (1ull << tableLog))
271
+ #define FSE_BUILD_CTABLE_WORKSPACE_SIZE_U32(maxSymbolValue, tableLog) (((maxSymbolValue + 2) + (1ull << (tableLog)))/2 + sizeof(U64)/sizeof(U32) /* additional 8 bytes for potential table overwrite */)
272
+ #define FSE_BUILD_CTABLE_WORKSPACE_SIZE(maxSymbolValue, tableLog) (sizeof(unsigned) * FSE_BUILD_CTABLE_WORKSPACE_SIZE_U32(maxSymbolValue, tableLog))
341
273
  size_t FSE_buildCTable_wksp(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
342
274
 
343
275
  #define FSE_BUILD_DTABLE_WKSP_SIZE(maxTableLog, maxSymbolValue) (sizeof(short) * (maxSymbolValue + 1) + (1ULL << maxTableLog) + 8)
@@ -345,19 +277,11 @@ size_t FSE_buildCTable_wksp(FSE_CTable* ct, const short* normalizedCounter, unsi
345
277
  FSE_PUBLIC_API size_t FSE_buildDTable_wksp(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
346
278
  /**< Same as FSE_buildDTable(), using an externally allocated `workspace` produced with `FSE_BUILD_DTABLE_WKSP_SIZE_U32(maxSymbolValue)` */
347
279
 
348
- size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits);
349
- /**< build a fake FSE_DTable, designed to read a flat distribution where each symbol uses nbBits */
350
-
351
- size_t FSE_buildDTable_rle (FSE_DTable* dt, unsigned char symbolValue);
352
- /**< build a fake FSE_DTable, designed to always generate the same symbolValue */
353
-
354
- #define FSE_DECOMPRESS_WKSP_SIZE_U32(maxTableLog, maxSymbolValue) (FSE_DTABLE_SIZE_U32(maxTableLog) + FSE_BUILD_DTABLE_WKSP_SIZE_U32(maxTableLog, maxSymbolValue))
280
+ #define FSE_DECOMPRESS_WKSP_SIZE_U32(maxTableLog, maxSymbolValue) (FSE_DTABLE_SIZE_U32(maxTableLog) + 1 + FSE_BUILD_DTABLE_WKSP_SIZE_U32(maxTableLog, maxSymbolValue) + (FSE_MAX_SYMBOL_VALUE + 1) / 2 + 1)
355
281
  #define FSE_DECOMPRESS_WKSP_SIZE(maxTableLog, maxSymbolValue) (FSE_DECOMPRESS_WKSP_SIZE_U32(maxTableLog, maxSymbolValue) * sizeof(unsigned))
356
- size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize);
357
- /**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DECOMPRESS_WKSP_SIZE_U32(maxLog, maxSymbolValue)` */
358
-
359
282
  size_t FSE_decompress_wksp_bmi2(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize, int bmi2);
360
- /**< Same as FSE_decompress_wksp() but with dynamic BMI2 support. Pass 1 if your CPU supports BMI2 or 0 if it doesn't. */
283
+ /**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DECOMPRESS_WKSP_SIZE_U32(maxLog, maxSymbolValue)`.
284
+ * Set bmi2 to 1 if your CPU supports BMI2 or 0 if it doesn't */
361
285
 
362
286
  typedef enum {
363
287
  FSE_repeat_none, /**< Cannot use the previous table */
@@ -553,7 +477,7 @@ MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePt
553
477
 
554
478
  /* FSE_getMaxNbBits() :
555
479
  * Approximate maximum cost of a symbol, in bits.
556
- * Fractional get rounded up (i.e : a symbol with a normalized frequency of 3 gives the same result as a frequency of 2)
480
+ * Fractional get rounded up (i.e. a symbol with a normalized frequency of 3 gives the same result as a frequency of 2)
557
481
  * note 1 : assume symbolValue is valid (<= maxSymbolValue)
558
482
  * note 2 : if freq[symbolValue]==0, @return a fake cost of tableLog+1 bits */
559
483
  MEM_STATIC U32 FSE_getMaxNbBits(const void* symbolTTPtr, U32 symbolValue)
@@ -1,6 +1,6 @@
1
1
  /* ******************************************************************
2
2
  * FSE : Finite State Entropy decoder
3
- * Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
  *
5
5
  * You can contact the author at :
6
6
  * - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
@@ -24,6 +24,7 @@
24
24
  #include "error_private.h"
25
25
  #define ZSTD_DEPS_NEED_MALLOC
26
26
  #include "zstd_deps.h"
27
+ #include "bits.h" /* ZSTD_highbit32 */
27
28
 
28
29
 
29
30
  /* **************************************************************
@@ -55,19 +56,6 @@
55
56
  #define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y)
56
57
  #define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y)
57
58
 
58
-
59
- /* Function templates */
60
- FSE_DTable* FSE_createDTable (unsigned tableLog)
61
- {
62
- if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX;
63
- return (FSE_DTable*)ZSTD_malloc( FSE_DTABLE_SIZE_U32(tableLog) * sizeof (U32) );
64
- }
65
-
66
- void FSE_freeDTable (FSE_DTable* dt)
67
- {
68
- ZSTD_free(dt);
69
- }
70
-
71
59
  static size_t FSE_buildDTable_internal(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize)
72
60
  {
73
61
  void* const tdPtr = dt+1; /* because *dt is unsigned, 32-bits aligned on 32-bits */
@@ -127,10 +115,10 @@ static size_t FSE_buildDTable_internal(FSE_DTable* dt, const short* normalizedCo
127
115
  }
128
116
  }
129
117
  /* Now we spread those positions across the table.
130
- * The benefit of doing it in two stages is that we avoid the the
118
+ * The benefit of doing it in two stages is that we avoid the
131
119
  * variable size inner loop, which caused lots of branch misses.
132
120
  * Now we can run through all the positions without any branch misses.
133
- * We unroll the loop twice, since that is what emperically worked best.
121
+ * We unroll the loop twice, since that is what empirically worked best.
134
122
  */
135
123
  {
136
124
  size_t position = 0;
@@ -166,7 +154,7 @@ static size_t FSE_buildDTable_internal(FSE_DTable* dt, const short* normalizedCo
166
154
  for (u=0; u<tableSize; u++) {
167
155
  FSE_FUNCTION_TYPE const symbol = (FSE_FUNCTION_TYPE)(tableDecode[u].symbol);
168
156
  U32 const nextState = symbolNext[symbol]++;
169
- tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32(nextState) );
157
+ tableDecode[u].nbBits = (BYTE) (tableLog - ZSTD_highbit32(nextState) );
170
158
  tableDecode[u].newState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize);
171
159
  } }
172
160
 
@@ -184,49 +172,6 @@ size_t FSE_buildDTable_wksp(FSE_DTable* dt, const short* normalizedCounter, unsi
184
172
  /*-*******************************************************
185
173
  * Decompression (Byte symbols)
186
174
  *********************************************************/
187
- size_t FSE_buildDTable_rle (FSE_DTable* dt, BYTE symbolValue)
188
- {
189
- void* ptr = dt;
190
- FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr;
191
- void* dPtr = dt + 1;
192
- FSE_decode_t* const cell = (FSE_decode_t*)dPtr;
193
-
194
- DTableH->tableLog = 0;
195
- DTableH->fastMode = 0;
196
-
197
- cell->newState = 0;
198
- cell->symbol = symbolValue;
199
- cell->nbBits = 0;
200
-
201
- return 0;
202
- }
203
-
204
-
205
- size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits)
206
- {
207
- void* ptr = dt;
208
- FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr;
209
- void* dPtr = dt + 1;
210
- FSE_decode_t* const dinfo = (FSE_decode_t*)dPtr;
211
- const unsigned tableSize = 1 << nbBits;
212
- const unsigned tableMask = tableSize - 1;
213
- const unsigned maxSV1 = tableMask+1;
214
- unsigned s;
215
-
216
- /* Sanity checks */
217
- if (nbBits < 1) return ERROR(GENERIC); /* min size */
218
-
219
- /* Build Decoding Table */
220
- DTableH->tableLog = (U16)nbBits;
221
- DTableH->fastMode = 1;
222
- for (s=0; s<maxSV1; s++) {
223
- dinfo[s].newState = 0;
224
- dinfo[s].symbol = (BYTE)s;
225
- dinfo[s].nbBits = (BYTE)nbBits;
226
- }
227
-
228
- return 0;
229
- }
230
175
 
231
176
  FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic(
232
177
  void* dst, size_t maxDstSize,
@@ -290,25 +235,11 @@ FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic(
290
235
  return op-ostart;
291
236
  }
292
237
 
238
+ typedef struct {
239
+ short ncount[FSE_MAX_SYMBOL_VALUE + 1];
240
+ FSE_DTable dtable[1]; /* Dynamically sized */
241
+ } FSE_DecompressWksp;
293
242
 
294
- size_t FSE_decompress_usingDTable(void* dst, size_t originalSize,
295
- const void* cSrc, size_t cSrcSize,
296
- const FSE_DTable* dt)
297
- {
298
- const void* ptr = dt;
299
- const FSE_DTableHeader* DTableH = (const FSE_DTableHeader*)ptr;
300
- const U32 fastMode = DTableH->fastMode;
301
-
302
- /* select fast mode (static) */
303
- if (fastMode) return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1);
304
- return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0);
305
- }
306
-
307
-
308
- size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize)
309
- {
310
- return FSE_decompress_wksp_bmi2(dst, dstCapacity, cSrc, cSrcSize, maxLog, workSpace, wkspSize, /* bmi2 */ 0);
311
- }
312
243
 
313
244
  FORCE_INLINE_TEMPLATE size_t FSE_decompress_wksp_body(
314
245
  void* dst, size_t dstCapacity,
@@ -318,33 +249,38 @@ FORCE_INLINE_TEMPLATE size_t FSE_decompress_wksp_body(
318
249
  {
319
250
  const BYTE* const istart = (const BYTE*)cSrc;
320
251
  const BYTE* ip = istart;
321
- short counting[FSE_MAX_SYMBOL_VALUE+1];
322
252
  unsigned tableLog;
323
253
  unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
324
- FSE_DTable* const dtable = (FSE_DTable*)workSpace;
254
+ FSE_DecompressWksp* const wksp = (FSE_DecompressWksp*)workSpace;
255
+
256
+ DEBUG_STATIC_ASSERT((FSE_MAX_SYMBOL_VALUE + 1) % 2 == 0);
257
+ if (wkspSize < sizeof(*wksp)) return ERROR(GENERIC);
325
258
 
326
259
  /* normal FSE decoding mode */
327
- size_t const NCountLength = FSE_readNCount_bmi2(counting, &maxSymbolValue, &tableLog, istart, cSrcSize, bmi2);
328
- if (FSE_isError(NCountLength)) return NCountLength;
329
- if (tableLog > maxLog) return ERROR(tableLog_tooLarge);
330
- assert(NCountLength <= cSrcSize);
331
- ip += NCountLength;
332
- cSrcSize -= NCountLength;
260
+ {
261
+ size_t const NCountLength = FSE_readNCount_bmi2(wksp->ncount, &maxSymbolValue, &tableLog, istart, cSrcSize, bmi2);
262
+ if (FSE_isError(NCountLength)) return NCountLength;
263
+ if (tableLog > maxLog) return ERROR(tableLog_tooLarge);
264
+ assert(NCountLength <= cSrcSize);
265
+ ip += NCountLength;
266
+ cSrcSize -= NCountLength;
267
+ }
333
268
 
334
269
  if (FSE_DECOMPRESS_WKSP_SIZE(tableLog, maxSymbolValue) > wkspSize) return ERROR(tableLog_tooLarge);
335
- workSpace = dtable + FSE_DTABLE_SIZE_U32(tableLog);
336
- wkspSize -= FSE_DTABLE_SIZE(tableLog);
270
+ assert(sizeof(*wksp) + FSE_DTABLE_SIZE(tableLog) <= wkspSize);
271
+ workSpace = (BYTE*)workSpace + sizeof(*wksp) + FSE_DTABLE_SIZE(tableLog);
272
+ wkspSize -= sizeof(*wksp) + FSE_DTABLE_SIZE(tableLog);
337
273
 
338
- CHECK_F( FSE_buildDTable_internal(dtable, counting, maxSymbolValue, tableLog, workSpace, wkspSize) );
274
+ CHECK_F( FSE_buildDTable_internal(wksp->dtable, wksp->ncount, maxSymbolValue, tableLog, workSpace, wkspSize) );
339
275
 
340
276
  {
341
- const void* ptr = dtable;
277
+ const void* ptr = wksp->dtable;
342
278
  const FSE_DTableHeader* DTableH = (const FSE_DTableHeader*)ptr;
343
279
  const U32 fastMode = DTableH->fastMode;
344
280
 
345
281
  /* select fast mode (static) */
346
- if (fastMode) return FSE_decompress_usingDTable_generic(dst, dstCapacity, ip, cSrcSize, dtable, 1);
347
- return FSE_decompress_usingDTable_generic(dst, dstCapacity, ip, cSrcSize, dtable, 0);
282
+ if (fastMode) return FSE_decompress_usingDTable_generic(dst, dstCapacity, ip, cSrcSize, wksp->dtable, 1);
283
+ return FSE_decompress_usingDTable_generic(dst, dstCapacity, ip, cSrcSize, wksp->dtable, 0);
348
284
  }
349
285
  }
350
286
 
@@ -355,7 +291,7 @@ static size_t FSE_decompress_wksp_body_default(void* dst, size_t dstCapacity, co
355
291
  }
356
292
 
357
293
  #if DYNAMIC_BMI2
358
- TARGET_ATTRIBUTE("bmi2") static size_t FSE_decompress_wksp_body_bmi2(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize)
294
+ BMI2_TARGET_ATTRIBUTE static size_t FSE_decompress_wksp_body_bmi2(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize)
359
295
  {
360
296
  return FSE_decompress_wksp_body(dst, dstCapacity, cSrc, cSrcSize, maxLog, workSpace, wkspSize, 1);
361
297
  }
@@ -372,22 +308,4 @@ size_t FSE_decompress_wksp_bmi2(void* dst, size_t dstCapacity, const void* cSrc,
372
308
  return FSE_decompress_wksp_body_default(dst, dstCapacity, cSrc, cSrcSize, maxLog, workSpace, wkspSize);
373
309
  }
374
310
 
375
-
376
- typedef FSE_DTable DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)];
377
-
378
- #ifndef ZSTD_NO_UNUSED_FUNCTIONS
379
- size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog) {
380
- U32 wksp[FSE_BUILD_DTABLE_WKSP_SIZE_U32(FSE_TABLELOG_ABSOLUTE_MAX, FSE_MAX_SYMBOL_VALUE)];
381
- return FSE_buildDTable_wksp(dt, normalizedCounter, maxSymbolValue, tableLog, wksp, sizeof(wksp));
382
- }
383
-
384
- size_t FSE_decompress(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize)
385
- {
386
- /* Static analyzer seems unable to understand this table will be properly initialized later */
387
- U32 wksp[FSE_DECOMPRESS_WKSP_SIZE_U32(FSE_MAX_TABLELOG, FSE_MAX_SYMBOL_VALUE)];
388
- return FSE_decompress_wksp(dst, dstCapacity, cSrc, cSrcSize, FSE_MAX_TABLELOG, wksp, sizeof(wksp));
389
- }
390
- #endif
391
-
392
-
393
311
  #endif /* FSE_COMMONDEFS_ONLY */