zstdlib 0.14.0 → 0.15.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.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/ext/zstdlib_c/extconf.rb +1 -1
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/bits.h +92 -87
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/bitstream.h +26 -29
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/compiler.h +36 -22
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/cpu.h +1 -1
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/debug.h +0 -9
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/error_private.c +1 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/error_private.h +0 -10
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/fse.h +2 -17
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/fse_decompress.c +2 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/huf.h +0 -9
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/mem.h +7 -11
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/pool.h +0 -9
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/portability_macros.h +22 -9
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/threading.h +0 -8
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/xxhash.h +93 -19
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_deps.h +12 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_internal.h +1 -69
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_trace.h +5 -12
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/hist.c +10 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/hist.h +7 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress.c +1057 -367
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_internal.h +227 -125
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_literals.c +1 -1
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_sequences.c +7 -7
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_sequences.h +7 -6
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_superblock.c +17 -17
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_cwksp.h +41 -24
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_double_fast.c +58 -50
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_double_fast.h +4 -12
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_fast.c +91 -74
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_fast.h +4 -12
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_lazy.c +64 -64
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_lazy.h +30 -39
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_ldm.c +48 -33
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_ldm.h +6 -14
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_opt.c +55 -51
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_opt.h +8 -16
- data/ext/zstdlib_c/zstd-1.5.7/lib/compress/zstd_preSplit.c +238 -0
- data/ext/zstdlib_c/zstd-1.5.7/lib/compress/zstd_preSplit.h +33 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstdmt_compress.c +134 -93
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstdmt_compress.h +4 -15
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/huf_decompress_amd64.S +10 -3
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress.c +14 -11
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress_block.c +6 -12
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress_internal.h +5 -5
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/zdict.h +15 -8
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/zstd.h +241 -132
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/zstd_errors.h +1 -8
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzwrite.c +2 -1
- metadata +75 -73
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/allocations.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/debug.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/entropy_common.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/pool.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/threading.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/xxhash.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/common/zstd_common.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/clevels.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/fse_compress.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/huf_compress.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_literals.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_compress_superblock.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/compress/zstd_ldm_geartab.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/huf_decompress.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_ddict.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_ddict.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/lib/decompress/zstd_decompress_block.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzclose.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzcompatibility.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzguts.h +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzlib.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/gzread.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/zstd_zlibwrapper.c +0 -0
- data/ext/zstdlib_c/{zstd-1.5.6 → zstd-1.5.7}/zlibWrapper/zstd_zlibwrapper.h +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b06ef354315c37bf27ef276115ea483d2e3fcee8dddad067c4b2402078b5eb9
|
4
|
+
data.tar.gz: 556e551d97acd069cbf4bdd2a00f626030ddef21e40c817cfb2933616f897a70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8562c7c5d52ccfdc41ed0ae3ed58df30997f964b9549cdd0d4401d4c6813a1e114e8ae8504da8d4dbcf1861a368b1ca4608761c187ae5d56f710f8d11f0a2d8
|
7
|
+
data.tar.gz: 4394fb98bbba32adee610e7c9e4dbcd5e46cad567ffaab3d05819ed98000a454f052a96f4bcbcc38e6d0ee69344c5ae639fa28eadb92f8b98c6bf807e7cde1b3
|
data/CHANGES.md
CHANGED
data/ext/zstdlib_c/extconf.rb
CHANGED
@@ -28,27 +28,29 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
|
|
28
28
|
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
|
29
29
|
{
|
30
30
|
assert(val != 0);
|
31
|
-
#
|
32
|
-
#
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
#
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
31
|
+
#if defined(_MSC_VER)
|
32
|
+
# if STATIC_BMI2
|
33
|
+
return (unsigned)_tzcnt_u32(val);
|
34
|
+
# else
|
35
|
+
if (val != 0) {
|
36
|
+
unsigned long r;
|
37
|
+
_BitScanForward(&r, val);
|
38
|
+
return (unsigned)r;
|
39
|
+
} else {
|
40
|
+
__assume(0); /* Should not reach this code path */
|
41
|
+
}
|
42
|
+
# endif
|
43
|
+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
44
|
+
return (unsigned)__builtin_ctz(val);
|
45
|
+
#elif defined(__ICCARM__)
|
46
|
+
return (unsigned)__builtin_ctz(val);
|
47
|
+
#else
|
48
|
+
return ZSTD_countTrailingZeros32_fallback(val);
|
49
|
+
#endif
|
49
50
|
}
|
50
51
|
|
51
|
-
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val)
|
52
|
+
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val)
|
53
|
+
{
|
52
54
|
assert(val != 0);
|
53
55
|
{
|
54
56
|
static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
|
@@ -67,86 +69,89 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
|
|
67
69
|
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
|
68
70
|
{
|
69
71
|
assert(val != 0);
|
70
|
-
#
|
71
|
-
#
|
72
|
-
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
72
|
+
#if defined(_MSC_VER)
|
73
|
+
# if STATIC_BMI2
|
74
|
+
return (unsigned)_lzcnt_u32(val);
|
75
|
+
# else
|
76
|
+
if (val != 0) {
|
77
|
+
unsigned long r;
|
78
|
+
_BitScanReverse(&r, val);
|
79
|
+
return (unsigned)(31 - r);
|
80
|
+
} else {
|
81
|
+
__assume(0); /* Should not reach this code path */
|
82
|
+
}
|
83
|
+
# endif
|
84
|
+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
85
|
+
return (unsigned)__builtin_clz(val);
|
86
|
+
#elif defined(__ICCARM__)
|
87
|
+
return (unsigned)__builtin_clz(val);
|
88
|
+
#else
|
89
|
+
return ZSTD_countLeadingZeros32_fallback(val);
|
90
|
+
#endif
|
88
91
|
}
|
89
92
|
|
90
93
|
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
|
91
94
|
{
|
92
95
|
assert(val != 0);
|
93
|
-
#
|
94
|
-
#
|
95
|
-
|
96
|
-
#
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
96
|
+
#if defined(_MSC_VER) && defined(_WIN64)
|
97
|
+
# if STATIC_BMI2
|
98
|
+
return (unsigned)_tzcnt_u64(val);
|
99
|
+
# else
|
100
|
+
if (val != 0) {
|
101
|
+
unsigned long r;
|
102
|
+
_BitScanForward64(&r, val);
|
103
|
+
return (unsigned)r;
|
104
|
+
} else {
|
105
|
+
__assume(0); /* Should not reach this code path */
|
106
|
+
}
|
107
|
+
# endif
|
108
|
+
#elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
|
109
|
+
return (unsigned)__builtin_ctzll(val);
|
110
|
+
#elif defined(__ICCARM__)
|
111
|
+
return (unsigned)__builtin_ctzll(val);
|
112
|
+
#else
|
113
|
+
{
|
114
|
+
U32 mostSignificantWord = (U32)(val >> 32);
|
115
|
+
U32 leastSignificantWord = (U32)val;
|
116
|
+
if (leastSignificantWord == 0) {
|
117
|
+
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
|
118
|
+
} else {
|
119
|
+
return ZSTD_countTrailingZeros32(leastSignificantWord);
|
117
120
|
}
|
118
|
-
|
121
|
+
}
|
122
|
+
#endif
|
119
123
|
}
|
120
124
|
|
121
125
|
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
|
122
126
|
{
|
123
127
|
assert(val != 0);
|
124
|
-
#
|
125
|
-
#
|
126
|
-
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
#
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
128
|
+
#if defined(_MSC_VER) && defined(_WIN64)
|
129
|
+
# if STATIC_BMI2
|
130
|
+
return (unsigned)_lzcnt_u64(val);
|
131
|
+
# else
|
132
|
+
if (val != 0) {
|
133
|
+
unsigned long r;
|
134
|
+
_BitScanReverse64(&r, val);
|
135
|
+
return (unsigned)(63 - r);
|
136
|
+
} else {
|
137
|
+
__assume(0); /* Should not reach this code path */
|
138
|
+
}
|
139
|
+
# endif
|
140
|
+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
|
141
|
+
return (unsigned)(__builtin_clzll(val));
|
142
|
+
#elif defined(__ICCARM__)
|
143
|
+
return (unsigned)(__builtin_clzll(val));
|
144
|
+
#else
|
145
|
+
{
|
146
|
+
U32 mostSignificantWord = (U32)(val >> 32);
|
147
|
+
U32 leastSignificantWord = (U32)val;
|
148
|
+
if (mostSignificantWord == 0) {
|
149
|
+
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
|
150
|
+
} else {
|
151
|
+
return ZSTD_countLeadingZeros32(mostSignificantWord);
|
148
152
|
}
|
149
|
-
|
153
|
+
}
|
154
|
+
#endif
|
150
155
|
}
|
151
156
|
|
152
157
|
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
|
@@ -14,9 +14,6 @@
|
|
14
14
|
#ifndef BITSTREAM_H_MODULE
|
15
15
|
#define BITSTREAM_H_MODULE
|
16
16
|
|
17
|
-
#if defined (__cplusplus)
|
18
|
-
extern "C" {
|
19
|
-
#endif
|
20
17
|
/*
|
21
18
|
* This API consists of small unitary functions, which must be inlined for best performance.
|
22
19
|
* Since link-time-optimization is not available for all compilers,
|
@@ -32,7 +29,6 @@ extern "C" {
|
|
32
29
|
#include "error_private.h" /* error codes and messages */
|
33
30
|
#include "bits.h" /* ZSTD_highbit32 */
|
34
31
|
|
35
|
-
|
36
32
|
/*=========================================
|
37
33
|
* Target specific
|
38
34
|
=========================================*/
|
@@ -52,12 +48,13 @@ extern "C" {
|
|
52
48
|
/*-******************************************
|
53
49
|
* bitStream encoding API (write forward)
|
54
50
|
********************************************/
|
51
|
+
typedef size_t BitContainerType;
|
55
52
|
/* bitStream can mix input from multiple sources.
|
56
53
|
* A critical property of these streams is that they encode and decode in **reverse** direction.
|
57
54
|
* So the first bit sequence you add will be the last to be read, like a LIFO stack.
|
58
55
|
*/
|
59
56
|
typedef struct {
|
60
|
-
|
57
|
+
BitContainerType bitContainer;
|
61
58
|
unsigned bitPos;
|
62
59
|
char* startPtr;
|
63
60
|
char* ptr;
|
@@ -65,7 +62,7 @@ typedef struct {
|
|
65
62
|
} BIT_CStream_t;
|
66
63
|
|
67
64
|
MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity);
|
68
|
-
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
|
65
|
+
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, BitContainerType value, unsigned nbBits);
|
69
66
|
MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC);
|
70
67
|
MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
|
71
68
|
|
@@ -74,7 +71,7 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
|
|
74
71
|
* `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code.
|
75
72
|
*
|
76
73
|
* bits are first added to a local register.
|
77
|
-
* Local register is
|
74
|
+
* Local register is BitContainerType, 64-bits on 64-bits systems, or 32-bits on 32-bits systems.
|
78
75
|
* Writing data into memory is an explicit operation, performed by the flushBits function.
|
79
76
|
* Hence keep track how many bits are potentially stored into local register to avoid register overflow.
|
80
77
|
* After a flushBits, a maximum of 7 bits might still be stored into local register.
|
@@ -90,7 +87,6 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
|
|
90
87
|
/*-********************************************
|
91
88
|
* bitStream decoding API (read backward)
|
92
89
|
**********************************************/
|
93
|
-
typedef size_t BitContainerType;
|
94
90
|
typedef struct {
|
95
91
|
BitContainerType bitContainer;
|
96
92
|
unsigned bitsConsumed;
|
@@ -106,7 +102,7 @@ typedef enum { BIT_DStream_unfinished = 0, /* fully refilled */
|
|
106
102
|
} BIT_DStream_status; /* result of BIT_reloadDStream() */
|
107
103
|
|
108
104
|
MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize);
|
109
|
-
MEM_STATIC
|
105
|
+
MEM_STATIC BitContainerType BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
|
110
106
|
MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD);
|
111
107
|
MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
|
112
108
|
|
@@ -125,7 +121,7 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
|
|
125
121
|
/*-****************************************
|
126
122
|
* unsafe API
|
127
123
|
******************************************/
|
128
|
-
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC,
|
124
|
+
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, BitContainerType value, unsigned nbBits);
|
129
125
|
/* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */
|
130
126
|
|
131
127
|
MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC);
|
@@ -163,10 +159,15 @@ MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
|
|
163
159
|
return 0;
|
164
160
|
}
|
165
161
|
|
166
|
-
FORCE_INLINE_TEMPLATE
|
162
|
+
FORCE_INLINE_TEMPLATE BitContainerType BIT_getLowerBits(BitContainerType bitContainer, U32 const nbBits)
|
167
163
|
{
|
168
|
-
#if
|
169
|
-
|
164
|
+
#if STATIC_BMI2 && !defined(ZSTD_NO_INTRINSICS)
|
165
|
+
# if (defined(__x86_64__) || defined(_M_X64)) && !defined(__ILP32__)
|
166
|
+
return _bzhi_u64(bitContainer, nbBits);
|
167
|
+
# else
|
168
|
+
DEBUG_STATIC_ASSERT(sizeof(bitContainer) == sizeof(U32));
|
169
|
+
return _bzhi_u32(bitContainer, nbBits);
|
170
|
+
# endif
|
170
171
|
#else
|
171
172
|
assert(nbBits < BIT_MASK_SIZE);
|
172
173
|
return bitContainer & BIT_mask[nbBits];
|
@@ -177,7 +178,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_getLowerBits(size_t bitContainer, U32 const nbB
|
|
177
178
|
* can add up to 31 bits into `bitC`.
|
178
179
|
* Note : does not check for register overflow ! */
|
179
180
|
MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
|
180
|
-
|
181
|
+
BitContainerType value, unsigned nbBits)
|
181
182
|
{
|
182
183
|
DEBUG_STATIC_ASSERT(BIT_MASK_SIZE == 32);
|
183
184
|
assert(nbBits < BIT_MASK_SIZE);
|
@@ -190,7 +191,7 @@ MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
|
|
190
191
|
* works only if `value` is _clean_,
|
191
192
|
* meaning all high bits above nbBits are 0 */
|
192
193
|
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC,
|
193
|
-
|
194
|
+
BitContainerType value, unsigned nbBits)
|
194
195
|
{
|
195
196
|
assert((value>>nbBits) == 0);
|
196
197
|
assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
@@ -237,7 +238,7 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC)
|
|
237
238
|
BIT_addBitsFast(bitC, 1, 1); /* endMark */
|
238
239
|
BIT_flushBits(bitC);
|
239
240
|
if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */
|
240
|
-
return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
|
241
|
+
return (size_t)(bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
|
241
242
|
}
|
242
243
|
|
243
244
|
|
@@ -298,12 +299,12 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si
|
|
298
299
|
return srcSize;
|
299
300
|
}
|
300
301
|
|
301
|
-
FORCE_INLINE_TEMPLATE
|
302
|
+
FORCE_INLINE_TEMPLATE BitContainerType BIT_getUpperBits(BitContainerType bitContainer, U32 const start)
|
302
303
|
{
|
303
304
|
return bitContainer >> start;
|
304
305
|
}
|
305
306
|
|
306
|
-
FORCE_INLINE_TEMPLATE
|
307
|
+
FORCE_INLINE_TEMPLATE BitContainerType BIT_getMiddleBits(BitContainerType bitContainer, U32 const start, U32 const nbBits)
|
307
308
|
{
|
308
309
|
U32 const regMask = sizeof(bitContainer)*8 - 1;
|
309
310
|
/* if start > regMask, bitstream is corrupted, and result is undefined */
|
@@ -313,7 +314,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_getMiddleBits(BitContainerType bitContainer, U3
|
|
313
314
|
* such cpus old (pre-Haswell, 2013) and their performance is not of that
|
314
315
|
* importance.
|
315
316
|
*/
|
316
|
-
#if defined(__x86_64__) || defined(
|
317
|
+
#if defined(__x86_64__) || defined(_M_X64)
|
317
318
|
return (bitContainer >> (start & regMask)) & ((((U64)1) << nbBits) - 1);
|
318
319
|
#else
|
319
320
|
return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
|
@@ -326,7 +327,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_getMiddleBits(BitContainerType bitContainer, U3
|
|
326
327
|
* On 32-bits, maxNbBits==24.
|
327
328
|
* On 64-bits, maxNbBits==56.
|
328
329
|
* @return : value extracted */
|
329
|
-
FORCE_INLINE_TEMPLATE
|
330
|
+
FORCE_INLINE_TEMPLATE BitContainerType BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
|
330
331
|
{
|
331
332
|
/* arbitrate between double-shift and shift+mask */
|
332
333
|
#if 1
|
@@ -342,7 +343,7 @@ FORCE_INLINE_TEMPLATE size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits
|
|
342
343
|
|
343
344
|
/*! BIT_lookBitsFast() :
|
344
345
|
* unsafe version; only works if nbBits >= 1 */
|
345
|
-
MEM_STATIC
|
346
|
+
MEM_STATIC BitContainerType BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
|
346
347
|
{
|
347
348
|
U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
|
348
349
|
assert(nbBits >= 1);
|
@@ -358,18 +359,18 @@ FORCE_INLINE_TEMPLATE void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
358
359
|
* Read (consume) next n bits from local register and update.
|
359
360
|
* Pay attention to not read more than nbBits contained into local register.
|
360
361
|
* @return : extracted value. */
|
361
|
-
FORCE_INLINE_TEMPLATE
|
362
|
+
FORCE_INLINE_TEMPLATE BitContainerType BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
|
362
363
|
{
|
363
|
-
|
364
|
+
BitContainerType const value = BIT_lookBits(bitD, nbBits);
|
364
365
|
BIT_skipBits(bitD, nbBits);
|
365
366
|
return value;
|
366
367
|
}
|
367
368
|
|
368
369
|
/*! BIT_readBitsFast() :
|
369
370
|
* unsafe version; only works if nbBits >= 1 */
|
370
|
-
MEM_STATIC
|
371
|
+
MEM_STATIC BitContainerType BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
|
371
372
|
{
|
372
|
-
|
373
|
+
BitContainerType const value = BIT_lookBitsFast(bitD, nbBits);
|
373
374
|
assert(nbBits >= 1);
|
374
375
|
BIT_skipBits(bitD, nbBits);
|
375
376
|
return value;
|
@@ -450,8 +451,4 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
|
|
450
451
|
return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
|
451
452
|
}
|
452
453
|
|
453
|
-
#if defined (__cplusplus)
|
454
|
-
}
|
455
|
-
#endif
|
456
|
-
|
457
454
|
#endif /* BITSTREAM_H_MODULE */
|
@@ -27,7 +27,7 @@
|
|
27
27
|
# define INLINE_KEYWORD
|
28
28
|
#endif
|
29
29
|
|
30
|
-
#if defined(__GNUC__) || defined(
|
30
|
+
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
31
31
|
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
32
32
|
#elif defined(_MSC_VER)
|
33
33
|
# define FORCE_INLINE_ATTR __forceinline
|
@@ -54,7 +54,7 @@
|
|
54
54
|
#endif
|
55
55
|
|
56
56
|
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
57
|
-
#if defined(__GNUC__)
|
57
|
+
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
58
58
|
# define UNUSED_ATTR __attribute__((unused))
|
59
59
|
#else
|
60
60
|
# define UNUSED_ATTR
|
@@ -95,6 +95,8 @@
|
|
95
95
|
#ifndef MEM_STATIC /* already defined in Linux Kernel mem.h */
|
96
96
|
#if defined(__GNUC__)
|
97
97
|
# define MEM_STATIC static __inline UNUSED_ATTR
|
98
|
+
#elif defined(__IAR_SYSTEMS_ICC__)
|
99
|
+
# define MEM_STATIC static inline UNUSED_ATTR
|
98
100
|
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
99
101
|
# define MEM_STATIC static inline
|
100
102
|
#elif defined(_MSC_VER)
|
@@ -108,7 +110,7 @@
|
|
108
110
|
#ifdef _MSC_VER
|
109
111
|
# define FORCE_NOINLINE static __declspec(noinline)
|
110
112
|
#else
|
111
|
-
# if defined(__GNUC__) || defined(
|
113
|
+
# if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
112
114
|
# define FORCE_NOINLINE static __attribute__((__noinline__))
|
113
115
|
# else
|
114
116
|
# define FORCE_NOINLINE static
|
@@ -117,7 +119,7 @@
|
|
117
119
|
|
118
120
|
|
119
121
|
/* target attribute */
|
120
|
-
#if defined(__GNUC__) || defined(
|
122
|
+
#if defined(__GNUC__) || defined(__IAR_SYSTEMS_ICC__)
|
121
123
|
# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
|
122
124
|
#else
|
123
125
|
# define TARGET_ATTRIBUTE(target)
|
@@ -205,30 +207,21 @@
|
|
205
207
|
# pragma warning(disable : 4324) /* disable: C4324: padded structure */
|
206
208
|
#endif
|
207
209
|
|
208
|
-
/*Like DYNAMIC_BMI2 but for compile time determination of BMI2 support*/
|
209
|
-
#ifndef STATIC_BMI2
|
210
|
-
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))
|
211
|
-
# ifdef __AVX2__ //MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2
|
212
|
-
# define STATIC_BMI2 1
|
213
|
-
# endif
|
214
|
-
# elif defined(__BMI2__) && defined(__x86_64__) && defined(__GNUC__)
|
215
|
-
# define STATIC_BMI2 1
|
216
|
-
# endif
|
217
|
-
#endif
|
218
|
-
|
219
|
-
#ifndef STATIC_BMI2
|
220
|
-
#define STATIC_BMI2 0
|
221
|
-
#endif
|
222
|
-
|
223
210
|
/* compile time determination of SIMD support */
|
224
211
|
#if !defined(ZSTD_NO_INTRINSICS)
|
225
|
-
# if defined(
|
212
|
+
# if defined(__AVX2__)
|
213
|
+
# define ZSTD_ARCH_X86_AVX2
|
214
|
+
# endif
|
215
|
+
# if defined(__SSE2__) || defined(_M_X64) || (defined (_M_IX86) && defined(_M_IX86_FP) && (_M_IX86_FP >= 2))
|
226
216
|
# define ZSTD_ARCH_X86_SSE2
|
227
217
|
# endif
|
228
218
|
# if defined(__ARM_NEON) || defined(_M_ARM64)
|
229
219
|
# define ZSTD_ARCH_ARM_NEON
|
230
220
|
# endif
|
231
221
|
#
|
222
|
+
# if defined(ZSTD_ARCH_X86_AVX2)
|
223
|
+
# include <immintrin.h>
|
224
|
+
# endif
|
232
225
|
# if defined(ZSTD_ARCH_X86_SSE2)
|
233
226
|
# include <emmintrin.h>
|
234
227
|
# elif defined(ZSTD_ARCH_ARM_NEON)
|
@@ -273,9 +266,15 @@
|
|
273
266
|
#endif
|
274
267
|
|
275
268
|
/*-**************************************************************
|
276
|
-
* Alignment
|
269
|
+
* Alignment
|
277
270
|
*****************************************************************/
|
278
271
|
|
272
|
+
/* @return 1 if @u is a 2^n value, 0 otherwise
|
273
|
+
* useful to check a value is valid for alignment restrictions */
|
274
|
+
MEM_STATIC int ZSTD_isPower2(size_t u) {
|
275
|
+
return (u & (u-1)) == 0;
|
276
|
+
}
|
277
|
+
|
279
278
|
/* this test was initially positioned in mem.h,
|
280
279
|
* but this file is removed (or replaced) for linux kernel
|
281
280
|
* so it's now hosted in compiler.h,
|
@@ -301,6 +300,21 @@
|
|
301
300
|
# endif
|
302
301
|
#endif /* ZSTD_ALIGNOF */
|
303
302
|
|
303
|
+
#ifndef ZSTD_ALIGNED
|
304
|
+
/* C90-compatible alignment macro (GCC/Clang). Adjust for other compilers if needed. */
|
305
|
+
# if defined(__GNUC__) || defined(__clang__)
|
306
|
+
# define ZSTD_ALIGNED(a) __attribute__((aligned(a)))
|
307
|
+
# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
|
308
|
+
# define ZSTD_ALIGNED(a) _Alignas(a)
|
309
|
+
#elif defined(_MSC_VER)
|
310
|
+
# define ZSTD_ALIGNED(n) __declspec(align(n))
|
311
|
+
# else
|
312
|
+
/* this compiler will require its own alignment instruction */
|
313
|
+
# define ZSTD_ALIGNED(...)
|
314
|
+
# endif
|
315
|
+
#endif /* ZSTD_ALIGNED */
|
316
|
+
|
317
|
+
|
304
318
|
/*-**************************************************************
|
305
319
|
* Sanitizer
|
306
320
|
*****************************************************************/
|
@@ -324,7 +338,7 @@
|
|
324
338
|
#endif
|
325
339
|
|
326
340
|
/**
|
327
|
-
* Helper function to perform a wrapped pointer difference without
|
341
|
+
* Helper function to perform a wrapped pointer difference without triggering
|
328
342
|
* UBSAN.
|
329
343
|
*
|
330
344
|
* @returns lhs - rhs with wrapping
|
@@ -35,7 +35,7 @@ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
|
|
35
35
|
U32 f7b = 0;
|
36
36
|
U32 f7c = 0;
|
37
37
|
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
|
38
|
-
#if !defined(__clang__)
|
38
|
+
#if !defined(_M_X64) || !defined(__clang__) || __clang_major__ >= 16
|
39
39
|
int reg[4];
|
40
40
|
__cpuid((int*)reg, 0);
|
41
41
|
{
|
@@ -32,10 +32,6 @@
|
|
32
32
|
#ifndef DEBUG_H_12987983217
|
33
33
|
#define DEBUG_H_12987983217
|
34
34
|
|
35
|
-
#if defined (__cplusplus)
|
36
|
-
extern "C" {
|
37
|
-
#endif
|
38
|
-
|
39
35
|
|
40
36
|
/* static assert is triggered at compile time, leaving no runtime artefact.
|
41
37
|
* static assert only works with compile-time constants.
|
@@ -108,9 +104,4 @@ extern int g_debuglevel; /* the variable is only declared,
|
|
108
104
|
# define DEBUGLOG(l, ...) do { } while (0) /* disabled */
|
109
105
|
#endif
|
110
106
|
|
111
|
-
|
112
|
-
#if defined (__cplusplus)
|
113
|
-
}
|
114
|
-
#endif
|
115
|
-
|
116
107
|
#endif /* DEBUG_H_12987983217 */
|
@@ -40,6 +40,7 @@ const char* ERR_getErrorString(ERR_enum code)
|
|
40
40
|
case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
|
41
41
|
case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
|
42
42
|
case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
|
43
|
+
case PREFIX(cannotProduce_uncompressedBlock): return "This mode cannot generate an uncompressed block";
|
43
44
|
case PREFIX(stabilityCondition_notRespected): return "pledged buffer stability condition is not respected";
|
44
45
|
case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
|
45
46
|
case PREFIX(dictionary_wrong): return "Dictionary mismatch";
|
@@ -13,11 +13,6 @@
|
|
13
13
|
#ifndef ERROR_H_MODULE
|
14
14
|
#define ERROR_H_MODULE
|
15
15
|
|
16
|
-
#if defined (__cplusplus)
|
17
|
-
extern "C" {
|
18
|
-
#endif
|
19
|
-
|
20
|
-
|
21
16
|
/* ****************************************
|
22
17
|
* Dependencies
|
23
18
|
******************************************/
|
@@ -26,7 +21,6 @@ extern "C" {
|
|
26
21
|
#include "debug.h"
|
27
22
|
#include "zstd_deps.h" /* size_t */
|
28
23
|
|
29
|
-
|
30
24
|
/* ****************************************
|
31
25
|
* Compiler-specific
|
32
26
|
******************************************/
|
@@ -161,8 +155,4 @@ void _force_has_format_string(const char *format, ...) {
|
|
161
155
|
} \
|
162
156
|
} while(0)
|
163
157
|
|
164
|
-
#if defined (__cplusplus)
|
165
|
-
}
|
166
|
-
#endif
|
167
|
-
|
168
158
|
#endif /* ERROR_H_MODULE */
|