zstd-ruby 1.5.2.3 → 1.5.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/ext/zstdruby/libzstd/common/bits.h +175 -0
  4. data/ext/zstdruby/libzstd/common/bitstream.h +18 -59
  5. data/ext/zstdruby/libzstd/common/compiler.h +22 -3
  6. data/ext/zstdruby/libzstd/common/cpu.h +1 -1
  7. data/ext/zstdruby/libzstd/common/debug.c +1 -1
  8. data/ext/zstdruby/libzstd/common/debug.h +1 -1
  9. data/ext/zstdruby/libzstd/common/entropy_common.c +12 -40
  10. data/ext/zstdruby/libzstd/common/error_private.c +9 -2
  11. data/ext/zstdruby/libzstd/common/error_private.h +1 -1
  12. data/ext/zstdruby/libzstd/common/fse.h +5 -83
  13. data/ext/zstdruby/libzstd/common/fse_decompress.c +7 -99
  14. data/ext/zstdruby/libzstd/common/huf.h +65 -156
  15. data/ext/zstdruby/libzstd/common/mem.h +39 -46
  16. data/ext/zstdruby/libzstd/common/pool.c +26 -10
  17. data/ext/zstdruby/libzstd/common/pool.h +7 -1
  18. data/ext/zstdruby/libzstd/common/portability_macros.h +22 -3
  19. data/ext/zstdruby/libzstd/common/threading.c +68 -14
  20. data/ext/zstdruby/libzstd/common/threading.h +5 -10
  21. data/ext/zstdruby/libzstd/common/xxhash.c +2 -2
  22. data/ext/zstdruby/libzstd/common/xxhash.h +8 -8
  23. data/ext/zstdruby/libzstd/common/zstd_common.c +1 -1
  24. data/ext/zstdruby/libzstd/common/zstd_deps.h +1 -1
  25. data/ext/zstdruby/libzstd/common/zstd_internal.h +17 -113
  26. data/ext/zstdruby/libzstd/common/zstd_trace.h +3 -3
  27. data/ext/zstdruby/libzstd/compress/clevels.h +1 -1
  28. data/ext/zstdruby/libzstd/compress/fse_compress.c +7 -124
  29. data/ext/zstdruby/libzstd/compress/hist.c +1 -1
  30. data/ext/zstdruby/libzstd/compress/hist.h +1 -1
  31. data/ext/zstdruby/libzstd/compress/huf_compress.c +234 -169
  32. data/ext/zstdruby/libzstd/compress/zstd_compress.c +1055 -455
  33. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +165 -145
  34. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +115 -39
  35. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -8
  36. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +3 -3
  37. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
  38. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -21
  39. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
  40. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +5 -3
  41. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +95 -33
  42. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
  43. data/ext/zstdruby/libzstd/compress/zstd_fast.c +433 -148
  44. data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
  45. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +306 -283
  46. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +4 -2
  47. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +5 -5
  48. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +1 -1
  49. data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +1 -1
  50. data/ext/zstdruby/libzstd/compress/zstd_opt.c +104 -80
  51. data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
  52. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +12 -5
  53. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +1 -1
  54. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +434 -441
  55. data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +30 -39
  56. data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +3 -4
  57. data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +1 -1
  58. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +164 -42
  59. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +186 -65
  60. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +1 -1
  61. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +4 -2
  62. data/ext/zstdruby/libzstd/dictBuilder/cover.c +19 -15
  63. data/ext/zstdruby/libzstd/dictBuilder/cover.h +1 -1
  64. data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +2 -2
  65. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +9 -87
  66. data/ext/zstdruby/libzstd/zdict.h +53 -31
  67. data/ext/zstdruby/libzstd/zstd.h +489 -90
  68. data/ext/zstdruby/libzstd/zstd_errors.h +27 -8
  69. data/ext/zstdruby/main.c +4 -0
  70. data/lib/zstd-ruby/version.rb +1 -1
  71. metadata +7 -6
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 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
@@ -44,7 +44,6 @@
44
44
  #ifndef ZDICT_STATIC_LINKING_ONLY
45
45
  # define ZDICT_STATIC_LINKING_ONLY
