extzstd 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -14
  3. data/contrib/zstd/CHANGELOG +301 -56
  4. data/contrib/zstd/CONTRIBUTING.md +169 -72
  5. data/contrib/zstd/LICENSE +4 -4
  6. data/contrib/zstd/Makefile +116 -87
  7. data/contrib/zstd/Package.swift +36 -0
  8. data/contrib/zstd/README.md +62 -32
  9. data/contrib/zstd/TESTING.md +2 -3
  10. data/contrib/zstd/appveyor.yml +52 -136
  11. data/contrib/zstd/lib/BUCK +5 -7
  12. data/contrib/zstd/lib/Makefile +225 -222
  13. data/contrib/zstd/lib/README.md +51 -6
  14. data/contrib/zstd/lib/common/allocations.h +55 -0
  15. data/contrib/zstd/lib/common/bits.h +200 -0
  16. data/contrib/zstd/lib/common/bitstream.h +45 -62
  17. data/contrib/zstd/lib/common/compiler.h +205 -22
  18. data/contrib/zstd/lib/common/cpu.h +1 -3
  19. data/contrib/zstd/lib/common/debug.c +1 -1
  20. data/contrib/zstd/lib/common/debug.h +12 -19
  21. data/contrib/zstd/lib/common/entropy_common.c +172 -48
  22. data/contrib/zstd/lib/common/error_private.c +10 -2
  23. data/contrib/zstd/lib/common/error_private.h +82 -3
  24. data/contrib/zstd/lib/common/fse.h +37 -86
  25. data/contrib/zstd/lib/common/fse_decompress.c +117 -92
  26. data/contrib/zstd/lib/common/huf.h +99 -166
  27. data/contrib/zstd/lib/common/mem.h +124 -142
  28. data/contrib/zstd/lib/common/pool.c +54 -27
  29. data/contrib/zstd/lib/common/pool.h +10 -4
  30. data/contrib/zstd/lib/common/portability_macros.h +156 -0
  31. data/contrib/zstd/lib/common/threading.c +74 -19
  32. data/contrib/zstd/lib/common/threading.h +5 -10
  33. data/contrib/zstd/lib/common/xxhash.c +7 -847
  34. data/contrib/zstd/lib/common/xxhash.h +5568 -167
  35. data/contrib/zstd/lib/common/zstd_common.c +2 -37
  36. data/contrib/zstd/lib/common/zstd_deps.h +111 -0
  37. data/contrib/zstd/lib/common/zstd_internal.h +132 -187
  38. data/contrib/zstd/lib/common/zstd_trace.h +163 -0
  39. data/contrib/zstd/lib/compress/clevels.h +134 -0
  40. data/contrib/zstd/lib/compress/fse_compress.c +83 -157
  41. data/contrib/zstd/lib/compress/hist.c +27 -29
  42. data/contrib/zstd/lib/compress/hist.h +2 -2
  43. data/contrib/zstd/lib/compress/huf_compress.c +916 -279
  44. data/contrib/zstd/lib/compress/zstd_compress.c +3773 -1019
  45. data/contrib/zstd/lib/compress/zstd_compress_internal.h +610 -203
  46. data/contrib/zstd/lib/compress/zstd_compress_literals.c +119 -42
  47. data/contrib/zstd/lib/compress/zstd_compress_literals.h +16 -6
  48. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +42 -19
  49. data/contrib/zstd/lib/compress/zstd_compress_sequences.h +1 -1
  50. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +49 -317
  51. data/contrib/zstd/lib/compress/zstd_compress_superblock.h +1 -1
  52. data/contrib/zstd/lib/compress/zstd_cwksp.h +320 -103
  53. data/contrib/zstd/lib/compress/zstd_double_fast.c +388 -151
  54. data/contrib/zstd/lib/compress/zstd_double_fast.h +3 -2
  55. data/contrib/zstd/lib/compress/zstd_fast.c +729 -265
  56. data/contrib/zstd/lib/compress/zstd_fast.h +3 -2
  57. data/contrib/zstd/lib/compress/zstd_lazy.c +1270 -251
  58. data/contrib/zstd/lib/compress/zstd_lazy.h +61 -1
  59. data/contrib/zstd/lib/compress/zstd_ldm.c +324 -219
  60. data/contrib/zstd/lib/compress/zstd_ldm.h +9 -2
  61. data/contrib/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
  62. data/contrib/zstd/lib/compress/zstd_opt.c +481 -209
  63. data/contrib/zstd/lib/compress/zstd_opt.h +1 -1
  64. data/contrib/zstd/lib/compress/zstdmt_compress.c +181 -457
  65. data/contrib/zstd/lib/compress/zstdmt_compress.h +34 -113
  66. data/contrib/zstd/lib/decompress/huf_decompress.c +1199 -565
  67. data/contrib/zstd/lib/decompress/huf_decompress_amd64.S +576 -0
  68. data/contrib/zstd/lib/decompress/zstd_ddict.c +12 -12
  69. data/contrib/zstd/lib/decompress/zstd_ddict.h +2 -2
  70. data/contrib/zstd/lib/decompress/zstd_decompress.c +627 -157
  71. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1086 -326
  72. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +19 -5
  73. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +62 -13
  74. data/contrib/zstd/lib/deprecated/zbuff.h +1 -1
  75. data/contrib/zstd/lib/deprecated/zbuff_common.c +1 -1
  76. data/contrib/zstd/lib/deprecated/zbuff_compress.c +24 -4
  77. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +3 -1
  78. data/contrib/zstd/lib/dictBuilder/cover.c +73 -52
  79. data/contrib/zstd/lib/dictBuilder/cover.h +7 -6
  80. data/contrib/zstd/lib/dictBuilder/divsufsort.c +1 -1
  81. data/contrib/zstd/lib/dictBuilder/fastcover.c +44 -35
  82. data/contrib/zstd/lib/dictBuilder/zdict.c +103 -111
  83. data/contrib/zstd/lib/legacy/zstd_legacy.h +8 -1
  84. data/contrib/zstd/lib/legacy/zstd_v01.c +21 -54
  85. data/contrib/zstd/lib/legacy/zstd_v01.h +1 -1
  86. data/contrib/zstd/lib/legacy/zstd_v02.c +29 -70
  87. data/contrib/zstd/lib/legacy/zstd_v02.h +1 -1
  88. data/contrib/zstd/lib/legacy/zstd_v03.c +30 -73
  89. data/contrib/zstd/lib/legacy/zstd_v03.h +1 -1
  90. data/contrib/zstd/lib/legacy/zstd_v04.c +29 -71
  91. data/contrib/zstd/lib/legacy/zstd_v04.h +1 -1
  92. data/contrib/zstd/lib/legacy/zstd_v05.c +40 -86
  93. data/contrib/zstd/lib/legacy/zstd_v05.h +1 -1
  94. data/contrib/zstd/lib/legacy/zstd_v06.c +47 -88
  95. data/contrib/zstd/lib/legacy/zstd_v06.h +1 -1
  96. data/contrib/zstd/lib/legacy/zstd_v07.c +40 -83
  97. data/contrib/zstd/lib/legacy/zstd_v07.h +1 -1
  98. data/contrib/zstd/lib/libzstd.mk +214 -0
  99. data/contrib/zstd/lib/libzstd.pc.in +7 -6
  100. data/contrib/zstd/lib/module.modulemap +35 -0
  101. data/contrib/zstd/lib/{dictBuilder/zdict.h → zdict.h} +203 -34
  102. data/contrib/zstd/lib/zstd.h +1217 -287
  103. data/contrib/zstd/lib/{common/zstd_errors.h → zstd_errors.h} +28 -8
  104. data/ext/extconf.rb +7 -6
  105. data/ext/extzstd.c +19 -10
  106. data/ext/extzstd.h +6 -0
  107. data/ext/libzstd_conf.h +0 -1
  108. data/ext/zstd_decompress_asm.S +1 -0
  109. data/gemstub.rb +3 -21
  110. data/lib/extzstd/version.rb +6 -1
  111. data/lib/extzstd.rb +0 -2
  112. data/test/test_basic.rb +0 -5
  113. metadata +18 -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
