extzstd 0.0.3.CONCEPT → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/HISTORY.ja.md +39 -0
- data/LICENSE +6 -6
- data/README.md +26 -45
- data/contrib/zstd/CHANGELOG +555 -0
- data/contrib/zstd/CODE_OF_CONDUCT.md +5 -0
- data/contrib/zstd/CONTRIBUTING.md +392 -0
- data/contrib/zstd/COPYING +339 -0
- data/contrib/zstd/LICENSE +13 -9
- data/contrib/zstd/Makefile +414 -0
- data/contrib/zstd/README.md +170 -45
- data/contrib/zstd/TESTING.md +44 -0
- data/contrib/zstd/appveyor.yml +289 -0
- data/contrib/zstd/lib/BUCK +234 -0
- data/contrib/zstd/lib/Makefile +354 -0
- data/contrib/zstd/lib/README.md +179 -0
- data/contrib/zstd/{common → lib/common}/bitstream.h +170 -130
- data/contrib/zstd/lib/common/compiler.h +175 -0
- data/contrib/zstd/lib/common/cpu.h +215 -0
- data/contrib/zstd/lib/common/debug.c +24 -0
- data/contrib/zstd/lib/common/debug.h +114 -0
- data/contrib/zstd/{common → lib/common}/entropy_common.c +79 -94
- data/contrib/zstd/lib/common/error_private.c +55 -0
- data/contrib/zstd/lib/common/error_private.h +80 -0
- data/contrib/zstd/{common → lib/common}/fse.h +153 -93
- data/contrib/zstd/{common → lib/common}/fse_decompress.c +37 -82
- data/contrib/zstd/lib/common/huf.h +340 -0
- data/contrib/zstd/{common → lib/common}/mem.h +154 -78
- data/contrib/zstd/lib/common/pool.c +344 -0
- data/contrib/zstd/lib/common/pool.h +84 -0
- data/contrib/zstd/lib/common/threading.c +121 -0
- data/contrib/zstd/lib/common/threading.h +155 -0
- data/contrib/zstd/{common → lib/common}/xxhash.c +85 -75
- data/contrib/zstd/{common → lib/common}/xxhash.h +85 -73
- data/contrib/zstd/lib/common/zstd_common.c +83 -0
- data/contrib/zstd/lib/common/zstd_errors.h +94 -0
- data/contrib/zstd/lib/common/zstd_internal.h +447 -0
- data/contrib/zstd/{compress → lib/compress}/fse_compress.c +194 -303
- data/contrib/zstd/lib/compress/hist.c +183 -0
- data/contrib/zstd/lib/compress/hist.h +75 -0
- data/contrib/zstd/lib/compress/huf_compress.c +798 -0
- data/contrib/zstd/lib/compress/zstd_compress.c +4278 -0
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +1125 -0
- data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
- data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.c +419 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +845 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
- data/contrib/zstd/lib/compress/zstd_cwksp.h +525 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.c +521 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.h +38 -0
- data/contrib/zstd/lib/compress/zstd_fast.c +496 -0
- data/contrib/zstd/lib/compress/zstd_fast.h +37 -0
- data/contrib/zstd/lib/compress/zstd_lazy.c +1138 -0
- data/contrib/zstd/lib/compress/zstd_lazy.h +67 -0
- data/contrib/zstd/lib/compress/zstd_ldm.c +619 -0
- data/contrib/zstd/lib/compress/zstd_ldm.h +110 -0
- data/contrib/zstd/lib/compress/zstd_opt.c +1200 -0
- data/contrib/zstd/lib/compress/zstd_opt.h +56 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.c +2143 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.h +192 -0
- data/contrib/zstd/lib/decompress/huf_decompress.c +1248 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.c +244 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.h +44 -0
- data/contrib/zstd/lib/decompress/zstd_decompress.c +1885 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1432 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +59 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +189 -0
- data/contrib/zstd/{common → lib/deprecated}/zbuff.h +86 -69
- data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +147 -0
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +75 -0
- data/contrib/zstd/lib/dictBuilder/cover.c +1236 -0
- data/contrib/zstd/lib/dictBuilder/cover.h +157 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +3 -3
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +5 -5
- data/contrib/zstd/lib/dictBuilder/fastcover.c +757 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +437 -347
- data/contrib/zstd/lib/dictBuilder/zdict.h +305 -0
- data/contrib/zstd/lib/legacy/zstd_legacy.h +415 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +272 -292
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +26 -32
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +162 -392
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +26 -32
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +162 -391
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +27 -33
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +195 -604
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +26 -32
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +300 -575
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +22 -31
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +165 -592
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +54 -67
- data/contrib/zstd/lib/legacy/zstd_v07.c +4541 -0
- data/contrib/zstd/lib/legacy/zstd_v07.h +187 -0
- data/contrib/zstd/lib/libzstd.pc.in +15 -0
- data/contrib/zstd/lib/zstd.h +2090 -0
- data/ext/depend +2 -0
- data/ext/extconf.rb +18 -5
- data/ext/extzstd.c +296 -214
- data/ext/extzstd.h +81 -36
- data/ext/extzstd_nogvls.h +0 -117
- data/ext/extzstd_stream.c +622 -0
- data/ext/libzstd_conf.h +8 -0
- data/ext/zstd_common.c +11 -0
- data/ext/zstd_compress.c +15 -0
- data/ext/zstd_decompress.c +6 -0
- data/ext/zstd_dictbuilder.c +10 -0
- data/ext/zstd_dictbuilder_fastcover.c +3 -0
- data/ext/zstd_legacy_v01.c +3 -1
- data/ext/zstd_legacy_v02.c +3 -1
- data/ext/zstd_legacy_v03.c +3 -1
- data/ext/zstd_legacy_v04.c +3 -1
- data/ext/zstd_legacy_v05.c +3 -1
- data/ext/zstd_legacy_v06.c +3 -1
- data/ext/zstd_legacy_v07.c +3 -0
- data/gemstub.rb +27 -21
- data/lib/extzstd.rb +82 -161
- data/lib/extzstd/version.rb +1 -1
- data/test/test_basic.rb +19 -6
- metadata +127 -59
- data/contrib/zstd/common/error_private.h +0 -125
- data/contrib/zstd/common/error_public.h +0 -77
- data/contrib/zstd/common/huf.h +0 -228
- data/contrib/zstd/common/zstd.h +0 -475
- data/contrib/zstd/common/zstd_common.c +0 -91
- data/contrib/zstd/common/zstd_internal.h +0 -238
- data/contrib/zstd/compress/huf_compress.c +0 -577
- data/contrib/zstd/compress/zbuff_compress.c +0 -327
- data/contrib/zstd/compress/zstd_compress.c +0 -3074
- data/contrib/zstd/compress/zstd_opt.h +0 -1046
- data/contrib/zstd/decompress/huf_decompress.c +0 -894
- data/contrib/zstd/decompress/zbuff_decompress.c +0 -294
- data/contrib/zstd/decompress/zstd_decompress.c +0 -1362
- data/contrib/zstd/dictBuilder/zdict.h +0 -113
- data/contrib/zstd/legacy/zstd_legacy.h +0 -140
- data/ext/extzstd_buffered.c +0 -265
- data/ext/zstd_amalgam.c +0 -18
@@ -1,35 +1,15 @@
|
|
1
1
|
/*
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
14
|
-
* Redistributions in binary form must reproduce the above
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
16
|
-
in the documentation and/or other materials provided with the
|
17
|
-
distribution.
|
18
|
-
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
You can contact the author at :
|
32
|
-
- xxHash source repository : https://github.com/Cyan4973/xxHash
|
2
|
+
* xxHash - Extremely Fast Hash algorithm
|
3
|
+
* Header File
|
4
|
+
* Copyright (c) 2012-2020, Yann Collet, Facebook, Inc.
|
5
|
+
*
|
6
|
+
* You can contact the author at :
|
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.
|
33
13
|
*/
|
34
14
|
|
35
15
|
/* Notice extracted from xxHash homepage :
|
@@ -64,13 +44,13 @@ XXH64 13.8 GB/s 1.9 GB/s
|
|
64
44
|
XXH32 6.8 GB/s 6.0 GB/s
|
65
45
|
*/
|
66
46
|
|
67
|
-
#ifndef XXHASH_H_5627135585666179
|
68
|
-
#define XXHASH_H_5627135585666179 1
|
69
|
-
|
70
47
|
#if defined (__cplusplus)
|
71
48
|
extern "C" {
|
72
49
|
#endif
|
73
50
|
|
51
|
+
#ifndef XXHASH_H_5627135585666179
|
52
|
+
#define XXHASH_H_5627135585666179 1
|
53
|
+
|
74
54
|
|
75
55
|
/* ****************************
|
76
56
|
* Definitions
|
@@ -82,18 +62,21 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
|
|
82
62
|
/* ****************************
|
83
63
|
* API modifier
|
84
64
|
******************************/
|
85
|
-
|
86
|
-
*
|
87
|
-
*
|
88
|
-
*
|
89
|
-
* do :
|
65
|
+
/** XXH_PRIVATE_API
|
66
|
+
* This is useful if you want to include xxhash functions in `static` mode
|
67
|
+
* in order to inline them, and remove their symbol from the public list.
|
68
|
+
* Methodology :
|
90
69
|
* #define XXH_PRIVATE_API
|
91
|
-
* #include "xxhash.
|
92
|
-
*
|
70
|
+
* #include "xxhash.h"
|
71
|
+
* `xxhash.c` is automatically included.
|
72
|
+
* It's not useful to compile and link it as a separate module anymore.
|
93
73
|
*/
|
94
74
|
#ifdef XXH_PRIVATE_API
|
75
|
+
# ifndef XXH_STATIC_LINKING_ONLY
|
76
|
+
# define XXH_STATIC_LINKING_ONLY
|
77
|
+
# endif
|
95
78
|
# if defined(__GNUC__)
|
96
|
-
# define XXH_PUBLIC_API static __attribute__((unused))
|
79
|
+
# define XXH_PUBLIC_API static __inline __attribute__((unused))
|
97
80
|
# elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
98
81
|
# define XXH_PUBLIC_API static inline
|
99
82
|
# elif defined(_MSC_VER)
|
@@ -103,17 +86,17 @@ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
|
|
103
86
|
# endif
|
104
87
|
#else
|
105
88
|
# define XXH_PUBLIC_API /* do nothing */
|
106
|
-
#endif
|
89
|
+
#endif /* XXH_PRIVATE_API */
|
107
90
|
|
108
91
|
/*!XXH_NAMESPACE, aka Namespace Emulation :
|
109
92
|
|
110
93
|
If you want to include _and expose_ xxHash functions from within your own library,
|
111
94
|
but also want to avoid symbol collisions with another library which also includes xxHash,
|
112
95
|
|
113
|
-
you can use XXH_NAMESPACE, to automatically prefix any public symbol from
|
96
|
+
you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
|
114
97
|
with the value of XXH_NAMESPACE (so avoid to keep it NULL and avoid numeric values).
|
115
98
|
|
116
|
-
Note that no change is required within the calling program as long as it
|
99
|
+
Note that no change is required within the calling program as long as it includes `xxhash.h` :
|
117
100
|
regular symbol name will be automatically translated by this header.
|
118
101
|
*/
|
119
102
|
#ifdef XXH_NAMESPACE
|
@@ -132,6 +115,12 @@ regular symbol name will be automatically translated by this header.
|
|
132
115
|
# define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update)
|
133
116
|
# define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
|
134
117
|
# define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest)
|
118
|
+
# define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState)
|
119
|
+
# define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState)
|
120
|
+
# define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash)
|
121
|
+
# define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash)
|
122
|
+
# define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical)
|
123
|
+
# define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical)
|
135
124
|
#endif
|
136
125
|
|
137
126
|
|
@@ -140,7 +129,7 @@ regular symbol name will be automatically translated by this header.
|
|
140
129
|
***************************************/
|
141
130
|
#define XXH_VERSION_MAJOR 0
|
142
131
|
#define XXH_VERSION_MINOR 6
|
143
|
-
#define XXH_VERSION_RELEASE
|
132
|
+
#define XXH_VERSION_RELEASE 2
|
144
133
|
#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
|
145
134
|
XXH_PUBLIC_API unsigned XXH_versionNumber (void);
|
146
135
|
|
@@ -163,7 +152,7 @@ XXH32() :
|
|
163
152
|
XXH64() :
|
164
153
|
Calculate the 64-bits hash of sequence of length "len" stored at memory address "input".
|
165
154
|
"seed" can be used to alter the result predictably.
|
166
|
-
This function runs faster on 64-bits systems, but slower on 32-bits systems (see benchmark).
|
155
|
+
This function runs 2x faster on 64-bits systems, but slower on 32-bits systems (see benchmark).
|
167
156
|
*/
|
168
157
|
|
169
158
|
|
@@ -173,8 +162,7 @@ XXH64() :
|
|
173
162
|
typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */
|
174
163
|
typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */
|
175
164
|
|
176
|
-
/*!
|
177
|
-
Compatible with dynamic libraries */
|
165
|
+
/*! State allocation, compatible with dynamic libraries */
|
178
166
|
|
179
167
|
XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void);
|
180
168
|
XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr);
|
@@ -193,31 +181,48 @@ XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned lon
|
|
193
181
|
XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length);
|
194
182
|
XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr);
|
195
183
|
|
196
|
-
|
197
|
-
These functions generate the xxHash of an input provided in multiple segments
|
198
|
-
|
184
|
+
/*
|
185
|
+
These functions generate the xxHash of an input provided in multiple segments.
|
186
|
+
Note that, for small input, they are slower than single-call functions, due to state management.
|
187
|
+
For small input, prefer `XXH32()` and `XXH64()` .
|
199
188
|
|
200
|
-
XXH state must first be allocated, using
|
189
|
+
XXH state must first be allocated, using XXH*_createState() .
|
201
190
|
|
202
|
-
Start a new hash by initializing state with a seed, using
|
191
|
+
Start a new hash by initializing state with a seed, using XXH*_reset().
|
203
192
|
|
204
|
-
Then, feed the hash state by calling
|
205
|
-
Obviously, input must be
|
193
|
+
Then, feed the hash state by calling XXH*_update() as many times as necessary.
|
194
|
+
Obviously, input must be allocated and read accessible.
|
206
195
|
The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
|
207
196
|
|
208
|
-
Finally, a hash value can be produced anytime, by using
|
197
|
+
Finally, a hash value can be produced anytime, by using XXH*_digest().
|
209
198
|
This function returns the nn-bits hash as an int or long long.
|
210
199
|
|
211
200
|
It's still possible to continue inserting input into the hash state after a digest,
|
212
|
-
and
|
201
|
+
and generate some new hashes later on, by calling again XXH*_digest().
|
213
202
|
|
214
203
|
When done, free XXH state space if it was allocated dynamically.
|
215
204
|
*/
|
216
205
|
|
217
206
|
|
207
|
+
/* **************************
|
208
|
+
* Utils
|
209
|
+
****************************/
|
210
|
+
#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) /* ! C99 */
|
211
|
+
# define restrict /* disable restrict */
|
212
|
+
#endif
|
213
|
+
|
214
|
+
XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dst_state, const XXH32_state_t* restrict src_state);
|
215
|
+
XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dst_state, const XXH64_state_t* restrict src_state);
|
216
|
+
|
217
|
+
|
218
218
|
/* **************************
|
219
219
|
* Canonical representation
|
220
220
|
****************************/
|
221
|
+
/* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
|
222
|
+
* The canonical representation uses human-readable write convention, aka big-endian (large digits first).
|
223
|
+
* These functions allow transformation of hash result into and from its canonical format.
|
224
|
+
* This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
|
225
|
+
*/
|
221
226
|
typedef struct { unsigned char digest[4]; } XXH32_canonical_t;
|
222
227
|
typedef struct { unsigned char digest[8]; } XXH64_canonical_t;
|
223
228
|
|
@@ -227,47 +232,54 @@ XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t
|
|
227
232
|
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src);
|
228
233
|
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src);
|
229
234
|
|
230
|
-
|
231
|
-
|
232
|
-
* These functions allow transformation of hash result into and from its canonical format.
|
233
|
-
* This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
|
234
|
-
*/
|
235
|
+
#endif /* XXHASH_H_5627135585666179 */
|
236
|
+
|
235
237
|
|
236
238
|
|
237
|
-
|
239
|
+
/* ================================================================================================
|
240
|
+
This section contains definitions which are not guaranteed to remain stable.
|
241
|
+
They may change in future versions, becoming incompatible with a different version of the library.
|
242
|
+
They shall only be used with static linking.
|
243
|
+
Never use these definitions in association with dynamic linking !
|
244
|
+
=================================================================================================== */
|
245
|
+
#if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXH_STATIC_H_3543687687345)
|
246
|
+
#define XXH_STATIC_H_3543687687345
|
238
247
|
|
239
|
-
/*
|
240
|
-
|
241
|
-
|
248
|
+
/* These definitions are only meant to allow allocation of XXH state
|
249
|
+
statically, on stack, or in a struct for example.
|
250
|
+
Do not use members directly. */
|
242
251
|
|
243
252
|
struct XXH32_state_s {
|
244
|
-
unsigned
|
245
|
-
unsigned
|
253
|
+
unsigned total_len_32;
|
254
|
+
unsigned large_len;
|
246
255
|
unsigned v1;
|
247
256
|
unsigned v2;
|
248
257
|
unsigned v3;
|
249
258
|
unsigned v4;
|
250
259
|
unsigned mem32[4]; /* buffer defined as U32 for alignment */
|
251
260
|
unsigned memsize;
|
261
|
+
unsigned reserved; /* never read nor write, will be removed in a future version */
|
252
262
|
}; /* typedef'd to XXH32_state_t */
|
253
263
|
|
254
264
|
struct XXH64_state_s {
|
255
265
|
unsigned long long total_len;
|
256
|
-
unsigned long long seed;
|
257
266
|
unsigned long long v1;
|
258
267
|
unsigned long long v2;
|
259
268
|
unsigned long long v3;
|
260
269
|
unsigned long long v4;
|
261
270
|
unsigned long long mem64[4]; /* buffer defined as U64 for alignment */
|
262
271
|
unsigned memsize;
|
272
|
+
unsigned reserved[2]; /* never read nor write, will be removed in a future version */
|
263
273
|
}; /* typedef'd to XXH64_state_t */
|
264
274
|
|
265
275
|
|
266
|
-
#
|
276
|
+
# ifdef XXH_PRIVATE_API
|
277
|
+
# include "xxhash.c" /* include xxhash functions as `static`, for inlining */
|
278
|
+
# endif
|
279
|
+
|
280
|
+
#endif /* XXH_STATIC_LINKING_ONLY && XXH_STATIC_H_3543687687345 */
|
267
281
|
|
268
282
|
|
269
283
|
#if defined (__cplusplus)
|
270
284
|
}
|
271
285
|
#endif
|
272
|
-
|
273
|
-
#endif /* XXHASH_H_5627135585666179 */
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-2020, 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
|
+
|
12
|
+
|
13
|
+
/*-*************************************
|
14
|
+
* Dependencies
|
15
|
+
***************************************/
|
16
|
+
#include <stdlib.h> /* malloc, calloc, free */
|
17
|
+
#include <string.h> /* memset */
|
18
|
+
#include "error_private.h"
|
19
|
+
#include "zstd_internal.h"
|
20
|
+
|
21
|
+
|
22
|
+
/*-****************************************
|
23
|
+
* Version
|
24
|
+
******************************************/
|
25
|
+
unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
|
26
|
+
|
27
|
+
const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
|
28
|
+
|
29
|
+
|
30
|
+
/*-****************************************
|
31
|
+
* ZSTD Error Management
|
32
|
+
******************************************/
|
33
|
+
#undef ZSTD_isError /* defined within zstd_internal.h */
|
34
|
+
/*! ZSTD_isError() :
|
35
|
+
* tells if a return value is an error code
|
36
|
+
* symbol is required for external callers */
|
37
|
+
unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
|
38
|
+
|
39
|
+
/*! ZSTD_getErrorName() :
|
40
|
+
* provides error code string from function result (useful for debugging) */
|
41
|
+
const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
42
|
+
|
43
|
+
/*! ZSTD_getError() :
|
44
|
+
* convert a `size_t` function result into a proper ZSTD_errorCode enum */
|
45
|
+
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
|
46
|
+
|
47
|
+
/*! ZSTD_getErrorString() :
|
48
|
+
* provides error code string from enum */
|
49
|
+
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
/*=**************************************************************
|
54
|
+
* Custom allocator
|
55
|
+
****************************************************************/
|
56
|
+
void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
|
57
|
+
{
|
58
|
+
if (customMem.customAlloc)
|
59
|
+
return customMem.customAlloc(customMem.opaque, size);
|
60
|
+
return malloc(size);
|
61
|
+
}
|
62
|
+
|
63
|
+
void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
|
64
|
+
{
|
65
|
+
if (customMem.customAlloc) {
|
66
|
+
/* calloc implemented as malloc+memset;
|
67
|
+
* not as efficient as calloc, but next best guess for custom malloc */
|
68
|
+
void* const ptr = customMem.customAlloc(customMem.opaque, size);
|
69
|
+
memset(ptr, 0, size);
|
70
|
+
return ptr;
|
71
|
+
}
|
72
|
+
return calloc(1, size);
|
73
|
+
}
|
74
|
+
|
75
|
+
void ZSTD_free(void* ptr, ZSTD_customMem customMem)
|
76
|
+
{
|
77
|
+
if (ptr!=NULL) {
|
78
|
+
if (customMem.customFree)
|
79
|
+
customMem.customFree(customMem.opaque, ptr);
|
80
|
+
else
|
81
|
+
free(ptr);
|
82
|
+
}
|
83
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-2020, 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_ERRORS_H_398273423
|
12
|
+
#define ZSTD_ERRORS_H_398273423
|
13
|
+
|
14
|
+
#if defined (__cplusplus)
|
15
|
+
extern "C" {
|
16
|
+
#endif
|
17
|
+
|
18
|
+
/*===== dependency =====*/
|
19
|
+
#include <stddef.h> /* size_t */
|
20
|
+
|
21
|
+
|
22
|
+
/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
|
23
|
+
#ifndef ZSTDERRORLIB_VISIBILITY
|
24
|
+
# if defined(__GNUC__) && (__GNUC__ >= 4)
|
25
|
+
# define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
|
26
|
+
# else
|
27
|
+
# define ZSTDERRORLIB_VISIBILITY
|
28
|
+
# endif
|
29
|
+
#endif
|
30
|
+
#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
|
31
|
+
# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY
|
32
|
+
#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
|
33
|
+
# define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
34
|
+
#else
|
35
|
+
# define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY
|
36
|
+
#endif
|
37
|
+
|
38
|
+
/*-*********************************************
|
39
|
+
* Error codes list
|
40
|
+
*-*********************************************
|
41
|
+
* Error codes _values_ are pinned down since v1.3.1 only.
|
42
|
+
* Therefore, don't rely on values if you may link to any version < v1.3.1.
|
43
|
+
*
|
44
|
+
* Only values < 100 are considered stable.
|
45
|
+
*
|
46
|
+
* note 1 : this API shall be used with static linking only.
|
47
|
+
* dynamic linking is not yet officially supported.
|
48
|
+
* note 2 : Prefer relying on the enum than on its value whenever possible
|
49
|
+
* This is the only supported way to use the error list < v1.3.1
|
50
|
+
* note 3 : ZSTD_isError() is always correct, whatever the library version.
|
51
|
+
**********************************************/
|
52
|
+
typedef enum {
|
53
|
+
ZSTD_error_no_error = 0,
|
54
|
+
ZSTD_error_GENERIC = 1,
|
55
|
+
ZSTD_error_prefix_unknown = 10,
|
56
|
+
ZSTD_error_version_unsupported = 12,
|
57
|
+
ZSTD_error_frameParameter_unsupported = 14,
|
58
|
+
ZSTD_error_frameParameter_windowTooLarge = 16,
|
59
|
+
ZSTD_error_corruption_detected = 20,
|
60
|
+
ZSTD_error_checksum_wrong = 22,
|
61
|
+
ZSTD_error_dictionary_corrupted = 30,
|
62
|
+
ZSTD_error_dictionary_wrong = 32,
|
63
|
+
ZSTD_error_dictionaryCreation_failed = 34,
|
64
|
+
ZSTD_error_parameter_unsupported = 40,
|
65
|
+
ZSTD_error_parameter_outOfBound = 42,
|
66
|
+
ZSTD_error_tableLog_tooLarge = 44,
|
67
|
+
ZSTD_error_maxSymbolValue_tooLarge = 46,
|
68
|
+
ZSTD_error_maxSymbolValue_tooSmall = 48,
|
69
|
+
ZSTD_error_stage_wrong = 60,
|
70
|
+
ZSTD_error_init_missing = 62,
|
71
|
+
ZSTD_error_memory_allocation = 64,
|
72
|
+
ZSTD_error_workSpace_tooSmall= 66,
|
73
|
+
ZSTD_error_dstSize_tooSmall = 70,
|
74
|
+
ZSTD_error_srcSize_wrong = 72,
|
75
|
+
ZSTD_error_dstBuffer_null = 74,
|
76
|
+
/* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
|
77
|
+
ZSTD_error_frameIndex_tooLarge = 100,
|
78
|
+
ZSTD_error_seekableIO = 102,
|
79
|
+
ZSTD_error_dstBuffer_wrong = 104,
|
80
|
+
ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
|
81
|
+
} ZSTD_ErrorCode;
|
82
|
+
|
83
|
+
/*! ZSTD_getErrorCode() :
|
84
|
+
convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
|
85
|
+
which can be used to compare with enum list published above */
|
86
|
+
ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
|
87
|
+
ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */
|
88
|
+
|
89
|
+
|
90
|
+
#if defined (__cplusplus)
|
91
|
+
}
|
92
|
+
#endif
|
93
|
+
|
94
|
+
#endif /* ZSTD_ERRORS_H_398273423 */
|