zstd-ruby 1.5.6.6 → 1.5.7.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +38 -1
  4. data/ext/zstdruby/common.h +37 -11
  5. data/ext/zstdruby/libzstd/common/bits.h +92 -87
  6. data/ext/zstdruby/libzstd/common/bitstream.h +26 -29
  7. data/ext/zstdruby/libzstd/common/compiler.h +36 -22
  8. data/ext/zstdruby/libzstd/common/cpu.h +1 -1
  9. data/ext/zstdruby/libzstd/common/debug.h +0 -9
  10. data/ext/zstdruby/libzstd/common/error_private.c +1 -0
  11. data/ext/zstdruby/libzstd/common/error_private.h +0 -10
  12. data/ext/zstdruby/libzstd/common/fse.h +2 -17
  13. data/ext/zstdruby/libzstd/common/fse_decompress.c +2 -0
  14. data/ext/zstdruby/libzstd/common/huf.h +0 -9
  15. data/ext/zstdruby/libzstd/common/mem.h +7 -11
  16. data/ext/zstdruby/libzstd/common/pool.h +0 -9
  17. data/ext/zstdruby/libzstd/common/portability_macros.h +22 -9
  18. data/ext/zstdruby/libzstd/common/threading.h +0 -8
  19. data/ext/zstdruby/libzstd/common/xxhash.h +93 -19
  20. data/ext/zstdruby/libzstd/common/zstd_deps.h +12 -0
  21. data/ext/zstdruby/libzstd/common/zstd_internal.h +1 -69
  22. data/ext/zstdruby/libzstd/common/zstd_trace.h +5 -12
  23. data/ext/zstdruby/libzstd/compress/hist.c +10 -0
  24. data/ext/zstdruby/libzstd/compress/hist.h +7 -0
  25. data/ext/zstdruby/libzstd/compress/zstd_compress.c +1057 -367
  26. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +227 -125
  27. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +1 -1
  28. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +7 -7
  29. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +7 -6
  30. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +17 -17
  31. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +41 -24
  32. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +58 -50
  33. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +4 -12
  34. data/ext/zstdruby/libzstd/compress/zstd_fast.c +91 -74
  35. data/ext/zstdruby/libzstd/compress/zstd_fast.h +4 -12
  36. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +64 -64
  37. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +30 -39
  38. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +48 -33
  39. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +6 -14
  40. data/ext/zstdruby/libzstd/compress/zstd_opt.c +55 -51
  41. data/ext/zstdruby/libzstd/compress/zstd_opt.h +8 -16
  42. data/ext/zstdruby/libzstd/compress/zstd_preSplit.c +238 -0
  43. data/ext/zstdruby/libzstd/compress/zstd_preSplit.h +33 -0
  44. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +134 -93
  45. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +4 -15
  46. data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +10 -3
  47. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +14 -11
  48. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +6 -12
  49. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +5 -5
  50. data/ext/zstdruby/libzstd/dictBuilder/cover.c +60 -19
  51. data/ext/zstdruby/libzstd/dictBuilder/divsufsort.h +0 -10
  52. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +2 -2
  53. data/ext/zstdruby/libzstd/zdict.h +15 -8
  54. data/ext/zstdruby/libzstd/zstd.h +241 -132
  55. data/ext/zstdruby/libzstd/zstd_errors.h +1 -8
  56. data/ext/zstdruby/main.c +4 -0
  57. data/ext/zstdruby/zstdruby.c +92 -0
  58. data/lib/zstd-ruby/stream_writer.rb +1 -1
  59. data/lib/zstd-ruby/version.rb +1 -1
  60. metadata +5 -3
@@ -227,10 +227,6 @@
227
227
  * xxHash prototypes and implementation
228
228
  */
229
229
 
