zstd-ruby 1.5.6.7 → 2.0.0.pre.preview1

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -1
  3. data/ext/zstdruby/common.h +1 -4
  4. data/ext/zstdruby/exports.txt +1 -0
  5. data/ext/zstdruby/extconf.rb +6 -1
  6. data/ext/zstdruby/libzstd/common/bits.h +92 -87
  7. data/ext/zstdruby/libzstd/common/bitstream.h +26 -29
  8. data/ext/zstdruby/libzstd/common/compiler.h +36 -22
  9. data/ext/zstdruby/libzstd/common/cpu.h +1 -1
  10. data/ext/zstdruby/libzstd/common/debug.h +0 -9
  11. data/ext/zstdruby/libzstd/common/error_private.c +1 -0
  12. data/ext/zstdruby/libzstd/common/error_private.h +0 -10
  13. data/ext/zstdruby/libzstd/common/fse.h +2 -17
  14. data/ext/zstdruby/libzstd/common/fse_decompress.c +2 -0
  15. data/ext/zstdruby/libzstd/common/huf.h +0 -9
  16. data/ext/zstdruby/libzstd/common/mem.h +7 -11
  17. data/ext/zstdruby/libzstd/common/pool.h +0 -9
  18. data/ext/zstdruby/libzstd/common/portability_macros.h +22 -9
  19. data/ext/zstdruby/libzstd/common/threading.h +0 -8
  20. data/ext/zstdruby/libzstd/common/xxhash.h +93 -19
  21. data/ext/zstdruby/libzstd/common/zstd_deps.h +12 -0
  22. data/ext/zstdruby/libzstd/common/zstd_internal.h +1 -69
  23. data/ext/zstdruby/libzstd/common/zstd_trace.h +5 -12
  24. data/ext/zstdruby/libzstd/compress/hist.c +10 -0
  25. data/ext/zstdruby/libzstd/compress/hist.h +7 -0
  26. data/ext/zstdruby/libzstd/compress/zstd_compress.c +1057 -367
  27. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +227 -125
  28. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +1 -1
  29. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +7 -7
  30. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +7 -6
  31. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +17 -17
  32. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +41 -24
  33. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +58 -50
  34. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +4 -12
  35. data/ext/zstdruby/libzstd/compress/zstd_fast.c +91 -74
  36. data/ext/zstdruby/libzstd/compress/zstd_fast.h +4 -12
  37. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +64 -64
  38. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +30 -39
  39. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +48 -33
  40. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +6 -14
  41. data/ext/zstdruby/libzstd/compress/zstd_opt.c +55 -51
  42. data/ext/zstdruby/libzstd/compress/zstd_opt.h +8 -16
  43. data/ext/zstdruby/libzstd/compress/zstd_preSplit.c +238 -0
  44. data/ext/zstdruby/libzstd/compress/zstd_preSplit.h +33 -0
  45. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +134 -93
  46. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +4 -15
  47. data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +10 -3
  48. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +14 -11
  49. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +6 -12
  50. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +5 -5
  51. data/ext/zstdruby/libzstd/dictBuilder/cover.c +60 -19
  52. data/ext/zstdruby/libzstd/dictBuilder/divsufsort.h +0 -10
  53. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +2 -2
  54. data/ext/zstdruby/libzstd/zdict.h +15 -8
  55. data/ext/zstdruby/libzstd/zstd.h +241 -132
  56. data/ext/zstdruby/libzstd/zstd_errors.h +1 -8
  57. data/ext/zstdruby/main.c +1 -1
  58. data/ext/zstdruby/streaming_compress.c +2 -3
  59. data/ext/zstdruby/streaming_decompress.c +22 -0
  60. data/ext/zstdruby/zstdruby.c +2 -103
  61. data/lib/zstd-ruby/version.rb +1 -1
  62. metadata +7 -4
@@ -39,10 +39,6 @@
39
39
  # define ZSTD_TRACE 0
