zstdlib 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +8 -0
  3. data/ext/zstdlib_c/extconf.rb +2 -2
  4. data/ext/zstdlib_c/ruby/zlib-3.2/zstdlib.c +5090 -0
  5. data/ext/zstdlib_c/zstd-1.5.5/lib/common/allocations.h +55 -0
  6. data/ext/zstdlib_c/zstd-1.5.5/lib/common/bits.h +200 -0
  7. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/bitstream.h +19 -60
  8. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/compiler.h +26 -3
  9. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/cpu.h +1 -1
  10. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/debug.c +1 -1
  11. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/debug.h +1 -1
  12. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/entropy_common.c +12 -40
  13. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/error_private.c +9 -2
  14. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/error_private.h +1 -1
  15. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/fse.h +5 -83
  16. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/fse_decompress.c +7 -99
  17. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/huf.h +65 -156
  18. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/mem.h +39 -46
  19. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/pool.c +26 -10
  20. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/pool.h +7 -1
  21. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/portability_macros.h +22 -3
  22. data/ext/zstdlib_c/zstd-1.5.5/lib/common/threading.c +176 -0
  23. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/threading.h +5 -10
  24. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/xxhash.c +2 -2
  25. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/xxhash.h +8 -8
  26. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/zstd_common.c +1 -36
  27. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/zstd_deps.h +1 -1
  28. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/zstd_internal.h +17 -118
  29. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/common/zstd_trace.h +3 -3
  30. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/clevels.h +1 -1
  31. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/fse_compress.c +7 -124
  32. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/hist.c +1 -1
  33. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/hist.h +1 -1
  34. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/huf_compress.c +234 -169
  35. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_compress.c +1243 -538
  36. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_compress_internal.h +225 -151
  37. data/ext/zstdlib_c/zstd-1.5.5/lib/compress/zstd_compress_literals.c +235 -0
  38. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_compress_literals.h +16 -8
  39. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_compress_sequences.c +3 -3
  40. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_compress_sequences.h +1 -1
  41. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_compress_superblock.c +25 -21
  42. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_compress_superblock.h +1 -1
  43. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_cwksp.h +128 -62
  44. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_double_fast.c +95 -33
  45. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_double_fast.h +3 -2
  46. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_fast.c +433 -148
  47. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_fast.h +3 -2
  48. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_lazy.c +398 -345
  49. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_lazy.h +4 -2
  50. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_ldm.c +5 -5
  51. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_ldm.h +1 -1
  52. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_ldm_geartab.h +1 -1
  53. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_opt.c +106 -80
  54. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstd_opt.h +1 -1
  55. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstdmt_compress.c +17 -9
  56. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/compress/zstdmt_compress.h +1 -1
  57. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/huf_decompress.c +434 -441
  58. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/huf_decompress_amd64.S +30 -39
  59. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/zstd_ddict.c +4 -4
  60. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/zstd_ddict.h +1 -1
  61. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/zstd_decompress.c +205 -80
  62. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/zstd_decompress_block.c +201 -81
  63. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/zstd_decompress_block.h +6 -1
  64. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/decompress/zstd_decompress_internal.h +4 -2
  65. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/zdict.h +53 -31
  66. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/zstd.h +580 -135
  67. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/lib/zstd_errors.h +27 -8
  68. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/gzclose.c +1 -1
  69. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/gzcompatibility.h +8 -8
  70. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/gzguts.h +10 -10
  71. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/gzlib.c +3 -3
  72. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/gzread.c +10 -10
  73. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/gzwrite.c +5 -5
  74. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/zstd_zlibwrapper.c +46 -44
  75. data/ext/zstdlib_c/{zstd-1.5.2 → zstd-1.5.5}/zlibWrapper/zstd_zlibwrapper.h +4 -1
  76. metadata +77 -74
  77. data/ext/zstdlib_c/zstd-1.5.2/lib/common/threading.c +0 -122
  78. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_literals.c +0 -159
@@ -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 */