46
46
  #endif
47
- #define HUF_STATIC_LINKING_ONLY
48
47
 
49
48
  #include "../common/mem.h" /* read */
50
49
  #include "../common/fse.h" /* FSE_normalizeCount, FSE_writeNCount */
@@ -54,6 +53,7 @@
54
53
  #include "../compress/zstd_compress_internal.h" /* ZSTD_loadCEntropy() */
55
54
  #include "../zdict.h"
56
55
  #include "divsufsort.h"
56
+ #include "../common/bits.h" /* ZSTD_NbCommonBytes */
57
57
 
58
58
 
59
59
  /*-*************************************
@@ -130,85 +130,6 @@ size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize)
130
130
  /*-********************************************************
131
131
  * Dictionary training functions
132
132
  **********************************************************/
133
- static unsigned ZDICT_NbCommonBytes (size_t val)
134
- {
135
- if (MEM_isLittleEndian()) {
136
- if (MEM_64bits()) {
137
- # if defined(_MSC_VER) && defined(_WIN64)
138
- if (val != 0) {
139
- unsigned long r;
140
- _BitScanForward64(&r, (U64)val);
141
- return (unsigned)(r >> 3);
142
- } else {
143
- /* Should not reach this code path */
144
- __assume(0);
145
- }
146
- # elif defined(__GNUC__) && (__GNUC__ >= 3)
147
- return (unsigned)(__builtin_ctzll((U64)val) >> 3);
148
- # else
149
- static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
150
- return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
151
- # endif
152
- } else { /* 32 bits */
153
- # if defined(_MSC_VER)
154
- if (val != 0) {
155
- unsigned long r;
156
- _BitScanForward(&r, (U32)val);
157
- return (unsigned)(r >> 3);
158
- } else {
159
- /* Should not reach this code path */
160
- __assume(0);
161
- }
162
- # elif defined(__GNUC__) && (__GNUC__ >= 3)
163
- return (unsigned)(__builtin_ctz((U32)val) >> 3);
164
- # else
165
- static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
166
- return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
167
- # endif
168
- }
169
- } else { /* Big Endian CPU */
170
- if (MEM_64bits()) {
171
- # if defined(_MSC_VER) && defined(_WIN64)
172
- if (val != 0) {
173
- unsigned long r;
174
- _BitScanReverse64(&r, val);
175
- return (unsigned)(r >> 3);
176
- } else {
177
- /* Should not reach this code path */
178
- __assume(0);
179
- }
180
- # elif defined(__GNUC__) && (__GNUC__ >= 3)
181
- return (unsigned)(__builtin_clzll(val) >> 3);
182
- # else
183
- unsigned r;
184
- const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
185
- if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
186
- if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
187
- r += (!val);
188
- return r;
189
- # endif
190
- } else { /* 32 bits */
191
- # if defined(_MSC_VER)
192
- if (val != 0) {
193
- unsigned long r;
194
- _BitScanReverse(&r, (unsigned long)val);
195
- return (unsigned)(r >> 3);
196
- } else {
197
- /* Should not reach this code path */
198
- __assume(0);
199
- }
200
- # elif defined(__GNUC__) && (__GNUC__ >= 3)
201
- return (unsigned)(__builtin_clz((U32)val) >> 3);
202
- # else
203
- unsigned r;
204
- if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
205
- r += (!val);
206
- return r;
207
- # endif
208
- } }
209
- }
210
-
211
-
212
133
  /*! ZDICT_count() :
213
134
  Count the nb of common bytes between 2 pointers.
214
135
  Note : this function presumes end of buffer followed by noisy guard band.
@@ -223,7 +144,7 @@ static size_t ZDICT_count(const void* pIn, const void* pMatch)
223
144
  pMatch = (const char*)pMatch+sizeof(size_t);
224
145
  continue;
225
146
  }
226
- pIn = (const char*)pIn+ZDICT_NbCommonBytes(diff);
147
+ pIn = (const char*)pIn+ZSTD_NbCommonBytes(diff);
227
148
  return (size_t)((const char*)pIn - pStart);
228
149
  }
229
150
  }
@@ -451,7 +372,7 @@ static U32 ZDICT_tryMerge(dictItem* table, dictItem elt, U32 eltNbToSkip, const
451
372
  elt = table[u];
452
373
  /* sort : improve rank */
