zstd-ruby 1.4.5.0 → 1.5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +78 -5
  4. data/Rakefile +8 -2
  5. data/ext/zstdruby/common.h +15 -0
  6. data/ext/zstdruby/extconf.rb +3 -2
  7. data/ext/zstdruby/libzstd/common/allocations.h +55 -0
  8. data/ext/zstdruby/libzstd/common/bits.h +200 -0
  9. data/ext/zstdruby/libzstd/common/bitstream.h +45 -62
  10. data/ext/zstdruby/libzstd/common/compiler.h +205 -22
  11. data/ext/zstdruby/libzstd/common/cpu.h +1 -3
  12. data/ext/zstdruby/libzstd/common/debug.c +1 -1
  13. data/ext/zstdruby/libzstd/common/debug.h +12 -19
  14. data/ext/zstdruby/libzstd/common/entropy_common.c +172 -48
  15. data/ext/zstdruby/libzstd/common/error_private.c +10 -2
  16. data/ext/zstdruby/libzstd/common/error_private.h +82 -3
  17. data/ext/zstdruby/libzstd/common/fse.h +37 -86
  18. data/ext/zstdruby/libzstd/common/fse_decompress.c +117 -92
  19. data/ext/zstdruby/libzstd/common/huf.h +99 -166
  20. data/ext/zstdruby/libzstd/common/mem.h +124 -142
  21. data/ext/zstdruby/libzstd/common/pool.c +54 -27
  22. data/ext/zstdruby/libzstd/common/pool.h +10 -4
  23. data/ext/zstdruby/libzstd/common/portability_macros.h +156 -0
  24. data/ext/zstdruby/libzstd/common/threading.c +74 -19
  25. data/ext/zstdruby/libzstd/common/threading.h +5 -10
  26. data/ext/zstdruby/libzstd/common/xxhash.c +7 -847
  27. data/ext/zstdruby/libzstd/common/xxhash.h +5568 -167
  28. data/ext/zstdruby/libzstd/common/zstd_common.c +2 -37
  29. data/ext/zstdruby/libzstd/common/zstd_deps.h +111 -0
  30. data/ext/zstdruby/libzstd/common/zstd_internal.h +132 -187
  31. data/ext/zstdruby/libzstd/common/zstd_trace.h +163 -0
  32. data/ext/zstdruby/libzstd/compress/clevels.h +134 -0
  33. data/ext/zstdruby/libzstd/compress/fse_compress.c +83 -157
  34. data/ext/zstdruby/libzstd/compress/hist.c +27 -29
  35. data/ext/zstdruby/libzstd/compress/hist.h +2 -2
  36. data/ext/zstdruby/libzstd/compress/huf_compress.c +916 -279
  37. data/ext/zstdruby/libzstd/compress/zstd_compress.c +3773 -1019
  38. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +610 -203
  39. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +119 -42
  40. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -6
  41. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +42 -19
  42. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
  43. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +49 -317
  44. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
  45. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +320 -103
  46. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +388 -151
  47. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
  48. data/ext/zstdruby/libzstd/compress/zstd_fast.c +729 -265
  49. data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
  50. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +1270 -251
  51. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +61 -1
  52. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +324 -219
  53. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +9 -2
  54. data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +106 -0
  55. data/ext/zstdruby/libzstd/compress/zstd_opt.c +481 -209
  56. data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
  57. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +181 -457
  58. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +34 -113
  59. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +1199 -565
  60. data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +576 -0
  61. data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +12 -12
  62. data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
  63. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +627 -157
  64. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +1086 -326
  65. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +19 -5
  66. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +62 -13
  67. data/ext/zstdruby/libzstd/dictBuilder/cover.c +73 -52
  68. data/ext/zstdruby/libzstd/dictBuilder/cover.h +7 -6
  69. data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
  70. data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +44 -35
  71. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +103 -111
  72. data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +203 -34
  73. data/ext/zstdruby/libzstd/zstd.h +1217 -287
  74. data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +28 -8
  75. data/ext/zstdruby/main.c +20 -0
  76. data/ext/zstdruby/skippable_frame.c +63 -0
  77. data/ext/zstdruby/streaming_compress.c +177 -0
  78. data/ext/zstdruby/streaming_compress.h +5 -0
  79. data/ext/zstdruby/streaming_decompress.c +123 -0
  80. data/ext/zstdruby/zstdruby.c +114 -32
  81. data/lib/zstd-ruby/version.rb +1 -1
  82. data/lib/zstd-ruby.rb +0 -1
  83. data/zstd-ruby.gemspec +1 -1
  84. metadata +19 -36
  85. data/.travis.yml +0 -14
  86. data/ext/zstdruby/libzstd/.gitignore +0 -3
  87. data/ext/zstdruby/libzstd/BUCK +0 -234
  88. data/ext/zstdruby/libzstd/Makefile +0 -354
  89. data/ext/zstdruby/libzstd/README.md +0 -179
  90. data/ext/zstdruby/libzstd/deprecated/zbuff.h +0 -214
  91. data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +0 -26
  92. data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +0 -147
  93. data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +0 -75
  94. data/ext/zstdruby/libzstd/dll/example/Makefile +0 -48
  95. data/ext/zstdruby/libzstd/dll/example/README.md +0 -69
  96. data/ext/zstdruby/libzstd/dll/example/build_package.bat +0 -20
  97. data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +0 -25
  98. data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +0 -181
  99. data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +0 -415
  100. data/ext/zstdruby/libzstd/legacy/zstd_v01.c +0 -2158
  101. data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
  102. data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3518
  103. data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
  104. data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3160
  105. data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
  106. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3647
  107. data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
  108. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4050
  109. data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
  110. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4154
  111. data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
  112. data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4541
  113. data/ext/zstdruby/libzstd/legacy/zstd_v07.h +0 -187
  114. data/ext/zstdruby/libzstd/libzstd.pc.in +0 -15
  115. data/ext/zstdruby/zstdruby.h +0 -6