230
- #if defined (__cplusplus)
231
- extern "C" {
232
- #endif
233
-
234
230
  /* ****************************
235
231
  * INLINE mode
236
232
  ******************************/
@@ -537,6 +533,9 @@ extern "C" {
537
533
  /*! @brief Version number, encoded as two digits each */
538
534
  #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
539
535
 
536
+ #if defined (__cplusplus)
537
+ extern "C" {
538
+ #endif
540
539
  /*!
541
540
  * @brief Obtains the xxHash version.
542
541
  *
@@ -547,6 +546,9 @@ extern "C" {
547
546
  */
548
547
  XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void);
549
548
 
549
+ #if defined (__cplusplus)
550
+ }
551
+ #endif
550
552
 
551
553
  /* ****************************
552
554
  * Common basic types
@@ -593,6 +595,10 @@ typedef uint32_t XXH32_hash_t;
593
595
  # endif
594
596
  #endif
595
597
 
598
+ #if defined (__cplusplus)
599
+ extern "C" {
600
+ #endif
601
+
596
602
  /*!
597
603
  * @}
598
604
  *
@@ -821,6 +827,9 @@ XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canoni
821
827
  #endif
822
828
  /*! @endcond */
823
829
 
830
+ #if defined (__cplusplus)
831
+ } /* end of extern "C" */
832
+ #endif
824
833
 
825
834
  /*!
826
835
  * @}
@@ -859,6 +868,9 @@ typedef uint64_t XXH64_hash_t;
859
868
  # endif
860
869
  #endif
861
870
 
871
+ #if defined (__cplusplus)
872
+ extern "C" {
873
+ #endif
862
874
  /*!
863
875
  * @}
864
876
  *
@@ -1562,6 +1574,11 @@ XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE con
1562
1574
 
1563
1575
 
1564
1576
  #endif /* !XXH_NO_XXH3 */
1577
+
1578
+ #if defined (__cplusplus)
1579
+ } /* extern "C" */
1580
+ #endif
1581
+
1565
1582
  #endif /* XXH_NO_LONG_LONG */
1566
1583
 
1567
1584
  /*!
@@ -1748,6 +1765,10 @@ struct XXH3_state_s {
1748
1765
  } while(0)
1749
1766
 
1750
1767
 
1768
+ #if defined (__cplusplus)
1769
+ extern "C" {
1770
+ #endif
1771
+
1751
1772
  /*!
1752
1773
  * @brief Calculates the 128-bit hash of @p data using XXH3.
1753
1774
  *
@@ -1963,8 +1984,13 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
1963
1984
  XXH64_hash_t seed64);
1964
1985
  #endif /* !XXH_NO_STREAM */
1965
1986
 
1987
+ #if defined (__cplusplus)
1988
+ } /* extern "C" */
1989
+ #endif
1990
+
1966
1991
  #endif /* !XXH_NO_XXH3 */
1967
1992
  #endif /* XXH_NO_LONG_LONG */
1993
+
1968
1994
  #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
1969
1995
  # define XXH_IMPLEMENTATION
1970
1996
  #endif