40
40
  #endif
41
41
 
42
- #if defined (__cplusplus)
43
- extern "C" {
44
- #endif
45
-
46
42
  /* ---- static assert (debug) --- */
47
43
  #define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
48
44
  #define ZSTD_isError ERR_isError /* for inlining */
@@ -95,7 +91,7 @@ typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
95
91
  #define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */) /* for a non-null block */
96
92
  #define MIN_LITERALS_FOR_4_STREAMS 6
97
93
 
98
- typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingType_e;
94
+ typedef enum { set_basic, set_rle, set_compressed, set_repeat } SymbolEncodingType_e;
99
95
 
100
96
  #define LONGNBSEQ 0x7F00
101
97
 
@@ -278,62 +274,6 @@ typedef enum {
278
274
  /*-*******************************************
279
275
  * Private declarations
280
276
  *********************************************/
281
- typedef struct seqDef_s {
282
- U32 offBase; /* offBase == Offset + ZSTD_REP_NUM, or repcode 1,2,3 */
283
- U16 litLength;
284
- U16 mlBase; /* mlBase == matchLength - MINMATCH */
285
- } seqDef;
286
-
287
- /* Controls whether seqStore has a single "long" litLength or matchLength. See seqStore_t. */
288
- typedef enum {
289
- ZSTD_llt_none = 0, /* no longLengthType */
290
- ZSTD_llt_literalLength = 1, /* represents a long literal */
291
- ZSTD_llt_matchLength = 2 /* represents a long match */
292
- } ZSTD_longLengthType_e;
293
-
294
- typedef struct {
295
- seqDef* sequencesStart;
296
- seqDef* sequences; /* ptr to end of sequences */
297
- BYTE* litStart;
298
- BYTE* lit; /* ptr to end of literals */
299
- BYTE* llCode;
300
- BYTE* mlCode;
301
- BYTE* ofCode;
302
- size_t maxNbSeq;
303
- size_t maxNbLit;
304
-
305
- /* longLengthPos and longLengthType to allow us to represent either a single litLength or matchLength
306
- * in the seqStore that has a value larger than U16 (if it exists). To do so, we increment
307
- * the existing value of the litLength or matchLength by 0x10000.
308
- */
309
- ZSTD_longLengthType_e longLengthType;
310
- U32 longLengthPos; /* Index of the sequence to apply long length modification to */
311
- } seqStore_t;
312
-
313
- typedef struct {
314
- U32 litLength;
315
- U32 matchLength;
316
- } ZSTD_sequenceLength;
317
-
318
- /**
319
- * Returns the ZSTD_sequenceLength for the given sequences. It handles the decoding of long sequences
320
- * indicated by longLengthPos and longLengthType, and adds MINMATCH back to matchLength.
321
- */
322
- MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore, seqDef const* seq)
323
- {
324
- ZSTD_sequenceLength seqLen;
325
- seqLen.litLength = seq->litLength;
326
- seqLen.matchLength = seq->mlBase + MINMATCH;
327
- if (seqStore->longLengthPos == (U32)(seq - seqStore->sequencesStart)) {
328
- if (seqStore->longLengthType == ZSTD_llt_literalLength) {
329
- seqLen.litLength += 0x10000;
330
- }
331
- if (seqStore->longLengthType == ZSTD_llt_matchLength) {
332
- seqLen.matchLength += 0x10000;
333
- }
334
- }
335
- return seqLen;
336
- }
337
277
 
338
278
  /**
339
279
  * Contains the compressed frame size and an upper-bound for the decompressed frame size.
@@ -347,10 +287,6 @@ typedef struct {
347
287
  unsigned long long decompressedBound;
348
288
  } ZSTD_frameSizeInfo; /* decompress & legacy */
349
289
 
350
- const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
351
- int ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
352
-
353
-
354
290
  /* ZSTD_invalidateRepCodes() :
355
291
  * ensures next compression will not use repcodes from previous block.
356
292
  * Note : only works with regular variant;
@@ -385,8 +321,4 @@ MEM_STATIC int ZSTD_cpuSupportsBmi2(void)
385
321
  return ZSTD_cpuid_bmi1(cpuid) && ZSTD_cpuid_bmi2(cpuid);
386
322
  }
387
323
 
388
- #if defined (__cplusplus)
389
- }
390
- #endif
391
-
392
324
  #endif /* ZSTD_CCOMMON_H_MODULE */
@@ -11,23 +11,20 @@
11
11
  #ifndef ZSTD_TRACE_H
12
12
  #define ZSTD_TRACE_H
13
13
 
14
- #if defined (__cplusplus)
15
- extern "C" {
16
- #endif
17
-
18
14
  #include <stddef.h>
19
15
 
20
16
  /* weak symbol support
21
17
  * For now, enable conservatively:
22
18
  * - Only GNUC
23
19
  * - Only ELF
24
- * - Only x86-64, i386 and aarch64
20
+ * - Only x86-64, i386, aarch64 and risc-v.
25
21
  * Also, explicitly disable on platforms known not to work so they aren't
26
22
  * forgotten in the future.
27
23
  */
28
24
  #if !defined(ZSTD_HAVE_WEAK_SYMBOLS) && \
29
25
  defined(__GNUC__) && defined(__ELF__) && \
30
- (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || defined(__aarch64__)) && \
26
+ (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
27
+ defined(_M_IX86) || defined(__aarch64__) || defined(__riscv)) && \
31
28
  !defined(__APPLE__) && !defined(_WIN32) && !defined(__MINGW32__) && \
32
29
  !defined(__CYGWIN__) && !defined(_AIX)
33
30
  # define ZSTD_HAVE_WEAK_SYMBOLS 1
@@ -64,7 +61,7 @@ typedef struct {
64
61
  /**
65
62
  * Non-zero if streaming (de)compression is used.
66
63
  */
67
- unsigned streaming;
64
+ int streaming;
68
65
  /**
69
66
  * The dictionary ID.
70
67
  */
@@ -73,7 +70,7 @@ typedef struct {
73
70
  * Is the dictionary cold?
74
71
  * Only set on decompression.
75
72
  */
76
- unsigned dictionaryIsCold;
73
+ int dictionaryIsCold;
77
74
  /**
78
75
  * The dictionary size or zero if no dictionary.
79
76
  */
@@ -156,8 +153,4 @@ ZSTD_WEAK_ATTR void ZSTD_trace_decompress_end(
156
153
 
157
154
  #endif /* ZSTD_TRACE */
158
155
 
159
- #if defined (__cplusplus)
160
- }
161
- #endif
162
-
163
156
  #endif /* ZSTD_TRACE_H */
@@ -26,6 +26,16 @@ unsigned HIST_isError(size_t code) { return ERR_isError(code); }
26
26
  /*-**************************************************************
27
27
  * Histogram functions
28
28
  ****************************************************************/
29
+ void HIST_add(unsigned* count, const void* src, size_t srcSize)
30
+ {
31
+ const BYTE* ip = (const BYTE*)src;
32
+ const BYTE* const end = ip + srcSize;
33
+
34
+ while (ip<end) {
35
+ count[*ip++]++;
36
+ }
37
+ }
38
+
29
39
  unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
30
40
  const void* src, size_t srcSize)
31
41
  {
@@ -73,3 +73,10 @@ size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
73
73
  */
74
74
  unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
75
75
  const void* src, size_t srcSize);
76
+
77
+ /*! HIST_add() :
78
+ * Lowest level: just add nb of occurrences of characters from @src into @count.
79
+ * @count is not reset. @count array is presumed large enough (i.e. 1 KB).
80
+ @ This function does not need any additional stack memory.
81
+ */
82
+ void HIST_add(unsigned* count, const void* src, size_t srcSize);