@@ -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
@@ -8,34 +8,184 @@
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
 
50
+ /*******************************************************************************
51
+ * Zstd dictionary builder
52
+ *
53
+ * FAQ
54
+ * ===
55
+ * Why should I use a dictionary?
56
+ * ------------------------------
57
+ *
58
+ * Zstd can use dictionaries to improve compression ratio of small data.
59
+ * Traditionally small files don't compress well because there is very little
60
+ * repetition in a single sample, since it is small. But, if you are compressing
61
+ * many similar files, like a bunch of JSON records that share the same
62
+ * structure, you can train a dictionary on ahead of time on some samples of
63
+ * these files. Then, zstd can use the dictionary to find repetitions that are
64
+ * present across samples. This can vastly improve compression ratio.
65
+ *
66
+ * When is a dictionary useful?
67
+ * ----------------------------
68
+ *
69
+ * Dictionaries are useful when compressing many small files that are similar.
70
+ * The larger a file is, the less benefit a dictionary will have. Generally,
71
+ * we don't expect dictionary compression to be effective past 100KB. And the
72
+ * smaller a file is, the more we would expect the dictionary to help.
73
+ *
74
+ * How do I use a dictionary?
75
+ * --------------------------
76
+ *
77
+ * Simply pass the dictionary to the zstd compressor with
78
+ * `ZSTD_CCtx_loadDictionary()`. The same dictionary must then be passed to
79
+ * the decompressor, using `ZSTD_DCtx_loadDictionary()`. There are other
80
+ * more advanced functions that allow selecting some options, see zstd.h for
81
+ * complete documentation.
82
+ *
83
+ * What is a zstd dictionary?
84
+ * --------------------------
85
+ *
86
+ * A zstd dictionary has two pieces: Its header, and its content. The header
87
+ * contains a magic number, the dictionary ID, and entropy tables. These
88
+ * entropy tables allow zstd to save on header costs in the compressed file,
89
+ * which really matters for small data. The content is just bytes, which are
90
+ * repeated content that is common across many samples.
91
+ *
92
+ * What is a raw content dictionary?
93
+ * ---------------------------------
94
+ *
95
+ * A raw content dictionary is just bytes. It doesn't have a zstd dictionary
96
+ * header, a dictionary ID, or entropy tables. Any buffer is a valid raw
97
+ * content dictionary.
98
+ *
99
+ * How do I train a dictionary?
100
+ * ----------------------------
101
+ *
102
+ * Gather samples from your use case. These samples should be similar to each
103
+ * other. If you have several use cases, you could try to train one dictionary
104
+ * per use case.
105
+ *
106
+ * Pass those samples to `ZDICT_trainFromBuffer()` and that will train your
107
+ * dictionary. There are a few advanced versions of this function, but this
108
+ * is a great starting point. If you want to further tune your dictionary
109
+ * you could try `ZDICT_optimizeTrainFromBuffer_cover()`. If that is too slow
110
+ * you can try `ZDICT_optimizeTrainFromBuffer_fastCover()`.
111
+ *
112
+ * If the dictionary training function fails, that is likely because you
113
+ * either passed too few samples, or a dictionary would not be effective
114
+ * for your data. Look at the messages that the dictionary trainer printed,
115
+ * if it doesn't say too few samples, then a dictionary would not be effective.
116
+ *
117
+ * How large should my dictionary be?
118
+ * ----------------------------------
119
+ *
120
+ * A reasonable dictionary size, the `dictBufferCapacity`, is about 100KB.
121
+ * The zstd CLI defaults to a 110KB dictionary. You likely don't need a
122
+ * dictionary larger than that. But, most use cases can get away with a
123
+ * smaller dictionary. The advanced dictionary builders can automatically
124
+ * shrink the dictionary for you, and select the smallest size that doesn't
125
+ * hurt compression ratio too much. See the `shrinkDict` parameter.
126
+ * A smaller dictionary can save memory, and potentially speed up
127
+ * compression.
128
+ *
129
+ * How many samples should I provide to the dictionary builder?
130
+ * ------------------------------------------------------------
131
+ *
132
+ * We generally recommend passing ~100x the size of the dictionary
133
+ * in samples. A few thousand should suffice. Having too few samples
134
+ * can hurt the dictionaries effectiveness. Having more samples will
135
+ * only improve the dictionaries effectiveness. But having too many
136
+ * samples can slow down the dictionary builder.
137
+ *
138
+ * How do I determine if a dictionary will be effective?
139
+ * -----------------------------------------------------
140
+ *
141
+ * Simply train a dictionary and try it out. You can use zstd's built in
142
+ * benchmarking tool to test the dictionary effectiveness.
143
+ *
144
+ * # Benchmark levels 1-3 without a dictionary
145
+ * zstd -b1e3 -r /path/to/my/files
146
+ * # Benchmark levels 1-3 with a dictionary
147
+ * zstd -b1e3 -r /path/to/my/files -D /path/to/my/dictionary
148
+ *
149
+ * When should I retrain a dictionary?
150
+ * -----------------------------------
151
+ *
152
+ * You should retrain a dictionary when its effectiveness drops. Dictionary
153
+ * effectiveness drops as the data you are compressing changes. Generally, we do
154
+ * expect dictionaries to "decay" over time, as your data changes, but the rate
155
+ * at which they decay depends on your use case. Internally, we regularly
156
+ * retrain dictionaries, and if the new dictionary performs significantly
157
+ * better than the old dictionary, we will ship the new dictionary.
158
+ *
159
+ * I have a raw content dictionary, how do I turn it into a zstd dictionary?
160
+ * -------------------------------------------------------------------------
161
+ *
162
+ * If you have a raw content dictionary, e.g. by manually constructing it, or
163
+ * using a third-party dictionary builder, you can turn it into a zstd
164
+ * dictionary by using `ZDICT_finalizeDictionary()`. You'll also have to
165
+ * provide some samples of the data. It will add the zstd header to the
166
+ * raw content, which contains a dictionary ID and entropy tables, which
167
+ * will improve compression ratio, and allow zstd to write the dictionary ID
168
+ * into the frame, if you so choose.
169
+ *
170
+ * Do I have to use zstd's dictionary builder?
171
+ * -------------------------------------------
172
+ *
173
+ * No! You can construct dictionary content however you please, it is just
174
+ * bytes. It will always be valid as a raw content dictionary. If you want
175
+ * a zstd dictionary, which can improve compression ratio, use
176
+ * `ZDICT_finalizeDictionary()`.
177
+ *
178
+ * What is the attack surface of a zstd dictionary?
179
+ * ------------------------------------------------
180
+ *
181
+ * Zstd is heavily fuzz tested, including loading fuzzed dictionaries, so
182
+ * zstd should never crash, or access out-of-bounds memory no matter what
183
+ * the dictionary is. However, if an attacker can control the dictionary
184
+ * during decompression, they can cause zstd to generate arbitrary bytes,
185
+ * just like if they controlled the compressed data.
186
+ *
187
+ ******************************************************************************/
188
+
39
189
 