@@ -2263,10 +2289,12 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
2263
2289
  * @{
2264
2290
  */
2265
2291
 
2266
-
2267
2292
  /* *************************************
2268
2293
  * Includes & Memory related functions
2269
2294
  ***************************************/
2295
+ #include <string.h> /* memcmp, memcpy */
2296
+ #include <limits.h> /* ULLONG_MAX */
2297
+
2270
2298
  #if defined(XXH_NO_STREAM)
2271
2299
  /* nothing */
2272
2300
  #elif defined(XXH_NO_STDLIB)
@@ -2280,9 +2308,17 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
2280
2308
  * without access to dynamic allocation.
2281
2309
  */
2282
2310
 
2311
+ #if defined (__cplusplus)
2312
+ extern "C" {
2313
+ #endif
2314
+
2283
2315
  static XXH_CONSTF void* XXH_malloc(size_t s) { (void)s; return NULL; }
2284
2316
  static void XXH_free(void* p) { (void)p; }
2285
2317
 
2318
+ #if defined (__cplusplus)
2319
+ } /* extern "C" */
2320
+ #endif
2321
+
2286
2322
  #else
2287
2323
 
2288
2324
  /*
@@ -2291,6 +2327,9 @@ static void XXH_free(void* p) { (void)p; }
2291
2327
  */
2292
2328
  #include <stdlib.h>
2293
2329
 
2330
+ #if defined (__cplusplus)
2331
+ extern "C" {
2332
+ #endif
2294
2333
  /*!
2295
2334
  * @internal
2296
2335
  * @brief Modify this function to use a different routine than malloc().
@@ -2303,10 +2342,15 @@ static XXH_MALLOCF void* XXH_malloc(size_t s) { return malloc(s); }
2303
2342
  */
2304
2343
  static void XXH_free(void* p) { free(p); }
2305
2344
 
2306
- #endif /* XXH_NO_STDLIB */
2345
+ #if defined (__cplusplus)
2346
+ } /* extern "C" */
2347
+ #endif
2307
2348
 
2308
- #include <string.h>
2349
+ #endif /* XXH_NO_STDLIB */
2309
2350
 
2351
+ #if defined (__cplusplus)
2352
+ extern "C" {
2353
+ #endif
2310
2354
  /*!
2311
2355
  * @internal
2312
2356
  * @brief Modify this function to use a different routine than memcpy().
@@ -2316,8 +2360,9 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
2316
2360
  return memcpy(dest,src,size);
2317
2361
  }
2318
2362
 
2319
- #include <limits.h> /* ULLONG_MAX */
2320
-
2363
+ #if defined (__cplusplus)
2364
+ } /* extern "C" */
2365
+ #endif
2321
2366
 
2322
2367
  /* *************************************
2323
2368
  * Compiler Specific Options
@@ -2452,6 +2497,10 @@ typedef XXH32_hash_t xxh_u32;
2452
2497
  # define U32 xxh_u32
2453
2498
  #endif
2454
2499
 
2500
+ #if defined (__cplusplus)
2501
+ extern "C" {
2502
+ #endif
2503
+
2455
2504
  /* *** Memory access *** */
2456
2505
 
2457
2506
  /*!
@@ -3608,6 +3657,10 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_can
3608
3657
  return XXH_readBE64(src);
3609
3658
  }
3610
3659
 
3660
+ #if defined (__cplusplus)
3661
+ }
3662
+ #endif
3663
+
3611
3664
  #ifndef XXH_NO_XXH3
3612
3665
 
3613
3666
  /* *********************************************************************
@@ -3839,7 +3892,7 @@ enum XXH_VECTOR_TYPE /* fake enum */ {
3839
3892
  # define XXH_VECTOR XXH_AVX512
3840
3893
  # elif defined(__AVX2__)
3841
3894
  # define XXH_VECTOR XXH_AVX2
3842
- # elif defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP == 2))
3895
+ # elif defined(__SSE2__) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP == 2))
3843
3896
  # define XXH_VECTOR XXH_SSE2
3844
3897
  # elif (defined(__PPC64__) && defined(__POWER8_VECTOR__)) \
3845
3898
  || (defined(__s390x__) && defined(__VEC__)) \
@@ -3928,6 +3981,10 @@ enum XXH_VECTOR_TYPE /* fake enum */ {
3928
3981
  # pragma GCC optimize("-O2")
3929
3982
  #endif
3930
3983
 
3984
+ #if defined (__cplusplus)
3985
+ extern "C" {
3986
+ #endif
3987
+
3931
3988
  #if XXH_VECTOR == XXH_NEON
3932
3989
 
3933
3990
  /*
@@ -4050,6 +4107,10 @@ XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs)
4050
4107
  # endif
4051
4108
  #endif /* XXH_VECTOR == XXH_NEON */
4052
4109
 
4110
+ #if defined (__cplusplus)
4111
+ } /* extern "C" */
4112
+ #endif
4113
+
4053
4114
  /*
4054
4115
  * VSX and Z Vector helpers.
4055
4116
  *
@@ -4111,6 +4172,9 @@ typedef xxh_u64x2 xxh_aliasing_u64x2 XXH_ALIASING;
4111
4172
  # if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__))
4112
4173
  # define XXH_vec_revb vec_revb
4113
4174
  # else
4175
+ #if defined (__cplusplus)
4176
+ extern "C" {
4177
+ #endif
4114
4178
  /*!
4115
4179
  * A polyfill for POWER9's vec_revb().
4116
4180
  */
@@ -4120,9 +4184,15 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_revb(xxh_u64x2 val)
4120
4184
  0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 };
4121
4185
  return vec_perm(val, val, vByteSwap);
4122
4186
  }
4187
+ #if defined (__cplusplus)
4188
+ } /* extern "C" */
4189
+ #endif
4123
4190
  # endif