@@ -11,6 +11,8 @@
11
11
  #ifndef ZSTD_COMPILER_H
12
12
  #define ZSTD_COMPILER_H
13
13
 
14
+ #include "portability_macros.h"
15
+
14
16
  /*-*******************************************************
15
17
  * Compiler specifics
16
18
  *********************************************************/
@@ -38,6 +40,17 @@
38
40
 
39
41
  #endif
40
42
 
43
+ /**
44
+ On MSVC qsort requires that functions passed into it use the __cdecl calling conversion(CC).
45
+ This explicitly marks such functions as __cdecl so that the code will still compile
46
+ if a CC other than __cdecl has been made the default.
47
+ */
48
+ #if defined(_MSC_VER)
49
+ # define WIN_CDECL __cdecl
50
+ #else
51
+ # define WIN_CDECL
52
+ #endif
53
+
41
54
  /**
42
55
  * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
43
56
  * parameters. They must be inlined for the compiler to eliminate the constant
@@ -79,30 +92,19 @@
79
92
  # endif
80
93
  #endif
81
94
 
95
+
82
96
  /* target attribute */
83
- #ifndef __has_attribute
84
- #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
85
- #endif
86
97
  #if defined(__GNUC__) || defined(__ICCARM__)
87
98
  # define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
88
99
  #else