40
190
  /*! ZDICT_trainFromBuffer():
41
191
  * Train a dictionary from an array of samples.
@@ -62,9 +212,16 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCap
62
212
  const size_t* samplesSizes, unsigned nbSamples);
63
213
 
64
214
  typedef struct {
65
- int compressionLevel; /*< optimize for a specific zstd compression level; 0 means default */
66
- unsigned notificationLevel; /*< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
67
- 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)
218
+ * NOTE: The zstd format reserves some dictionary IDs for future use.
219
+ * You may use them in private settings, but be warned that they
220
+ * may be used by zstd in a public dictionary registry in the future.
221
+ * These dictionary IDs are:
222
+ * - low range : <= 32767
223
+ * - high range : >= (2^31)
224
+ */
68
225
  } ZDICT_params_t;
69
226
 
70
227
  /*! ZDICT_finalizeDictionary():
@@ -91,7 +248,6 @@ typedef struct {
91
248
  * is presumed that the most profitable content is at the end of the dictionary,
92
249
  * since that is the cheapest to reference.
93
250
  *
94
- * `dictContentSize` must be >= ZDICT_CONTENTSIZE_MIN bytes.
95
251
  * `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN).
96
252
  *
97
253
  * @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),
@@ -115,9 +271,21 @@ ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictS
115
271
  ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
116
272
  ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
117
273
 
274
+ #endif /* ZSTD_ZDICT_H */
118
275
 
