zstdlib 0.7.0-x64-mingw32 → 0.10.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +20 -0
- data/README.md +7 -1
- data/Rakefile +38 -8
- data/ext/{zstdlib → zstdlib_c}/extconf.rb +11 -6
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.2/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.3/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.4/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.5/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.6/zstdlib.c +2 -2
- data/ext/{zstdlib → zstdlib_c}/ruby/zlib-2.7/zstdlib.c +2 -2
- data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/adler32.c +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/compress.c +0 -0
- data/ext/zstdlib_c/zlib-1.2.12/crc32.c +1116 -0
- data/ext/zstdlib_c/zlib-1.2.12/crc32.h +9446 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/deflate.c +78 -30
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/deflate.h +12 -15
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzclose.c +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzguts.h +3 -2
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzlib.c +5 -3
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzread.c +5 -7
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/gzwrite.c +25 -13
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/infback.c +2 -1
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inffast.c +14 -14
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inffast.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inffixed.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inflate.c +39 -8
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inflate.h +3 -2
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inftrees.c +3 -3
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/inftrees.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/trees.c +27 -48
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/trees.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/uncompr.c +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zconf.h +0 -0
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zlib.h +123 -100
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zutil.c +2 -2
- data/ext/{zstdlib/zlib-1.2.11 → zstdlib_c/zlib-1.2.12}/zutil.h +12 -9
- data/ext/{zstdlib → zstdlib_c}/zlib.mk +0 -0
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper/zlibwrapper.c +1 -5
- data/ext/{zstdlib → zstdlib_c}/zlibwrapper.mk +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/bitstream.h +46 -22
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/compiler.h +335 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/cpu.h +1 -3
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/debug.c +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/debug.h +12 -19
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/entropy_common.c +368 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/error_private.c +2 -1
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.h +159 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/fse.h +41 -12
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/fse_decompress.c +139 -22
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/huf.h +47 -23
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/mem.h +87 -98
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/pool.c +34 -23
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/pool.h +4 -4
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/threading.c +6 -5
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/threading.h +0 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_common.c +10 -10
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_deps.h +111 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/common/zstd_internal.h +191 -145
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/fse_compress.c +89 -46
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.c +27 -29
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/hist.h +2 -2
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/huf_compress.c +1370 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress.c +2917 -868
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_internal.h +458 -125
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.c +12 -11
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_literals.h +4 -2
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.c +41 -18
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_sequences.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.c +26 -298
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_compress_superblock.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_cwksp.h +234 -83
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.c +313 -138
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_double_fast.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.c +329 -150
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_fast.h +1 -1
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.c +2104 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.h +125 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.c +321 -216
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_ldm.h +9 -2
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.c +412 -166
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstd_opt.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/compress/zstdmt_compress.c +169 -453
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.h +113 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/huf_decompress.c +1044 -403
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.c +9 -9
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_ddict.h +2 -2
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress.c +450 -105
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.c +913 -273
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_block.h +14 -5
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/decompress/zstd_decompress_internal.h +59 -12
- data/ext/zstdlib_c/zstd-1.5.2/lib/zdict.h +452 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/lib/zstd.h +699 -214
- data/ext/{zstdlib/zstd-1.4.5/lib/common → zstdlib_c/zstd-1.5.2/lib}/zstd_errors.h +2 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzclose.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzcompatibility.h +1 -1
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzguts.h +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzlib.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzread.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/gzwrite.c +0 -0
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.c +133 -44
- data/ext/{zstdlib/zstd-1.4.5 → zstdlib_c/zstd-1.5.2}/zlibWrapper/zstd_zlibwrapper.h +1 -1
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/2.4/zstdlib_c.so +0 -0
- data/lib/2.5/zstdlib_c.so +0 -0
- data/lib/2.6/zstdlib_c.so +0 -0
- data/lib/2.7/zstdlib_c.so +0 -0
- data/lib/3.0/zstdlib_c.so +0 -0
- data/lib/zstdlib.rb +2 -2
- metadata +124 -116
- data/ext/zstdlib/zlib-1.2.11/crc32.c +0 -442
- data/ext/zstdlib/zlib-1.2.11/crc32.h +0 -441
- data/ext/zstdlib/zstd-1.4.5/lib/common/compiler.h +0 -175
- data/ext/zstdlib/zstd-1.4.5/lib/common/entropy_common.c +0 -216
- data/ext/zstdlib/zstd-1.4.5/lib/common/error_private.h +0 -80
- data/ext/zstdlib/zstd-1.4.5/lib/common/xxhash.c +0 -864
- data/ext/zstdlib/zstd-1.4.5/lib/common/xxhash.h +0 -285
- data/ext/zstdlib/zstd-1.4.5/lib/compress/huf_compress.c +0 -798
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.c +0 -1138
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.h +0 -67
- data/ext/zstdlib/zstd-1.4.5/lib/compress/zstdmt_compress.h +0 -192
- data/ext/zstdlib/zstd.mk +0 -14
- data/lib/2.2/zstdlib.so +0 -0
- data/lib/2.3/zstdlib.so +0 -0
- data/lib/2.4/zstdlib.so +0 -0
- data/lib/2.5/zstdlib.so +0 -0
- data/lib/2.6/zstdlib.so +0 -0
- data/lib/2.7/zstdlib.so +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
/* ******************************************************************
|
2
2
|
* bitstream
|
3
3
|
* Part of FSE library
|
4
|
-
* Copyright (c)
|
4
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
5
5
|
*
|
6
6
|
* You can contact the author at :
|
7
7
|
* - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
@@ -17,7 +17,6 @@
|
|
17
17
|
#if defined (__cplusplus)
|
18
18
|
extern "C" {
|
19
19
|
#endif
|
20
|
-
|
21
20
|
/*
|
22
21
|
* This API consists of small unitary functions, which must be inlined for best performance.
|
23
22
|
* Since link-time-optimization is not available for all compilers,
|
@@ -36,10 +35,12 @@ extern "C" {
|
|
36
35
|
/*=========================================
|
37
36
|
* Target specific
|
38
37
|
=========================================*/
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
38
|
+
#ifndef ZSTD_NO_INTRINSICS
|
39
|
+
# if defined(__BMI__) && defined(__GNUC__)
|
40
|
+
# include <immintrin.h> /* support for bextr (experimental) */
|
41
|
+
# elif defined(__ICCARM__)
|
42
|
+
# include <intrinsics.h>
|
43
|
+
# endif
|
43
44
|
#endif
|
44
45
|
|
45
46
|
#define STREAM_ACCUMULATOR_MIN_32 25
|
@@ -141,8 +142,18 @@ MEM_STATIC unsigned BIT_highbit32 (U32 val)
|
|
141
142
|
assert(val != 0);
|
142
143
|
{
|
143
144
|
# if defined(_MSC_VER) /* Visual */
|
144
|
-
|
145
|
-
|
145
|
+
# if STATIC_BMI2 == 1
|
146
|
+
return _lzcnt_u32(val) ^ 31;
|
147
|
+
# else
|
148
|
+
if (val != 0) {
|
149
|
+
unsigned long r;
|
150
|
+
_BitScanReverse(&r, val);
|
151
|
+
return (unsigned)r;
|
152
|
+
} else {
|
153
|
+
/* Should not reach this code path */
|
154
|
+
__assume(0);
|
155
|
+
}
|
156
|
+
# endif
|
146
157
|
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
|
147
158
|
return __builtin_clz (val) ^ 31;
|
148
159
|
# elif defined(__ICCARM__) /* IAR Intrinsic */
|
@@ -198,7 +209,7 @@ MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
|
|
198
209
|
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
|
199
210
|
size_t value, unsigned nbBits)
|
200
211
|
{
|
201
|
-
|
212
|
+
DEBUG_STATIC_ASSERT(BIT_MASK_SIZE == 32);
|
202
213
|
assert(nbBits < BIT_MASK_SIZE);
|
203
214
|
assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
204
215
|
bitC->bitContainer |= (value & BIT_mask[nbBits]) << bitC->bitPos;
|
@@ -271,7 +282,7 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC)
|
|
271
282
|
*/
|
272
283
|
MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize)
|
273
284
|
{
|
274
|
-
if (srcSize < 1) {
|
285
|
+
if (srcSize < 1) { ZSTD_memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
|
275
286
|
|
276
287
|
bitD->start = (const char*)srcBuffer;
|
277
288
|
bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
|
@@ -288,22 +299,22 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
|
|
288
299
|
switch(srcSize)
|
289
300
|
{
|
290
301
|
case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
|
291
|
-
|
302
|
+
ZSTD_FALLTHROUGH;
|
292
303
|
|
293
304
|
case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
|
294
|
-
|
305
|
+
ZSTD_FALLTHROUGH;
|
295
306
|
|
296
307
|
case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
|
297
|
-
|
308
|
+
ZSTD_FALLTHROUGH;
|
298
309
|
|
299
310
|
case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
|
300
|
-
|
311
|
+
ZSTD_FALLTHROUGH;
|
301
312
|
|
302
313
|
case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
|
303
|
-
|
314
|
+
ZSTD_FALLTHROUGH;
|
304
315
|
|
305
316
|
case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
|
306
|
-
|
317
|
+
ZSTD_FALLTHROUGH;
|
307
318
|
|
308
319
|
default: break;
|
309
320
|
}
|
@@ -317,23 +328,36 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
|
|
317
328
|
return srcSize;
|
318
329
|
}
|
319
330
|
|
320
|
-
MEM_STATIC size_t BIT_getUpperBits(size_t bitContainer, U32 const start)
|
331
|
+
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getUpperBits(size_t bitContainer, U32 const start)
|
321
332
|
{
|
322
333
|
return bitContainer >> start;
|
323
334
|
}
|
324
335
|
|
325
|
-
MEM_STATIC size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits)
|
336
|
+
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits)
|
326
337
|
{
|
327
338
|
U32 const regMask = sizeof(bitContainer)*8 - 1;
|
328
339
|
/* if start > regMask, bitstream is corrupted, and result is undefined */
|
329
340
|
assert(nbBits < BIT_MASK_SIZE);
|
341
|
+
/* x86 transform & ((1 << nbBits) - 1) to bzhi instruction, it is better
|
342
|
+
* than accessing memory. When bmi2 instruction is not present, we consider
|
343
|
+
* such cpus old (pre-Haswell, 2013) and their performance is not of that
|
344
|
+
* importance.
|
345
|
+
*/
|
346
|
+
#if defined(__x86_64__) || defined(_M_X86)
|
347
|
+
return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1);
|
348
|
+
#else
|
330
349
|
return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
|
350
|
+
#endif
|
331
351
|
}
|
332
352
|
|
333
|
-
MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
|
353
|
+
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
|
334
354
|
{
|
355
|
+
#if defined(STATIC_BMI2) && STATIC_BMI2 == 1
|
356
|
+
return _bzhi_u64(bitContainer, nbBits);
|
357
|
+
#else
|
335
358
|
assert(nbBits < BIT_MASK_SIZE);
|
336
359
|
return bitContainer & BIT_mask[nbBits];
|
360
|
+
#endif
|
337
361
|
}
|
338
362
|
|
339
363
|
/*! BIT_lookBits() :
|
@@ -342,7 +366,7 @@ MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
|
|
342
366
|
* On 32-bits, maxNbBits==24.
|
343
367
|
* On 64-bits, maxNbBits==56.
|
344
368
|
* @return : value extracted */
|
345
|
-
MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t*
|
369
|
+
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
|
346
370
|
{
|
347
371
|
/* arbitrate between double-shift and shift+mask */
|
348
372
|
#if 1
|
@@ -365,7 +389,7 @@ MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
|
|
365
389
|
return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
|
366
390
|
}
|
367
391
|
|
368
|
-
MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
|
392
|
+
MEM_STATIC FORCE_INLINE_ATTR void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
|
369
393
|
{
|
370
394
|
bitD->bitsConsumed += nbBits;
|
371
395
|
}
|
@@ -374,7 +398,7 @@ MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
374
398
|
* Read (consume) next n bits from local register and update.
|
375
399
|
* Pay attention to not read more than nbBits contained into local register.
|
376
400
|
* @return : extracted value. */
|
377
|
-
MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
|
401
|
+
MEM_STATIC FORCE_INLINE_ATTR size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
|
378
402
|
{
|
379
403
|
size_t const value = BIT_lookBits(bitD, nbBits);
|
380
404
|
BIT_skipBits(bitD, nbBits);
|
@@ -0,0 +1,335 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) Yann Collet, 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_COMPILER_H
|
12
|
+
#define ZSTD_COMPILER_H
|
13
|
+
|
14
|
+
#include "portability_macros.h"
|
15
|
+
|
16
|
+
/*-*******************************************************
|
17
|
+
* Compiler specifics
|
18
|
+
*********************************************************/
|
19
|
+
/* force inlining */
|
20
|
+
|
21
|
+
#if !defined(ZSTD_NO_INLINE)
|
22
|
+
#if (defined(__GNUC__) && !defined(__STRICT_ANSI__)) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
23
|
+
# define INLINE_KEYWORD inline
|
24
|
+
#else
|
25
|
+
# define INLINE_KEYWORD
|
26
|
+
#endif
|
27
|
+
|
28
|
+
#if defined(__GNUC__) || defined(__ICCARM__)
|
29
|
+
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
30
|
+
#elif defined(_MSC_VER)
|
31
|
+
# define FORCE_INLINE_ATTR __forceinline
|
32
|
+
#else
|
33
|
+
# define FORCE_INLINE_ATTR
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#else
|
37
|
+
|
38
|
+
#define INLINE_KEYWORD
|
39
|
+
#define FORCE_INLINE_ATTR
|
40
|
+
|
41
|
+
#endif
|
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
|
+
|
54
|
+
/**
|
55
|
+
* FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
|
56
|
+
* parameters. They must be inlined for the compiler to eliminate the constant
|
57
|
+
* branches.
|
58
|
+
*/
|
59
|
+
#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
60
|
+
/**
|
61
|
+
* HINT_INLINE is used to help the compiler generate better code. It is *not*
|
62
|
+
* used for "templates", so it can be tweaked based on the compilers
|
63
|
+
* performance.
|
64
|
+
*
|
65
|
+
* gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the
|
66
|
+
* always_inline attribute.
|
67
|
+
*
|
68
|
+
* clang up to 5.0.0 (trunk) benefit tremendously from the always_inline
|
69
|
+
* attribute.
|
70
|
+
*/
|
71
|
+
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
|
72
|
+
# define HINT_INLINE static INLINE_KEYWORD
|
73
|
+
#else
|
74
|
+
# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
75
|
+
#endif
|
76
|
+
|
77
|
+
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
78
|
+
#if defined(__GNUC__)
|
79
|
+
# define UNUSED_ATTR __attribute__((unused))
|
80
|
+
#else
|
81
|
+
# define UNUSED_ATTR
|
82
|
+
#endif
|
83
|
+
|
84
|
+
/* force no inlining */
|
85
|
+
#ifdef _MSC_VER
|
86
|
+
# define FORCE_NOINLINE static __declspec(noinline)
|
87
|
+
#else
|
88
|
+
# if defined(__GNUC__) || defined(__ICCARM__)
|
89
|
+
# define FORCE_NOINLINE static __attribute__((__noinline__))
|
90
|
+
# else
|
91
|
+
# define FORCE_NOINLINE static
|
92
|
+
# endif
|
93
|
+
#endif
|
94
|
+
|
95
|
+
|
96
|
+
/* target attribute */
|
97
|
+
#if defined(__GNUC__) || defined(__ICCARM__)
|
98
|
+
# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
|
99
|
+
#else
|
100
|
+
# define TARGET_ATTRIBUTE(target)
|
101
|
+
#endif
|
102
|
+
|
103
|
+
/* Target attribute for BMI2 dynamic dispatch.
|
104
|
+
* Enable lzcnt, bmi, and bmi2.
|
105
|
+
* We test for bmi1 & bmi2. lzcnt is included in bmi1.
|
106
|
+
*/
|
107
|
+
#define BMI2_TARGET_ATTRIBUTE TARGET_ATTRIBUTE("lzcnt,bmi,bmi2")
|
108
|
+
|
109
|
+
/* prefetch
|
110
|
+
* can be disabled, by declaring NO_PREFETCH build macro */
|
111
|
+
#if defined(NO_PREFETCH)
|
112
|
+
# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
|
113
|
+
# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
|
114
|
+
#else
|
115
|
+
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
|
116
|
+
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
|
117
|
+
# define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
|
118
|
+
# define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
|
119
|
+
# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
|
120
|
+
# define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
|
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)))
|
125
|
+
# else
|
126
|
+
# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
|
127
|
+
# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
|
128
|
+
# endif
|
129
|
+
#endif /* NO_PREFETCH */
|
130
|
+
|
131
|
+
#define CACHELINE_SIZE 64
|
132
|
+
|
133
|
+
#define PREFETCH_AREA(p, s) { \
|
134
|
+
const char* const _ptr = (const char*)(p); \
|
135
|
+
size_t const _size = (size_t)(s); \
|
136
|
+
size_t _pos; \
|
137
|
+
for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
|
138
|
+
PREFETCH_L2(_ptr + _pos); \
|
139
|
+
} \
|
140
|
+
}
|
141
|
+
|
142
|
+
/* vectorization
|
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__)
|
146
|
+
# if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5)
|
147
|
+
# define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
|
148
|
+
# else
|
149
|
+
# define DONT_VECTORIZE _Pragma("GCC optimize(\"no-tree-vectorize\")")
|
150
|
+
# endif
|
151
|
+
#else
|
152
|
+
# define DONT_VECTORIZE
|
153
|
+
#endif
|
154
|
+
|
155
|
+
/* Tell the compiler that a branch is likely or unlikely.
|
156
|
+
* Only use these macros if it causes the compiler to generate better code.
|
157
|
+
* If you can remove a LIKELY/UNLIKELY annotation without speed changes in gcc
|
158
|
+
* and clang, please do.
|
159
|
+
*/
|
160
|
+
#if defined(__GNUC__)
|
161
|
+
#define LIKELY(x) (__builtin_expect((x), 1))
|
162
|
+
#define UNLIKELY(x) (__builtin_expect((x), 0))
|
163
|
+
#else
|
164
|
+
#define LIKELY(x) (x)
|
165
|
+
#define UNLIKELY(x) (x)
|
166
|
+
#endif
|
167
|
+
|
168
|
+
/* disable warnings */
|
169
|
+
#ifdef _MSC_VER /* Visual Studio */
|
170
|
+
# include <intrin.h> /* For Visual 2005 */
|
171
|
+
# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
|
172
|
+
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
173
|
+
# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
|
174
|
+
# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */
|
175
|
+
# pragma warning(disable : 4324) /* disable: C4324: padded structure */
|
176
|
+
#endif
|
177
|
+
|
178
|
+
/*Like DYNAMIC_BMI2 but for compile time determination of BMI2 support*/
|
179
|
+
#ifndef STATIC_BMI2
|
180
|
+
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))
|
181
|
+
# ifdef __AVX2__ //MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2
|
182
|
+
# define STATIC_BMI2 1
|
183
|
+
# endif
|
184
|
+
# endif
|
185
|
+
#endif
|
186
|
+
|
187
|
+
#ifndef STATIC_BMI2
|
188
|
+
#define STATIC_BMI2 0
|
189
|
+
#endif
|
190
|
+
|
191
|
+
/* compile time determination of SIMD support */
|
192
|
+
#if !defined(ZSTD_NO_INTRINSICS)
|
193
|
+
# if defined(__SSE2__) || defined(_M_AMD64) || (defined (_M_IX86) && defined(_M_IX86_FP) && (_M_IX86_FP >= 2))
|
194
|
+
# define ZSTD_ARCH_X86_SSE2
|
195
|
+
# endif
|
196
|
+
# if defined(__ARM_NEON) || defined(_M_ARM64)
|
197
|
+
# define ZSTD_ARCH_ARM_NEON
|
198
|
+
# endif
|
199
|
+
#
|
200
|
+
# if defined(ZSTD_ARCH_X86_SSE2)
|
201
|
+
# include <emmintrin.h>
|
202
|
+
# elif defined(ZSTD_ARCH_ARM_NEON)
|
203
|
+
# include <arm_neon.h>
|
204
|
+
# endif
|
205
|
+
#endif
|
206
|
+
|
207
|
+
/* C-language Attributes are added in C23. */
|
208
|
+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201710L) && defined(__has_c_attribute)
|
209
|
+
# define ZSTD_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
|
210
|
+
#else
|
211
|
+
# define ZSTD_HAS_C_ATTRIBUTE(x) 0
|
212
|
+
#endif
|
213
|
+
|
214
|
+
/* Only use C++ attributes in C++. Some compilers report support for C++
|
215
|
+
* attributes when compiling with C.
|
216
|
+
*/
|
217
|
+
#if defined(__cplusplus) && defined(__has_cpp_attribute)
|
218
|
+
# define ZSTD_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
219
|
+
#else
|
220
|
+
# define ZSTD_HAS_CPP_ATTRIBUTE(x) 0
|
221
|
+
#endif
|
222
|
+
|
223
|
+
/* Define ZSTD_FALLTHROUGH macro for annotating switch case with the 'fallthrough' attribute.
|
224
|
+
* - C23: https://en.cppreference.com/w/c/language/attributes/fallthrough
|
225
|
+
* - CPP17: https://en.cppreference.com/w/cpp/language/attributes/fallthrough
|
226
|
+
* - Else: __attribute__((__fallthrough__))
|
227
|
+
*/
|
228
|
+
#ifndef ZSTD_FALLTHROUGH
|
229
|
+
# if ZSTD_HAS_C_ATTRIBUTE(fallthrough)
|
230
|
+
# define ZSTD_FALLTHROUGH [[fallthrough]]
|
231
|
+
# elif ZSTD_HAS_CPP_ATTRIBUTE(fallthrough)
|
232
|
+
# define ZSTD_FALLTHROUGH [[fallthrough]]
|
233
|
+
# elif __has_attribute(__fallthrough__)
|
234
|
+
/* Leading semicolon is to satisfy gcc-11 with -pedantic. Without the semicolon
|
235
|
+
* gcc complains about: a label can only be part of a statement and a declaration is not a statement.
|
236
|
+
*/
|
237
|
+
# define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
|
238
|
+
# else
|
239
|
+
# define ZSTD_FALLTHROUGH
|
240
|
+
# endif
|
241
|
+
#endif
|
242
|
+
|
243
|
+
/*-**************************************************************
|
244
|
+
* Alignment check
|
245
|
+
*****************************************************************/
|
246
|
+
|
247
|
+
/* this test was initially positioned in mem.h,
|
248
|
+
* but this file is removed (or replaced) for linux kernel
|
249
|
+
* so it's now hosted in compiler.h,
|
250
|
+
* which remains valid for both user & kernel spaces.
|
251
|
+
*/
|
252
|
+
|
253
|
+
#ifndef ZSTD_ALIGNOF
|
254
|
+
# if defined(__GNUC__) || defined(_MSC_VER)
|
255
|
+
/* covers gcc, clang & MSVC */
|
256
|
+
/* note : this section must come first, before C11,
|
257
|
+
* due to a limitation in the kernel source generator */
|
258
|
+
# define ZSTD_ALIGNOF(T) __alignof(T)
|
259
|
+
|
260
|
+
# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
261
|
+
/* C11 support */
|
262
|
+
# include <stdalign.h>
|
263
|
+
# define ZSTD_ALIGNOF(T) alignof(T)
|
264
|
+
|
265
|
+
# else
|
266
|
+
/* No known support for alignof() - imperfect backup */
|
267
|
+
# define ZSTD_ALIGNOF(T) (sizeof(void*) < sizeof(T) ? sizeof(void*) : sizeof(T))
|
268
|
+
|
269
|
+
# endif
|
270
|
+
#endif /* ZSTD_ALIGNOF */
|
271
|
+
|
272
|
+
/*-**************************************************************
|
273
|
+
* Sanitizer
|
274
|
+
*****************************************************************/
|
275
|
+
|
276
|
+
#if ZSTD_MEMORY_SANITIZER
|
277
|
+
/* Not all platforms that support msan provide sanitizers/msan_interface.h.
|
278
|
+
* We therefore declare the functions we need ourselves, rather than trying to
|
279
|
+
* include the header file... */
|
280
|
+
#include <stddef.h> /* size_t */
|
281
|
+
#define ZSTD_DEPS_NEED_STDINT
|
282
|
+
#include "zstd_deps.h" /* intptr_t */
|
283
|
+
|
284
|
+
/* Make memory region fully initialized (without changing its contents). */
|
285
|
+
void __msan_unpoison(const volatile void *a, size_t size);
|
286
|
+
|
287
|
+
/* Make memory region fully uninitialized (without changing its contents).
|
288
|
+
This is a legacy interface that does not update origin information. Use
|
289
|
+
__msan_allocated_memory() instead. */
|
290
|
+
void __msan_poison(const volatile void *a, size_t size);
|
291
|
+
|
292
|
+
/* Returns the offset of the first (at least partially) poisoned byte in the
|
293
|
+
memory range, or -1 if the whole range is good. */
|
294
|
+
intptr_t __msan_test_shadow(const volatile void *x, size_t size);
|
295
|
+
#endif
|
296
|
+
|
297
|
+
#if ZSTD_ADDRESS_SANITIZER
|
298
|
+
/* Not all platforms that support asan provide sanitizers/asan_interface.h.
|
299
|
+
* We therefore declare the functions we need ourselves, rather than trying to
|
300
|
+
* include the header file... */
|
301
|
+
#include <stddef.h> /* size_t */
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Marks a memory region (<c>[addr, addr+size)</c>) as unaddressable.
|
305
|
+
*
|
306
|
+
* This memory must be previously allocated by your program. Instrumented
|
307
|
+
* code is forbidden from accessing addresses in this region until it is
|
308
|
+
* unpoisoned. This function is not guaranteed to poison the entire region -
|
309
|
+
* it could poison only a subregion of <c>[addr, addr+size)</c> due to ASan
|
310
|
+
* alignment restrictions.
|
311
|
+
*
|
312
|
+
* \note This function is not thread-safe because no two threads can poison or
|
313
|
+
* unpoison memory in the same memory region simultaneously.
|
314
|
+
*
|
315
|
+
* \param addr Start of memory region.
|
316
|
+
* \param size Size of memory region. */
|
317
|
+
void __asan_poison_memory_region(void const volatile *addr, size_t size);
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Marks a memory region (<c>[addr, addr+size)</c>) as addressable.
|
321
|
+
*
|
322
|
+
* This memory must be previously allocated by your program. Accessing
|
323
|
+
* addresses in this region is allowed until this region is poisoned again.
|
324
|
+
* This function could unpoison a super-region of <c>[addr, addr+size)</c> due
|
325
|
+
* to ASan alignment restrictions.
|
326
|
+
*
|
327
|
+
* \note This function is not thread-safe because no two threads can
|
328
|
+
* poison or unpoison memory in the same memory region simultaneously.
|
329
|
+
*
|
330
|
+
* \param addr Start of memory region.
|
331
|
+
* \param size Size of memory region. */
|
332
|
+
void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
|
333
|
+
#endif
|
334
|
+
|
335
|
+
#endif /* ZSTD_COMPILER_H */
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) Facebook, Inc.
|
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)
|
4
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
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)
|
4
|
+
* Copyright (c) Yann Collet, Facebook, Inc.
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
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
|
-
|
102
|
-
|
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 */
|