453
374
  while ((u>1) && (table[u-1].savings < elt.savings))
454
- table[u] = table[u-1], u--;
375
+ table[u] = table[u-1], u--;
455
376
  table[u] = elt;
456
377
  return u;
457
378
  } }
@@ -602,7 +523,7 @@ static size_t ZDICT_trainBuffer_legacy(dictItem* dictList, U32 dictListSize,
602
523
  if (solution.length==0) { cursor++; continue; }
603
524
  ZDICT_insertDictItem(dictList, dictListSize, solution, buffer);
604
525
  cursor += solution.length;
605
- DISPLAYUPDATE(2, "\r%4.2f %% \r", (double)cursor / bufferSize * 100);
526
+ DISPLAYUPDATE(2, "\r%4.2f %% \r", (double)cursor / (double)bufferSize * 100.0);
606
527
  } }
607
528
 
608
529
  _cleanup:
@@ -754,6 +675,7 @@ static size_t ZDICT_analyzeEntropy(void* dstBuffer, size_t maxDstSize,
754
675
  size_t const totalSrcSize = ZDICT_totalSampleSize(fileSizes, nbFiles);
755
676
  size_t const averageSampleSize = totalSrcSize / (nbFiles + !nbFiles);
756
677
  BYTE* dstPtr = (BYTE*)dstBuffer;
678
+ U32 wksp[HUF_CTABLE_WORKSPACE_SIZE_U32];
757
679
 
758
680
  /* init */
759
681
  DEBUGLOG(4, "ZDICT_analyzeEntropy");
@@ -794,7 +716,7 @@ static size_t ZDICT_analyzeEntropy(void* dstBuffer, size_t maxDstSize,
794
716
  } }
795
717
 
796
718
  /* analyze, build stats, starting with literals */