276
+ #if defined(ZDICT_STATIC_LINKING_ONLY) && !defined(ZSTD_ZDICT_H_STATIC)
277
+ #define ZSTD_ZDICT_H_STATIC
119
278
 
120
- #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
121
289
 
122
290
  /* ====================================================================================
123
291
  * The definitions in this section are considered experimental.
@@ -126,8 +294,9 @@ ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
126
294
  * Use them only in association with static linking.
127
295
  * ==================================================================================== */
128
296
 
129
- #define ZDICT_CONTENTSIZE_MIN 128
130
297
  #define ZDICT_DICTSIZE_MIN 256
298
+ /* Deprecated: Remove in v1.6.0 */
299
+ #define ZDICT_CONTENTSIZE_MIN 128
131
300
 
132
301
  /*! ZDICT_cover_params_t:
133
302
  * k and d are the only required parameters.
@@ -172,7 +341,7 @@ typedef struct {
172
341
  * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
173
342
  * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
174
343
  */
175
- ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
344
+ ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_cover(
176
345
  void *dictBuffer, size_t dictBufferCapacity,
177
346
  const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
178
347
  ZDICT_cover_params_t parameters);
@@ -194,7 +363,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
194
363
  * See ZDICT_trainFromBuffer() for details on failure modes.
195
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.
196
365
  */
197
- ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
366
+ ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_cover(
198
367
  void* dictBuffer, size_t dictBufferCapacity,
199
368
  const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
200
369
  ZDICT_cover_params_t* parameters);
@@ -215,7 +384,7 @@ ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
215
384
  * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
216
385
  * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
217
386
  */
218
- ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
387
+ ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
219
388
  size_t dictBufferCapacity, const void *samplesBuffer,
220
389
  const size_t *samplesSizes, unsigned nbSamples,
221
390
  ZDICT_fastCover_params_t parameters);
@@ -238,7 +407,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
238
407
  * See ZDICT_trainFromBuffer() for details on failure modes.
239
408
  * Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread.
240
409
  */
241
- ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
410
+ ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
242
411
  size_t dictBufferCapacity, const void* samplesBuffer,
243
412
  const size_t* samplesSizes, unsigned nbSamples,
244
413
  ZDICT_fastCover_params_t* parameters);
@@ -263,43 +432,43 @@ typedef struct {
263
432
  * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
264
433
  * Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0.
265
434
  */
266
- ZDICTLIB_API size_t ZDICT_trainFromBuffer_legacy(
267
- void *dictBuffer, size_t dictBufferCapacity,
268
- const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
435
+ ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_legacy(
436
+ void* dictBuffer, size_t dictBufferCapacity,
437
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
269
438
  ZDICT_legacy_params_t parameters);
270
439
 
440
+
271
441
  /* Deprecation warnings */
272
442
  /* It is generally possible to disable deprecation warnings from compiler,
273
443
  for example with -Wno-deprecated-declarations for gcc
274
444
  or _CRT_SECURE_NO_WARNINGS in Visual.
275
445
  Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */
276
446
  #ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS
277
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API /* disable deprecation warnings */
447
+ # define ZDICT_DEPRECATED(message) /* disable deprecation warnings */
278
448
  #else
279
449
  # define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
280
450
  # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
281
- # define ZDICT_DEPRECATED(message) [[deprecated(message)]] ZDICTLIB_API
282
- # elif (ZDICT_GCC_VERSION >= 405) || defined(__clang__)
283
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated(message)))
451
+ # define ZDICT_DEPRECATED(message) [[deprecated(message)]]
452
+ # elif defined(__clang__) || (ZDICT_GCC_VERSION >= 405)
453
+ # define ZDICT_DEPRECATED(message) __attribute__((deprecated(message)))
284
454
  # elif (ZDICT_GCC_VERSION >= 301)
285
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated))
455
+ # define ZDICT_DEPRECATED(message) __attribute__((deprecated))
286
456
  # elif defined(_MSC_VER)
287
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API __declspec(deprecated(message))
457
+ # define ZDICT_DEPRECATED(message) __declspec(deprecated(message))
288
458
  # else
289
459
  # pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler")
290
- # define ZDICT_DEPRECATED(message) ZDICTLIB_API
460
+ # define ZDICT_DEPRECATED(message)
291
461
  # endif
292
462
  #endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */
293
463
 
294
464
  ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead")
465
+ ZDICTLIB_STATIC_API
295
466
  size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
296
467
  const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
297
468
 
298
469
 
299
- #endif /* ZDICT_STATIC_LINKING_ONLY */
470
+ #endif /* ZSTD_ZDICT_H_STATIC */
300
471
 
301
472
  #if defined (__cplusplus)
302
473
  }
303
474
  #endif
304
-
305
- #endif /* DICTBUILDER_H_001 */