89
100
  # define TARGET_ATTRIBUTE(target)
90
101
  #endif
91
102
 
92
- /* Enable runtime BMI2 dispatch based on the CPU.
93
- * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
103
+ /* Target attribute for BMI2 dynamic dispatch.
104
+ * Enable lzcnt, bmi, and bmi2.
105
+ * We test for bmi1 & bmi2. lzcnt is included in bmi1.
94
106
  */
95
- #ifndef DYNAMIC_BMI2
96
- #if ((defined(__clang__) && __has_attribute(__target__)) \
97
- || (defined(__GNUC__) \
98
- && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
99
- && (defined(__x86_64__) || defined(_M_X86)) \
100
- && !defined(__BMI2__)
101
- # define DYNAMIC_BMI2 1
102
- #else
103
- # define DYNAMIC_BMI2 0
104
- #endif
105
- #endif
107
+ #define BMI2_TARGET_ATTRIBUTE TARGET_ATTRIBUTE("lzcnt,bmi,bmi2")
106
108
 
107
109
  /* prefetch
108
110
  * can be disabled, by declaring NO_PREFETCH build macro */
@@ -114,12 +116,12 @@
114
116
  # include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
115
117
  # define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
116
118
  # define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
117
- # elif defined(__aarch64__)
118
- # define PREFETCH_L1(ptr) __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr)))
119
- # define PREFETCH_L2(ptr) __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr)))
120
119
  # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
121
120
  # define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
122
121
  # define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
122
+ # elif defined(__aarch64__)
123
+ # define PREFETCH_L1(ptr) __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr)))
124
+ # define PREFETCH_L2(ptr) __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr)))
123
125
  # else
124
126
  # define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
125
127
  # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
@@ -138,8 +140,9 @@
138
140
  }
139
141
 
140
142
  /* vectorization
141
- * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */
142
- #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__)
143
+ * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax,
144
+ * and some compilers, like Intel ICC and MCST LCC, do not support it at all. */
145
+ #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && !defined(__LCC__)
143
146
  # if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5)
144
147
  # define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
145
148
  # else
@@ -162,6 +165,12 @@
162
165
  #define UNLIKELY(x) (x)
163
166
  #endif
164
167
 
168
+ #if __has_builtin(__builtin_unreachable) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
169
+ # define ZSTD_UNREACHABLE { assert(0), __builtin_unreachable(); }
170
+ #else
171
+ # define ZSTD_UNREACHABLE { assert(0); }
172
+ #endif
173
+
165
174
  /* disable warnings */
166
175
  #ifdef _MSC_VER /* Visual Studio */