797
- { size_t maxNbBits = HUF_buildCTable (hufTable, countLit, 255, huffLog);
719
+ { size_t maxNbBits = HUF_buildCTable_wksp(hufTable, countLit, 255, huffLog, wksp, sizeof(wksp));
798
720
  if (HUF_isError(maxNbBits)) {
799
721
  eSize = maxNbBits;
800
722
  DISPLAYLEVEL(1, " HUF_buildCTable error \n");
@@ -803,7 +725,7 @@ static size_t ZDICT_analyzeEntropy(void* dstBuffer, size_t maxDstSize,
803
725
  if (maxNbBits==8) { /* not compressible : will fail on HUF_writeCTable() */
804
726
  DISPLAYLEVEL(2, "warning : pathological dataset : literals are not compressible : samples are noisy or too regular \n");
805
727
  ZDICT_flatLit(countLit); /* replace distribution by a fake "mostly flat but still compressible" distribution, that HUF_writeCTable() can encode */
806
- maxNbBits = HUF_buildCTable (hufTable, countLit, 255, huffLog);
728
+ maxNbBits = HUF_buildCTable_wksp(hufTable, countLit, 255, huffLog, wksp, sizeof(wksp));
807
729
  assert(maxNbBits==9);
808
730
  }
809
731
  huffLog = (U32)maxNbBits;
@@ -844,7 +766,7 @@ static size_t ZDICT_analyzeEntropy(void* dstBuffer, size_t maxDstSize,
844
766
  llLog = (U32)errorCode;
845
767
 
846
768
  /* write result to buffer */
847
- { size_t const hhSize = HUF_writeCTable(dstPtr, maxDstSize, hufTable, 255, huffLog);
769
+ { size_t const hhSize = HUF_writeCTable_wksp(dstPtr, maxDstSize, hufTable, 255, huffLog, wksp, sizeof(wksp));
848
770
  if (HUF_isError(hhSize)) {
849
771
  eSize = hhSize;
850
772
  DISPLAYLEVEL(1, "HUF_writeCTable error \n");
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 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
@@ -8,32 +8,43 @@
8
8
  * You may select, at your option, one of the above-listed licenses.
9
9
  */
10
10
 
11
- #ifndef DICTBUILDER_H_001
12
- #define DICTBUILDER_H_001
13
-
14
11
  #if defined (__cplusplus)
15
12
  extern "C" {
16
13
  #endif
17
14
 
15
+ #ifndef ZSTD_ZDICT_H
16
+ #define ZSTD_ZDICT_H
18
17
 
19
18
  /*====== Dependencies ======*/
20
19
  #include <stddef.h> /* size_t */
21
20
 
22
21
 
23
22
  /* ===== ZDICTLIB_API : control library symbols visibility ===== */
24
- #ifndef ZDICTLIB_VISIBILITY
25
- # if defined(__GNUC__) && (__GNUC__ >= 4)
26
- # define ZDICTLIB_VISIBILITY __attribute__ ((visibility ("default")))
23
+ #ifndef ZDICTLIB_VISIBLE
24
+ /* Backwards compatibility with old macro name */
25
+ # ifdef ZDICTLIB_VISIBILITY
26
+ # define ZDICTLIB_VISIBLE ZDICTLIB_VISIBILITY
27
+ # elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
28
+ # define ZDICTLIB_VISIBLE __attribute__ ((visibility ("default")))
29
+ # else
30
+ # define ZDICTLIB_VISIBLE
31
+ # endif
32
+ #endif
33
+
34
+ #ifndef ZDICTLIB_HIDDEN
35
+ # if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
36
+ # define ZDICTLIB_HIDDEN __attribute__ ((visibility ("hidden")))
27
37
  # else
28
- # define ZDICTLIB_VISIBILITY
38
+ # define ZDICTLIB_HIDDEN
29
39
  # endif
30
40
  #endif
41
+
31
42
  #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
32
- # define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBILITY
43
+ # define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBLE
33
44
  #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
34
- # define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
45
+ # define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
35
46
  #else
36
- # define ZDICTLIB_API ZDICTLIB_VISIBILITY
47
+ # define ZDICTLIB_API ZDICTLIB_VISIBLE
37
48
  #endif
38
49
 
39
50
  /*******************************************************************************
@@ -110,8 +121,8 @@ extern "C" {
110
121
  * The zstd CLI defaults to a 110KB dictionary. You likely don't need a
111
122
  * dictionary larger than that. But, most use cases can get away with a
112
123
  * smaller dictionary. The advanced dictionary builders can automatically
113
- * shrink the dictionary for you, and select a the smallest size that
114
- * doesn't hurt compression ratio too much. See the `shrinkDict` parameter.
124
+ * shrink the dictionary for you, and select the smallest size that doesn't
125
+ * hurt compression ratio too much. See the `shrinkDict` parameter.
115
126
  * A smaller dictionary can save memory, and potentially speed up
116
127
  * compression.
117
128
  *
@@ -201,9 +212,9 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCap
201
212
  const size_t* samplesSizes, unsigned nbSamples);
202
213
 
203
214
  typedef struct {
204
- int compressionLevel; /*< optimize for a specific zstd compression level; 0 means default */
205
- unsigned notificationLevel; /*< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
206
- unsigned dictID; /*< force dictID value; 0 means auto mode (32-bits random value)
215
+ int compressionLevel; /**< optimize for a specific zstd compression level; 0 means default */
216
+ unsigned notificationLevel; /**< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
217
+ unsigned dictID; /**< force dictID value; 0 means auto mode (32-bits random value)
207
218
  * NOTE: The zstd format reserves some dictionary IDs for future use.
208
219
  * You may use them in private settings, but be warned that they
209
220
  * may be used by zstd in a public dictionary registry in the future.
@@ -260,9 +271,21 @@ ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictS
260
271
  ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
261
272
  ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
262
273
 
274
+ #endif /* ZSTD_ZDICT_H */
263
275
 
276
+ #if defined(ZDICT_STATIC_LINKING_ONLY) && !defined(ZSTD_ZDICT_H_STATIC)
277
+ #define ZSTD_ZDICT_H_STATIC
264
278
 
265
- #ifdef ZDICT_STATIC_LINKING_ONLY
279
+ /* This can be overridden externally to hide static symbols. */
280
+ #ifndef ZDICTLIB_STATIC_API
281
+ # if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
282
+ # define ZDICTLIB_STATIC_API __declspec(dllexport) ZDICTLIB_VISIBLE
283
+ # elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
284
+ # define ZDICTLIB_STATIC_API __declspec(dllimport) ZDICTLIB_VISIBLE
285
+ # else
286
+ # define ZDICTLIB_STATIC_API ZDICTLIB_VISIBLE
287
+ # endif
288
+ #endif
266
289
 
267
290
  /* ====================================================================================
268
291
  * The definitions in this section are considered experimental.
@@ -318,7 +341,7 @@ typedef struct {
318
341
  * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
319
342
  * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
320
343
  */
321
- ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
344
+ ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_cover(
322
345
  void *dictBuffer, size_t dictBufferCapacity,
323
346
  const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
324
347
  ZDICT_cover_params_t parameters);
@@ -340,7 +363,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
340
363
  * See ZDICT_trainFromBuffer() for details on failure modes.
341
364
  * Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread.
342
365
  */
343
- ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
366
+ ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_cover(
344
367
  void* dictBuffer, size_t dictBufferCapacity,
345
368
  const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
346
369
  ZDICT_cover_params_t* parameters);
@@ -361,7 +384,7 @@ ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
361
384
  * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
362
385
  * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
363
386
  */
364
- ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
387
+ ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
365
388
  size_t dictBufferCapacity, const void *samplesBuffer,
366
389
  const size_t *samplesSizes, unsigned nbSamples,
367
390
  ZDICT_fastCover_params_t parameters);
@@ -384,7 +407,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
384
407
  * See ZDICT_trainFromBuffer() for details on failure modes.
385
408
  * Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread.
386
409
  */
387
- ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
410
+ ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
388
411
  size_t dictBufferCapacity, const void* samplesBuffer,
389
412
  const size_t* samplesSizes, unsigned nbSamples,
390
413
  ZDICT_fastCover_params_t* parameters);
@@ -409,7 +432,7 @@ typedef struct {
409
432
  * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
410
433
  * Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0.
411
434
  */
412
- ZDICTLIB_API size_t ZDICT_trainFromBuffer_legacy(
435
+ ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_legacy(
413
436
  void* dictBuffer, size_t dictBufferCapacity,
414
437
  const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
415
438
  ZDICT_legacy_params_t parameters);
@@ -421,32 +444,31 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_legacy(
421
444
  or _CRT_SECURE_NO_WARNINGS in Visual.
422
445
  Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */
423
446
  #ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS
424
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API /* disable deprecation warnings */
447
+ # define ZDICT_DEPRECATED(message) /* disable deprecation warnings */
425
448
  #else
426
449
  # define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
427
450
  # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
428
- # define ZDICT_DEPRECATED(message) [[deprecated(message)]] ZDICTLIB_API
451
+ # define ZDICT_DEPRECATED(message) [[deprecated(message)]]
429
452
  # elif defined(__clang__) || (ZDICT_GCC_VERSION >= 405)
430
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated(message)))
453
+ # define ZDICT_DEPRECATED(message) __attribute__((deprecated(message)))
431
454
  # elif (ZDICT_GCC_VERSION >= 301)
432
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated))
455
+ # define ZDICT_DEPRECATED(message) __attribute__((deprecated))
433
456
  # elif defined(_MSC_VER)
434
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API __declspec(deprecated(message))
457
+ # define ZDICT_DEPRECATED(message) __declspec(deprecated(message))
435
458
  # else
436
459
  # pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler")
437
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API
460
+ # define ZDICT_DEPRECATED(message)
438
461
  # endif
439
462
  #endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */
440
463
 
441
464
  ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead")
465
+ ZDICTLIB_STATIC_API
442
466
  size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
443
467
  const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
444
468
 
445
469
 
446
- #endif /* ZDICT_STATIC_LINKING_ONLY */
470
+ #endif /* ZSTD_ZDICT_H_STATIC */
447
471
 
448
472
  #if defined (__cplusplus)
449
473
  }
450
474
  #endif
451
-
452
- #endif /* DICTBUILDER_H_001 */