zstdlib 0.8.0-x64-mingw32 → 0.9.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +10 -0
  3. data/README.md +7 -1
  4. data/Rakefile +38 -8
  5. data/ext/{zstdlib → zstdlib_c}/extconf.rb +10 -5
  6. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.2/zstdlib.c +2 -2
  7. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.3/zstdlib.c +2 -2
  8. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.4/zstdlib.c +2 -2
  9. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.5/zstdlib.c +2 -2
  10. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.6/zstdlib.c +2 -2
  11. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.7/zstdlib.c +2 -2
  12. data/ext/{zstdlib → zstdlib_c}/ruby/zlib-3.0/zstdlib.c +2 -2
  13. data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
  14. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/adler32.c +0 -0
  15. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/compress.c +0 -0
  16. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.c +0 -0
  17. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/crc32.h +0 -0
  18. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.c +0 -0
  19. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/deflate.h +0 -0
  20. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzclose.c +0 -0
  21. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzguts.h +0 -0
  22. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzlib.c +0 -0
  23. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzread.c +0 -0
  24. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/gzwrite.c +0 -0
  25. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/infback.c +0 -0
  26. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.c +0 -0
  27. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffast.h +0 -0
  28. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inffixed.h +0 -0
  29. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.c +0 -0
  30. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inflate.h +0 -0
  31. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.c +0 -0
  32. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/inftrees.h +0 -0
  33. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.c +0 -0
  34. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/trees.h +0 -0
  35. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/uncompr.c +0 -0
  36. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zconf.h +0 -0
  37. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zlib.h +0 -0
  38. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.c +0 -0
  39. data/ext/{zstdlib → zstdlib_c}/zlib-1.2.11/zutil.h +0 -0
  40. data/ext/{zstdlib → zstdlib_c}/zlib.mk +0 -0
  41. data/ext/{zstdlib → zstdlib_c}/zlibwrapper/zlibwrapper.c +1 -5
  42. data/ext/{zstdlib → zstdlib_c}/zlibwrapper.mk +0 -0
  43. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/bitstream.h +24 -9
  44. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/compiler.h +89 -43
  45. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/cpu.h +0 -0
  46. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/debug.c +0 -0
  47. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/debug.h +0 -0
  48. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/entropy_common.c +11 -5
  49. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.c +0 -0
  50. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.h +79 -0
  51. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/fse.h +2 -1
  52. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/fse_decompress.c +1 -1
  53. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/huf.h +24 -22
  54. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/mem.h +18 -0
  55. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/pool.c +11 -6
  56. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/pool.h +2 -2
  57. data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
  58. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/threading.c +0 -0
  59. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/threading.h +0 -0
  60. data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
  61. data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
  62. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_common.c +0 -0
  63. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_deps.h +0 -0
  64. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_internal.h +95 -92
  65. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_trace.h +12 -3
  66. data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
  67. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/fse_compress.c +63 -27
  68. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.c +0 -0
  69. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.h +0 -0
  70. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/huf_compress.c +537 -104
  71. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress.c +307 -373
  72. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_internal.h +174 -83
  73. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.c +4 -3
  74. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.h +3 -1
  75. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.c +15 -14
  76. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.h +0 -0
  77. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.c +4 -3
  78. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.h +0 -0
  79. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_cwksp.h +41 -27
  80. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.c +295 -120
  81. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.h +0 -0
  82. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.c +309 -130
  83. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.h +0 -0
  84. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_lazy.c +482 -562
  85. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_lazy.h +0 -0
  86. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.c +9 -7
  87. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.h +1 -1
  88. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm_geartab.h +4 -1
  89. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.c +249 -148
  90. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.h +0 -0
  91. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.c +76 -38
  92. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.h +4 -1
  93. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/huf_decompress.c +727 -189
  94. data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
  95. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.c +0 -0
  96. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.h +0 -0
  97. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress.c +85 -22
  98. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.c +744 -220
  99. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.h +8 -2
  100. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_internal.h +34 -3
  101. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/zdict.h +4 -4
  102. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/zstd.h +179 -136
  103. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/lib/zstd_errors.h +0 -0
  104. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzclose.c +0 -0
  105. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzcompatibility.h +0 -0
  106. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzguts.h +0 -0
  107. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzlib.c +0 -0
  108. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzread.c +0 -0
  109. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzwrite.c +0 -0
  110. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.c +7 -0
  111. data/ext/{zstdlib/zstd-1.5.0 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.h +0 -0
  112. data/ext/zstdlib_c/zstd.mk +15 -0
  113. data/lib/2.4/zstdlib_c.so +0 -0
  114. data/lib/2.5/zstdlib_c.so +0 -0
  115. data/lib/2.6/zstdlib_c.so +0 -0
  116. data/lib/2.7/zstdlib_c.so +0 -0
  117. data/lib/3.0/zstdlib_c.so +0 -0
  118. data/lib/zstdlib.rb +2 -2
  119. metadata +124 -121
  120. data/ext/zstdlib/zstd-1.5.0/lib/common/xxhash.c +0 -824
  121. data/ext/zstdlib/zstd-1.5.0/lib/common/xxhash.h +0 -285
  122. data/ext/zstdlib/zstd.mk +0 -14
  123. data/lib/2.2/zstdlib.so +0 -0
  124. data/lib/2.3/zstdlib.so +0 -0
  125. data/lib/2.4/zstdlib.so +0 -0
  126. data/lib/2.5/zstdlib.so +0 -0
  127. data/lib/2.6/zstdlib.so +0 -0
  128. data/lib/2.7/zstdlib.so +0 -0
@@ -51,6 +51,8 @@ extern "C" {
51
51
  # include <stdint.h> /* intptr_t */
52
52
  # endif
53
53
  typedef uint8_t BYTE;
54
+ typedef uint8_t U8;
55
+ typedef int8_t S8;
54
56
  typedef uint16_t U16;
55
57
  typedef int16_t S16;
56
58
  typedef uint32_t U32;
@@ -63,6 +65,8 @@ extern "C" {
63
65
  # error "this implementation requires char to be exactly 8-bit type"
64
66
  #endif
65
67
  typedef unsigned char BYTE;
68
+ typedef unsigned char U8;
69
+ typedef signed char S8;
66
70
  #if USHRT_MAX != 65535
67
71
  # error "this implementation requires short to be exactly 16-bit type"
68
72
  #endif
@@ -153,8 +157,22 @@ MEM_STATIC unsigned MEM_64bits(void) { return sizeof(size_t)==8; }
153
157
 
154
158
  MEM_STATIC unsigned MEM_isLittleEndian(void)
155
159
  {
160
+ #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
161
+ return 1;
162
+ #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
163
+ return 0;
164
+ #elif defined(__clang__) && __LITTLE_ENDIAN__
165
+ return 1;
166
+ #elif defined(__clang__) && __BIG_ENDIAN__
167
+ return 0;
168
+ #elif defined(_MSC_VER) && (_M_AMD64 || _M_IX86)
169
+ return 1;
170
+ #elif defined(__DMC__) && defined(_M_IX86)
171
+ return 1;
172
+ #else
156
173
  const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
157
174
  return one.c[0];
175
+ #endif
158
176
  }
159
177
 
160
178
  #if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
@@ -86,7 +86,7 @@ static void* POOL_thread(void* opaque) {
86
86
  { POOL_job const job = ctx->queue[ctx->queueHead];
87
87
  ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
88
88
  ctx->numThreadsBusy++;
89
- ctx->queueEmpty = ctx->queueHead == ctx->queueTail;
89
+ ctx->queueEmpty = (ctx->queueHead == ctx->queueTail);
90
90
  /* Unlock the mutex, signal a pusher, and run the job */
91
91
  ZSTD_pthread_cond_signal(&ctx->queuePushCond);
92
92
  ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
@@ -105,6 +105,7 @@ static void* POOL_thread(void* opaque) {
105
105
  assert(0); /* Unreachable */
106
106
  }
107
107
 
108
+ /* ZSTD_createThreadPool() : public access point */
108
109
  POOL_ctx* ZSTD_createThreadPool(size_t numThreads) {
109
110
  return POOL_create (numThreads, 0);
110
111
  }
@@ -114,7 +115,8 @@ POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
114
115
  }
115
116
 
116
117
  POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
117
- ZSTD_customMem customMem) {
118
+ ZSTD_customMem customMem)
119
+ {
118
120
  POOL_ctx* ctx;
119
121
  /* Check parameters */
120
122
  if (!numThreads) { return NULL; }
@@ -192,7 +194,7 @@ void ZSTD_freeThreadPool (ZSTD_threadPool* pool) {
192
194
  POOL_free (pool);
193
195
  }
194
196
 
195
- size_t POOL_sizeof(POOL_ctx *ctx) {
197
+ size_t POOL_sizeof(const POOL_ctx* ctx) {
196
198
  if (ctx==NULL) return 0; /* supports sizeof NULL */
197
199
  return sizeof(*ctx)
198
200
  + ctx->queueSize * sizeof(POOL_job)
@@ -257,7 +259,8 @@ static int isQueueFull(POOL_ctx const* ctx) {
257
259
  }
258
260
 
259
261
 
260
- static void POOL_add_internal(POOL_ctx* ctx, POOL_function function, void *opaque)
262
+ static void
263
+ POOL_add_internal(POOL_ctx* ctx, POOL_function function, void *opaque)
261
264
  {
262
265
  POOL_job const job = {function, opaque};
263
266
  assert(ctx != NULL);
@@ -313,7 +316,9 @@ POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
313
316
  return POOL_create_advanced(numThreads, queueSize, ZSTD_defaultCMem);
314
317
  }
315
318
 
316
- POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize, ZSTD_customMem customMem) {
319
+ POOL_ctx*
320
+ POOL_create_advanced(size_t numThreads, size_t queueSize, ZSTD_customMem customMem)
321
+ {
317
322
  (void)numThreads;
318
323
  (void)queueSize;
319
324
  (void)customMem;
@@ -341,7 +346,7 @@ int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque) {
341
346
  return 1;
342
347
  }
343
348
 
344
- size_t POOL_sizeof(POOL_ctx* ctx) {
349
+ size_t POOL_sizeof(const POOL_ctx* ctx) {
345
350
  if (ctx==NULL) return 0; /* supports sizeof NULL */
346
351
  assert(ctx == &g_poolCtx);
347
352
  return sizeof(*ctx);
@@ -53,7 +53,7 @@ int POOL_resize(POOL_ctx* ctx, size_t numThreads);
53
53
  * @return threadpool memory usage
54
54
  * note : compatible with NULL (returns 0 in this case)
55
55
  */
56
- size_t POOL_sizeof(POOL_ctx* ctx);
56
+ size_t POOL_sizeof(const POOL_ctx* ctx);
57
57
 
58
58
  /*! POOL_function :
59
59
  * The function type that can be added to a thread pool.
@@ -70,7 +70,7 @@ void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque);
70
70
 
71
71
 
72
72
  /*! POOL_tryAdd() :
73
- * Add the job `function(opaque)` to thread pool _if_ a worker is available.
73
+ * Add the job `function(opaque)` to thread pool _if_ a queue slot is available.
74
74
  * Returns immediately even if not (does not block).
75
75
  * @return : 1 if successful, 0 if not.
76
76
  */
@@ -0,0 +1,137 @@
1
+ /*
2
+ * Copyright (c) Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under both the BSD-style license (found in the
6
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7
+ * in the COPYING file in the root directory of this source tree).
8
+ * You may select, at your option, one of the above-listed licenses.
9
+ */
10
+
11
+ #ifndef ZSTD_PORTABILITY_MACROS_H
12
+ #define ZSTD_PORTABILITY_MACROS_H
13
+
14
+ /**
15
+ * This header file contains macro defintions to support portability.
16
+ * This header is shared between C and ASM code, so it MUST only
17
+ * contain macro definitions. It MUST not contain any C code.
18
+ *
19
+ * This header ONLY defines macros to detect platforms/feature support.
20
+ *
21
+ */
22
+
23
+
24
+ /* compat. with non-clang compilers */
25
+ #ifndef __has_attribute
26
+ #define __has_attribute(x) 0
27
+ #endif
28
+
29
+ /* compat. with non-clang compilers */
30
+ #ifndef __has_builtin
31
+ # define __has_builtin(x) 0
32
+ #endif
33
+
34
+ /* compat. with non-clang compilers */
35
+ #ifndef __has_feature
36
+ # define __has_feature(x) 0
37
+ #endif
38
+
39
+ /* detects whether we are being compiled under msan */
40
+ #ifndef ZSTD_MEMORY_SANITIZER
41
+ # if __has_feature(memory_sanitizer)
42
+ # define ZSTD_MEMORY_SANITIZER 1
43
+ # else
44
+ # define ZSTD_MEMORY_SANITIZER 0
45
+ # endif
46
+ #endif
47
+
48
+ /* detects whether we are being compiled under asan */
49
+ #ifndef ZSTD_ADDRESS_SANITIZER
50
+ # if __has_feature(address_sanitizer)
51
+ # define ZSTD_ADDRESS_SANITIZER 1
52
+ # elif defined(__SANITIZE_ADDRESS__)
53
+ # define ZSTD_ADDRESS_SANITIZER 1
54
+ # else
55
+ # define ZSTD_ADDRESS_SANITIZER 0
56
+ # endif
57
+ #endif
58
+
59
+ /* detects whether we are being compiled under dfsan */
60
+ #ifndef ZSTD_DATAFLOW_SANITIZER
61
+ # if __has_feature(dataflow_sanitizer)
62
+ # define ZSTD_DATAFLOW_SANITIZER 1
63
+ # else
64
+ # define ZSTD_DATAFLOW_SANITIZER 0
65
+ # endif
66
+ #endif
67
+
68
+ /* Mark the internal assembly functions as hidden */
69
+ #ifdef __ELF__
70
+ # define ZSTD_HIDE_ASM_FUNCTION(func) .hidden func
71
+ #else
72
+ # define ZSTD_HIDE_ASM_FUNCTION(func)
73
+ #endif
74
+
75
+ /* Enable runtime BMI2 dispatch based on the CPU.
76
+ * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
77
+ */
78
+ #ifndef DYNAMIC_BMI2
79
+ #if ((defined(__clang__) && __has_attribute(__target__)) \
80
+ || (defined(__GNUC__) \
81
+ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
82
+ && (defined(__x86_64__) || defined(_M_X64)) \
83
+ && !defined(__BMI2__)
84
+ # define DYNAMIC_BMI2 1
85
+ #else
86
+ # define DYNAMIC_BMI2 0
87
+ #endif
88
+ #endif
89
+
90
+ /**
91
+ * Only enable assembly for GNUC comptabile compilers,
92
+ * because other platforms may not support GAS assembly syntax.
93
+ *
94
+ * Only enable assembly for Linux / MacOS, other platforms may
95
+ * work, but they haven't been tested. This could likely be
96
+ * extended to BSD systems.
97
+ *
98
+ * Disable assembly when MSAN is enabled, because MSAN requires
99
+ * 100% of code to be instrumented to work.
100
+ */
101
+ #if defined(__GNUC__)
102
+ # if defined(__linux__) || defined(__linux) || defined(__APPLE__)
103
+ # if ZSTD_MEMORY_SANITIZER
104
+ # define ZSTD_ASM_SUPPORTED 0
105
+ # elif ZSTD_DATAFLOW_SANITIZER
106
+ # define ZSTD_ASM_SUPPORTED 0
107
+ # else
108
+ # define ZSTD_ASM_SUPPORTED 1
109
+ # endif
110
+ # else
111
+ # define ZSTD_ASM_SUPPORTED 0
112
+ # endif
113
+ #else
114
+ # define ZSTD_ASM_SUPPORTED 0
115
+ #endif
116
+
117
+ /**
118
+ * Determines whether we should enable assembly for x86-64
119
+ * with BMI2.
120
+ *
121
+ * Enable if all of the following conditions hold:
122
+ * - ASM hasn't been explicitly disabled by defining ZSTD_DISABLE_ASM
123
+ * - Assembly is supported
124
+ * - We are compiling for x86-64 and either:
125
+ * - DYNAMIC_BMI2 is enabled
126
+ * - BMI2 is supported at compile time
127
+ */
128
+ #if !defined(ZSTD_DISABLE_ASM) && \
129
+ ZSTD_ASM_SUPPORTED && \
130
+ defined(__x86_64__) && \
131
+ (DYNAMIC_BMI2 || defined(__BMI2__))
132
+ # define ZSTD_ENABLE_ASM_X86_64_BMI2 1
133
+ #else
134
+ # define ZSTD_ENABLE_ASM_X86_64_BMI2 0
135
+ #endif
136
+
137
+ #endif /* ZSTD_PORTABILITY_MACROS_H */
@@ -0,0 +1,24 @@
1
+ /*
2
+ * xxHash - Fast Hash algorithm
3
+ * Copyright (c) Yann Collet, Facebook, Inc.
4
+ *
5
+ * You can contact the author at :
6
+ * - xxHash homepage: http://www.xxhash.com
7
+ * - xxHash source repository : https://github.com/Cyan4973/xxHash
8
+ *
9
+ * This source code is licensed under both the BSD-style license (found in the
10
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
11
+ * in the COPYING file in the root directory of this source tree).
12
+ * You may select, at your option, one of the above-listed licenses.
13
+ */
14
+
15
+
16
+
17
+ /*
18
+ * xxhash.c instantiates functions defined in xxhash.h
19
+ */
20
+
21
+ #define XXH_STATIC_LINKING_ONLY /* access advanced declarations */
22
+ #define XXH_IMPLEMENTATION /* access definitions */
23
+
24
+ #include "xxhash.h"