167
176
  # include <intrin.h> /* For Visual 2005 */
@@ -172,4 +181,178 @@
172
181
  # pragma warning(disable : 4324) /* disable: C4324: padded structure */
173
182
  #endif
174
183
 
184
+ /*Like DYNAMIC_BMI2 but for compile time determination of BMI2 support*/
185
+ #ifndef STATIC_BMI2
186
+ # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))
187
+ # ifdef __AVX2__ //MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2
188
+ # define STATIC_BMI2 1
189
+ # endif
190
+ # elif defined(__BMI2__) && defined(__x86_64__) && defined(__GNUC__)
191
+ # define STATIC_BMI2 1
192
+ # endif
193
+ #endif
194
+
195
+ #ifndef STATIC_BMI2
196
+ #define STATIC_BMI2 0
197
+ #endif
198
+
199
+ /* compile time determination of SIMD support */
200
+ #if !defined(ZSTD_NO_INTRINSICS)
201
+ # if defined(__SSE2__) || defined(_M_AMD64) || (defined (_M_IX86) && defined(_M_IX86_FP) && (_M_IX86_FP >= 2))
202
+ # define ZSTD_ARCH_X86_SSE2
203
+ # endif
204
+ # if defined(__ARM_NEON) || defined(_M_ARM64)
205
+ # define ZSTD_ARCH_ARM_NEON
206
+ # endif
207
+ #
208
+ # if defined(ZSTD_ARCH_X86_SSE2)
209
+ # include <emmintrin.h>
210
+ # elif defined(ZSTD_ARCH_ARM_NEON)
211
+ # include <arm_neon.h>
212
+ # endif
213
+ #endif
214
+
215
+ /* C-language Attributes are added in C23. */
216
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201710L) && defined(__has_c_attribute)
217
+ # define ZSTD_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
218
+ #else
219
+ # define ZSTD_HAS_C_ATTRIBUTE(x) 0
220
+ #endif
221
+
222
+ /* Only use C++ attributes in C++. Some compilers report support for C++
223
+ * attributes when compiling with C.
224
+ */
225
+ #if defined(__cplusplus) && defined(__has_cpp_attribute)
226
+ # define ZSTD_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
227
+ #else
228
+ # define ZSTD_HAS_CPP_ATTRIBUTE(x) 0
229
+ #endif
230
+
231
+ /* Define ZSTD_FALLTHROUGH macro for annotating switch case with the 'fallthrough' attribute.
232
+ * - C23: https://en.cppreference.com/w/c/language/attributes/fallthrough
233
+ * - CPP17: https://en.cppreference.com/w/cpp/language/attributes/fallthrough
234
+ * - Else: __attribute__((__fallthrough__))
235
+ */
236
+ #ifndef ZSTD_FALLTHROUGH
237
+ # if ZSTD_HAS_C_ATTRIBUTE(fallthrough)
238
+ # define ZSTD_FALLTHROUGH [[fallthrough]]
239
+ # elif ZSTD_HAS_CPP_ATTRIBUTE(fallthrough)
240
+ # define ZSTD_FALLTHROUGH [[fallthrough]]
241
+ # elif __has_attribute(__fallthrough__)
242
+ /* Leading semicolon is to satisfy gcc-11 with -pedantic. Without the semicolon
243
+ * gcc complains about: a label can only be part of a statement and a declaration is not a statement.
244
+ */
245
+ # define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
246
+ # else
247
+ # define ZSTD_FALLTHROUGH
248
+ # endif
249
+ #endif
250
+
251
+ /*-**************************************************************
252
+ * Alignment check
253
+ *****************************************************************/
254
+
255
+ /* this test was initially positioned in mem.h,
256
+ * but this file is removed (or replaced) for linux kernel
257
+ * so it's now hosted in compiler.h,
258
+ * which remains valid for both user & kernel spaces.
259
+ */
260
+
261
+ #ifndef ZSTD_ALIGNOF
262
+ # if defined(__GNUC__) || defined(_MSC_VER)
263
+ /* covers gcc, clang & MSVC */
264
+ /* note : this section must come first, before C11,
265
+ * due to a limitation in the kernel source generator */
266
+ # define ZSTD_ALIGNOF(T) __alignof(T)
267
+
268
+ # elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
269
+ /* C11 support */
270
+ # include <stdalign.h>
271
+ # define ZSTD_ALIGNOF(T) alignof(T)
272
+
273
+ # else
274
+ /* No known support for alignof() - imperfect backup */
275
+ # define ZSTD_ALIGNOF(T) (sizeof(void*) < sizeof(T) ? sizeof(void*) : sizeof(T))
276
+
277
+ # endif
278
+ #endif /* ZSTD_ALIGNOF */
279
+
280
+ /*-**************************************************************
281
+ * Sanitizer
282
+ *****************************************************************/
283
+
284
+ /* Issue #3240 reports an ASAN failure on an llvm-mingw build. Out of an
285
+ * abundance of caution, disable our custom poisoning on mingw. */
286
+ #ifdef __MINGW32__
287
+ #ifndef ZSTD_ASAN_DONT_POISON_WORKSPACE
288
+ #define ZSTD_ASAN_DONT_POISON_WORKSPACE 1
289
+ #endif
290
+ #ifndef ZSTD_MSAN_DONT_POISON_WORKSPACE
291
+ #define ZSTD_MSAN_DONT_POISON_WORKSPACE 1
292
+ #endif
293
+ #endif
294
+
295
+ #if ZSTD_MEMORY_SANITIZER && !defined(ZSTD_MSAN_DONT_POISON_WORKSPACE)
296
+ /* Not all platforms that support msan provide sanitizers/msan_interface.h.
297
+ * We therefore declare the functions we need ourselves, rather than trying to
298
+ * include the header file... */
299
+ #include <stddef.h> /* size_t */
300
+ #define ZSTD_DEPS_NEED_STDINT
301
+ #include "zstd_deps.h" /* intptr_t */
302
+
303
+ /* Make memory region fully initialized (without changing its contents). */
304
+ void __msan_unpoison(const volatile void *a, size_t size);
305
+
306
+ /* Make memory region fully uninitialized (without changing its contents).
307
+ This is a legacy interface that does not update origin information. Use
308
+ __msan_allocated_memory() instead. */
309
+ void __msan_poison(const volatile void *a, size_t size);
310
+
311
+ /* Returns the offset of the first (at least partially) poisoned byte in the
312
+ memory range, or -1 if the whole range is good. */
313
+ intptr_t __msan_test_shadow(const volatile void *x, size_t size);
314
+
315
+ /* Print shadow and origin for the memory range to stderr in a human-readable
316
+ format. */
317
+ void __msan_print_shadow(const volatile void *x, size_t size);
318
+ #endif
319
+
320
+ #if ZSTD_ADDRESS_SANITIZER && !defined(ZSTD_ASAN_DONT_POISON_WORKSPACE)
321
+ /* Not all platforms that support asan provide sanitizers/asan_interface.h.
322
+ * We therefore declare the functions we need ourselves, rather than trying to
323
+ * include the header file... */
324
+ #include <stddef.h> /* size_t */
325
+
326
+ /**
327
+ * Marks a memory region (<c>[addr, addr+size)</c>) as unaddressable.
328
+ *
329
+ * This memory must be previously allocated by your program. Instrumented
330
+ * code is forbidden from accessing addresses in this region until it is
331
+ * unpoisoned. This function is not guaranteed to poison the entire region -
332
+ * it could poison only a subregion of <c>[addr, addr+size)</c> due to ASan
333
+ * alignment restrictions.
334
+ *
335
+ * \note This function is not thread-safe because no two threads can poison or
336
+ * unpoison memory in the same memory region simultaneously.
337
+ *
338
+ * \param addr Start of memory region.
339
+ * \param size Size of memory region. */
340
+ void __asan_poison_memory_region(void const volatile *addr, size_t size);
341
+
342
+ /**
343
+ * Marks a memory region (<c>[addr, addr+size)</c>) as addressable.
344
+ *
345
+ * This memory must be previously allocated by your program. Accessing
346
+ * addresses in this region is allowed until this region is poisoned again.
347
+ * This function could unpoison a super-region of <c>[addr, addr+size)</c> due
348
+ * to ASan alignment restrictions.
349
+ *
350
+ * \note This function is not thread-safe because no two threads can
351
+ * poison or unpoison memory in the same memory region simultaneously.
352
+ *
353
+ * \param addr Start of memory region.
354
+ * \param size Size of memory region. */
355
+ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
356
+ #endif
357
+
175
358
  #endif /* ZSTD_COMPILER_H */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2018-2020, 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