4124
4191
  # endif /* XXH_VSX_BE */
4125
4192
 
4193
+ #if defined (__cplusplus)
4194
+ extern "C" {
4195
+ #endif
4126
4196
  /*!
4127
4197
  * Performs an unaligned vector load and byte swaps it on big endian.
4128
4198
  */
@@ -4167,6 +4237,11 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b)
4167
4237
  return result;
4168
4238
  }
4169
4239
  # endif /* XXH_vec_mulo, XXH_vec_mule */
4240
+
4241
+ #if defined (__cplusplus)
4242
+ } /* extern "C" */
4243
+ #endif
4244
+
4170
4245
  #endif /* XXH_VECTOR == XXH_VSX */
4171
4246
 
4172
4247
  #if XXH_VECTOR == XXH_SVE
@@ -4200,7 +4275,9 @@ do { \
4200
4275
  # endif
4201
4276
  #endif /* XXH_NO_PREFETCH */
4202
4277
 
4203
-
4278
+ #if defined (__cplusplus)
4279
+ extern "C" {
4280
+ #endif
4204
4281
  /* ==========================================
4205
4282
  * XXH3 default settings
4206
4283
  * ========================================== */
@@ -6877,8 +6954,6 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (XXH_NOESCAPE const XXH3_state_
6877
6954
  #endif /* !XXH_NO_STREAM */
6878
6955
  /* 128-bit utility functions */
6879
6956
 
6880
- #include <string.h> /* memcmp, memcpy */
6881
-
6882
6957
  /* return : 1 is equal, 0 if different */
6883
6958
  /*! @ingroup XXH3_family */
6884
6959
  XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2)
@@ -7005,16 +7080,15 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed)
7005
7080
  # pragma GCC pop_options
7006
7081
  #endif
7007
7082
 
7008
- #endif /* XXH_NO_LONG_LONG */
7009
7083
 
7084
+ #if defined (__cplusplus)
7085
+ } /* extern "C" */
7086
+ #endif
7087
+
7088
+ #endif /* XXH_NO_LONG_LONG */
7010
7089
  #endif /* XXH_NO_XXH3 */
7011
7090
 
7012
7091
  /*!
7013
7092
  * @}
7014
7093
  */
7015
7094
  #endif /* XXH_IMPLEMENTATION */
7016
-
7017
-
7018
- #if defined (__cplusplus)
7019
- } /* extern "C" */
7020
- #endif
@@ -24,6 +24,18 @@
24
24
  #ifndef ZSTD_DEPS_COMMON
25
25
  #define ZSTD_DEPS_COMMON
26
26
 
27
+ /* Even though we use qsort_r only for the dictionary builder, the macro
28
+ * _GNU_SOURCE has to be declared *before* the inclusion of any standard
29
+ * header and the script 'combine.sh' combines the whole zstd source code
30
+ * in a single file.
31
+ */
32
+ #if defined(__linux) || defined(__linux__) || defined(linux) || defined(__gnu_linux__) || \
33
+ defined(__CYGWIN__) || defined(__MSYS__)
34
+ #if !defined(_GNU_SOURCE) && !defined(__ANDROID__) /* NDK doesn't ship qsort_r(). */
35
+ #define _GNU_SOURCE
36
+ #endif
37
+ #endif
38
+
27
39
  #include <limits.h>
28
40
  #include <stddef.h>
29
41
  #include <string.h>
@@ -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);