@@ -16,8 +16,6 @@
16
16
  * https://github.com/facebook/folly/blob/master/folly/CpuId.h
17
17
  */
18
18
 
19
- #include <string.h>
20
-
21
19
  #include "mem.h"
22
20
 
23
21
  #ifdef _MSC_VER
@@ -1,7 +1,7 @@
1
1
  /* ******************************************************************
2
2
  * debug
3
3
  * Part of FSE library
4
- * Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
6
6
  * You can contact the author at :
7
7
  * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
@@ -1,7 +1,7 @@
1
1
  /* ******************************************************************
2
2
  * debug
3
3
  * Part of FSE library
4
- * Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
6
6
  * You can contact the author at :
7
7
  * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
@@ -51,15 +51,6 @@ extern "C" {
51
51
  #endif
52
52
 
53
53
 
54
- /* DEBUGFILE can be defined externally,
55
- * typically through compiler command line.
56
- * note : currently useless.
57
- * Value must be stderr or stdout */
58
- #ifndef DEBUGFILE
59
- # define DEBUGFILE stderr
60
- #endif
61
-
62
-
63
54
  /* recommended values for DEBUGLEVEL :
64
55
  * 0 : release mode, no debug, all run-time checks disabled
65
56
  * 1 : enables assert() only, no display
@@ -76,7 +67,8 @@ extern "C" {
76
67
  */
77
68
 
78
69
  #if (DEBUGLEVEL>=1)
79
- # include <assert.h>
70
+ # define ZSTD_DEPS_NEED_ASSERT
71
+ # include "zstd_deps.h"
80
72
  #else
81
73
  # ifndef assert /* assert may be already defined, due to prior #include <assert.h> */
82
74
  # define assert(condition) ((void)0) /* disable assert (default) */
@@ -84,7 +76,8 @@ extern "C" {
84
76
  #endif
85
77
 
86
78
  #if (DEBUGLEVEL>=2)
87
- # include <stdio.h>
79
+ # define ZSTD_DEPS_NEED_IO
80
+ # include "zstd_deps.h"
88
81
  extern int g_debuglevel; /* the variable is only declared,
89
82
  it actually lives in debug.c,
90
83
  and is shared by the whole process.
@@ -92,14 +85,14 @@ extern int g_debuglevel; /* the variable is only declared,
92
85
  It's useful when enabling very verbose levels
93
86
  on selective conditions (such as position in src) */
94
87
 
95
- # define RAWLOG(l, ...) { \
96
- if (l<=g_debuglevel) { \
97
- fprintf(stderr, __VA_ARGS__); \
88
+ # define RAWLOG(l, ...) { \
89
+ if (l<=g_debuglevel) { \
90
+ ZSTD_DEBUG_PRINT(__VA_ARGS__); \
98
91
  } }
99
- # define DEBUGLOG(l, ...) { \
100
- if (l<=g_debuglevel) { \
101
- fprintf(stderr, __FILE__ ": " __VA_ARGS__); \
102
- fprintf(stderr, " \n"); \
92
+ # define DEBUGLOG(l, ...) { \
93
+ if (l<=g_debuglevel) { \
94
+ ZSTD_DEBUG_PRINT(__FILE__ ": " __VA_ARGS__); \
95
+ ZSTD_DEBUG_PRINT(" \n"); \
103
96
  } }
104
97
  #else
105
98
  # define RAWLOG(l, ...) {} /* disabled */