zstd-ruby 1.3.0.0 → 1.3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/zstdruby/libzstd/common/bitstream.h +40 -41
- data/ext/zstdruby/libzstd/common/compiler.h +85 -0
- data/ext/zstdruby/libzstd/common/error_private.c +8 -10
- data/ext/zstdruby/libzstd/common/error_private.h +4 -4
- data/ext/zstdruby/libzstd/common/fse.h +11 -5
- data/ext/zstdruby/libzstd/common/fse_decompress.c +3 -22
- data/ext/zstdruby/libzstd/common/huf.h +5 -6
- data/ext/zstdruby/libzstd/common/mem.h +6 -6
- data/ext/zstdruby/libzstd/common/pool.c +61 -27
- data/ext/zstdruby/libzstd/common/pool.h +10 -10
- data/ext/zstdruby/libzstd/common/threading.h +5 -6
- data/ext/zstdruby/libzstd/common/xxhash.c +28 -22
- data/ext/zstdruby/libzstd/common/zstd_common.c +4 -4
- data/ext/zstdruby/libzstd/common/zstd_errors.h +30 -32
- data/ext/zstdruby/libzstd/common/zstd_internal.h +57 -56
- data/ext/zstdruby/libzstd/compress/fse_compress.c +4 -22
- data/ext/zstdruby/libzstd/compress/huf_compress.c +4 -3
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +314 -304
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +118 -116
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +223 -156
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +10 -9
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +8 -24
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +95 -115
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +4 -4
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +4 -5
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +4 -4
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +4 -4
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +7 -9
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +5 -5
- data/ext/zstdruby/libzstd/dictBuilder/zdict.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +8 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +5 -5
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +5 -5
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +5 -5
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +4 -4
- data/ext/zstdruby/libzstd/zstd.h +16 -14
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +3 -2
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
2
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree
|
7
|
-
*
|
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
8
|
*/
|
9
9
|
|
10
10
|
#ifndef MEM_H_MODULE
|
@@ -110,7 +110,7 @@ Only use if no other choice to achieve best performance on target platform */
|
|
110
110
|
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
|
111
111
|
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
112
112
|
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
113
|
-
MEM_STATIC
|
113
|
+
MEM_STATIC size_t MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; }
|
114
114
|
|
115
115
|
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
116
116
|
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
|
@@ -131,7 +131,7 @@ MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
|
|
131
131
|
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
|
132
132
|
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
|
133
133
|
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
134
|
-
MEM_STATIC
|
134
|
+
MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalign*)ptr)->st; }
|
135
135
|
|
136
136
|
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
137
137
|
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; }
|
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2016-present, Facebook, Inc.
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree
|
7
|
-
*
|
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
8
|
*/
|
9
9
|
|
10
10
|
|
@@ -39,6 +39,12 @@ struct POOL_ctx_s {
|
|
39
39
|
size_t queueHead;
|
40
40
|
size_t queueTail;
|
41
41
|
size_t queueSize;
|
42
|
+
|
43
|
+
/* The number of threads working on jobs */
|
44
|
+
size_t numThreadsBusy;
|
45
|
+
/* Indicates if the queue is empty */
|
46
|
+
int queueEmpty;
|
47
|
+
|
42
48
|
/* The mutex protects the queue */
|
43
49
|
pthread_mutex_t queueMutex;
|
44
50
|
/* Condition variable for pushers to wait on when the queue is full */
|
@@ -60,30 +66,41 @@ static void* POOL_thread(void* opaque) {
|
|
60
66
|
for (;;) {
|
61
67
|
/* Lock the mutex and wait for a non-empty queue or until shutdown */
|
62
68
|
pthread_mutex_lock(&ctx->queueMutex);
|
63
|
-
|
69
|
+
|
70
|
+
while (ctx->queueEmpty && !ctx->shutdown) {
|
64
71
|
pthread_cond_wait(&ctx->queuePopCond, &ctx->queueMutex);
|
65
72
|
}
|
66
73
|
/* empty => shutting down: so stop */
|
67
|
-
if (ctx->
|
74
|
+
if (ctx->queueEmpty) {
|
68
75
|
pthread_mutex_unlock(&ctx->queueMutex);
|
69
76
|
return opaque;
|
70
77
|
}
|
71
78
|
/* Pop a job off the queue */
|
72
79
|
{ POOL_job const job = ctx->queue[ctx->queueHead];
|
73
80
|
ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
|
81
|
+
ctx->numThreadsBusy++;
|
82
|
+
ctx->queueEmpty = ctx->queueHead == ctx->queueTail;
|
74
83
|
/* Unlock the mutex, signal a pusher, and run the job */
|
75
84
|
pthread_mutex_unlock(&ctx->queueMutex);
|
76
85
|
pthread_cond_signal(&ctx->queuePushCond);
|
86
|
+
|
77
87
|
job.function(job.opaque);
|
78
|
-
|
79
|
-
|
88
|
+
|
89
|
+
/* If the intended queue size was 0, signal after finishing job */
|
90
|
+
if (ctx->queueSize == 1) {
|
91
|
+
pthread_mutex_lock(&ctx->queueMutex);
|
92
|
+
ctx->numThreadsBusy--;
|
93
|
+
pthread_mutex_unlock(&ctx->queueMutex);
|
94
|
+
pthread_cond_signal(&ctx->queuePushCond);
|
95
|
+
} }
|
96
|
+
} /* for (;;) */
|
80
97
|
/* Unreachable */
|
81
98
|
}
|
82
99
|
|
83
100
|
POOL_ctx *POOL_create(size_t numThreads, size_t queueSize) {
|
84
101
|
POOL_ctx *ctx;
|
85
102
|
/* Check the parameters */
|
86
|
-
if (!numThreads
|
103
|
+
if (!numThreads) { return NULL; }
|
87
104
|
/* Allocate the context and zero initialize */
|
88
105
|
ctx = (POOL_ctx *)calloc(1, sizeof(POOL_ctx));
|
89
106
|
if (!ctx) { return NULL; }
|
@@ -92,15 +109,17 @@ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize) {
|
|
92
109
|
* and full queues.
|
93
110
|
*/
|
94
111
|
ctx->queueSize = queueSize + 1;
|
95
|
-
ctx->queue = (POOL_job
|
112
|
+
ctx->queue = (POOL_job*) malloc(ctx->queueSize * sizeof(POOL_job));
|
96
113
|
ctx->queueHead = 0;
|
97
114
|
ctx->queueTail = 0;
|
98
|
-
|
99
|
-
|
100
|
-
|
115
|
+
ctx->numThreadsBusy = 0;
|
116
|
+
ctx->queueEmpty = 1;
|
117
|
+
(void)pthread_mutex_init(&ctx->queueMutex, NULL);
|
118
|
+
(void)pthread_cond_init(&ctx->queuePushCond, NULL);
|
119
|
+
(void)pthread_cond_init(&ctx->queuePopCond, NULL);
|
101
120
|
ctx->shutdown = 0;
|
102
121
|
/* Allocate space for the thread handles */
|
103
|
-
ctx->threads = (pthread_t
|
122
|
+
ctx->threads = (pthread_t*)malloc(numThreads * sizeof(pthread_t));
|
104
123
|
ctx->numThreads = 0;
|
105
124
|
/* Check for errors */
|
106
125
|
if (!ctx->threads || !ctx->queue) { POOL_free(ctx); return NULL; }
|
@@ -153,22 +172,37 @@ size_t POOL_sizeof(POOL_ctx *ctx) {
|
|
153
172
|
+ ctx->numThreads * sizeof(pthread_t);
|
154
173
|
}
|
155
174
|
|
156
|
-
|
157
|
-
|
175
|
+
/**
|
176
|
+
* Returns 1 if the queue is full and 0 otherwise.
|
177
|
+
*
|
178
|
+
* If the queueSize is 1 (the pool was created with an intended queueSize of 0),
|
179
|
+
* then a queue is empty if there is a thread free and no job is waiting.
|
180
|
+
*/
|
181
|
+
static int isQueueFull(POOL_ctx const* ctx) {
|
182
|
+
if (ctx->queueSize > 1) {
|
183
|
+
return ctx->queueHead == ((ctx->queueTail + 1) % ctx->queueSize);
|
184
|
+
} else {
|
185
|
+
return ctx->numThreadsBusy == ctx->numThreads ||
|
186
|
+
!ctx->queueEmpty;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
void POOL_add(void* ctxVoid, POOL_function function, void *opaque) {
|
191
|
+
POOL_ctx* const ctx = (POOL_ctx*)ctxVoid;
|
158
192
|
if (!ctx) { return; }
|
159
193
|
|
160
194
|
pthread_mutex_lock(&ctx->queueMutex);
|
161
195
|
{ POOL_job const job = {function, opaque};
|
196
|
+
|
162
197
|
/* Wait until there is space in the queue for the new job */
|
163
|
-
|
164
|
-
while (ctx->queueHead == newTail && !ctx->shutdown) {
|
198
|
+
while (isQueueFull(ctx) && !ctx->shutdown) {
|
165
199
|
pthread_cond_wait(&ctx->queuePushCond, &ctx->queueMutex);
|
166
|
-
newTail = (ctx->queueTail + 1) % ctx->queueSize;
|
167
200
|
}
|
168
201
|
/* The queue is still going => there is space */
|
169
202
|
if (!ctx->shutdown) {
|
203
|
+
ctx->queueEmpty = 0;
|
170
204
|
ctx->queue[ctx->queueTail] = job;
|
171
|
-
ctx->queueTail =
|
205
|
+
ctx->queueTail = (ctx->queueTail + 1) % ctx->queueSize;
|
172
206
|
}
|
173
207
|
}
|
174
208
|
pthread_mutex_unlock(&ctx->queueMutex);
|
@@ -183,22 +217,22 @@ struct POOL_ctx_s {
|
|
183
217
|
int data;
|
184
218
|
};
|
185
219
|
|
186
|
-
POOL_ctx
|
220
|
+
POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
|
187
221
|
(void)numThreads;
|
188
222
|
(void)queueSize;
|
189
|
-
return (POOL_ctx
|
223
|
+
return (POOL_ctx*)malloc(sizeof(POOL_ctx));
|
190
224
|
}
|
191
225
|
|
192
|
-
void POOL_free(POOL_ctx
|
193
|
-
|
226
|
+
void POOL_free(POOL_ctx* ctx) {
|
227
|
+
free(ctx);
|
194
228
|
}
|
195
229
|
|
196
|
-
void POOL_add(void
|
230
|
+
void POOL_add(void* ctx, POOL_function function, void* opaque) {
|
197
231
|
(void)ctx;
|
198
232
|
function(opaque);
|
199
233
|
}
|
200
234
|
|
201
|
-
size_t POOL_sizeof(POOL_ctx
|
235
|
+
size_t POOL_sizeof(POOL_ctx* ctx) {
|
202
236
|
if (ctx==NULL) return 0; /* supports sizeof NULL */
|
203
237
|
return sizeof(*ctx);
|
204
238
|
}
|
@@ -1,11 +1,12 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2016-present, Facebook, Inc.
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree
|
7
|
-
*
|
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
8
|
*/
|
9
|
+
|
9
10
|
#ifndef POOL_H
|
10
11
|
#define POOL_H
|
11
12
|
|
@@ -19,11 +20,10 @@ extern "C" {
|
|
19
20
|
typedef struct POOL_ctx_s POOL_ctx;
|
20
21
|
|
21
22
|
/*! POOL_create() :
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@return : The POOL_ctx pointer on success else NULL.
|
23
|
+
* Create a thread pool with at most `numThreads` threads.
|
24
|
+
* `numThreads` must be at least 1.
|
25
|
+
* The maximum number of queued jobs before blocking is `queueSize`.
|
26
|
+
* @return : POOL_ctx pointer on success, else NULL.
|
27
27
|
*/
|
28
28
|
POOL_ctx *POOL_create(size_t numThreads, size_t queueSize);
|
29
29
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
/**
|
3
2
|
* Copyright (c) 2016 Tino Reichardt
|
4
3
|
* All rights reserved.
|
@@ -42,14 +41,14 @@ extern "C" {
|
|
42
41
|
|
43
42
|
/* mutex */
|
44
43
|
#define pthread_mutex_t CRITICAL_SECTION
|
45
|
-
#define pthread_mutex_init(a,b) InitializeCriticalSection((a))
|
44
|
+
#define pthread_mutex_init(a,b) (InitializeCriticalSection((a)), 0)
|
46
45
|
#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
|
47
46
|
#define pthread_mutex_lock(a) EnterCriticalSection((a))
|
48
47
|
#define pthread_mutex_unlock(a) LeaveCriticalSection((a))
|
49
48
|
|
50
49
|
/* condition variable */
|
51
50
|
#define pthread_cond_t CONDITION_VARIABLE
|
52
|
-
#define pthread_cond_init(a, b) InitializeConditionVariable((a))
|
51
|
+
#define pthread_cond_init(a, b) (InitializeConditionVariable((a)), 0)
|
53
52
|
#define pthread_cond_destroy(a) /* No delete */
|
54
53
|
#define pthread_cond_wait(a, b) SleepConditionVariableCS((a), (b), INFINITE)
|
55
54
|
#define pthread_cond_signal(a) WakeConditionVariable((a))
|
@@ -80,14 +79,14 @@ int _pthread_join(pthread_t* thread, void** value_ptr);
|
|
80
79
|
#else /* ZSTD_MULTITHREAD not defined */
|
81
80
|
/* No multithreading support */
|
82
81
|
|
83
|
-
#define pthread_mutex_t int /* #define rather than typedef,
|
84
|
-
#define pthread_mutex_init(a,b)
|
82
|
+
#define pthread_mutex_t int /* #define rather than typedef, because sometimes pthread support is implicit, resulting in duplicated symbols */
|
83
|
+
#define pthread_mutex_init(a,b) ((void)a, 0)
|
85
84
|
#define pthread_mutex_destroy(a)
|
86
85
|
#define pthread_mutex_lock(a)
|
87
86
|
#define pthread_mutex_unlock(a)
|
88
87
|
|
89
88
|
#define pthread_cond_t int
|
90
|
-
#define pthread_cond_init(a,b)
|
89
|
+
#define pthread_cond_init(a,b) ((void)a, 0)
|
91
90
|
#define pthread_cond_destroy(a)
|
92
91
|
#define pthread_cond_wait(a,b)
|
93
92
|
#define pthread_cond_signal(a)
|
@@ -113,19 +113,25 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp
|
|
113
113
|
/* *************************************
|
114
114
|
* Compiler Specific Options
|
115
115
|
***************************************/
|
116
|
-
#
|
117
|
-
#
|
118
|
-
# define FORCE_INLINE static __forceinline
|
116
|
+
#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
117
|
+
# define INLINE_KEYWORD inline
|
119
118
|
#else
|
120
|
-
#
|
121
|
-
#
|
122
|
-
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
119
|
+
# define INLINE_KEYWORD
|
120
|
+
#endif
|
121
|
+
|
122
|
+
#if defined(__GNUC__)
|
123
|
+
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
124
|
+
#elif defined(_MSC_VER)
|
125
|
+
# define FORCE_INLINE_ATTR __forceinline
|
126
|
+
#else
|
127
|
+
# define FORCE_INLINE_ATTR
|
128
|
+
#endif
|
129
|
+
|
130
|
+
#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
131
|
+
|
132
|
+
|
133
|
+
#ifdef _MSC_VER
|
134
|
+
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
129
135
|
#endif
|
130
136
|
|
131
137
|
|
@@ -248,7 +254,7 @@ typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
|
|
248
254
|
*****************************/
|
249
255
|
typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
|
250
256
|
|
251
|
-
|
257
|
+
FORCE_INLINE_TEMPLATE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
|
252
258
|
{
|
253
259
|
if (align==XXH_unaligned)
|
254
260
|
return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
|
@@ -256,7 +262,7 @@ FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_a
|
|
256
262
|
return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr);
|
257
263
|
}
|
258
264
|
|
259
|
-
|
265
|
+
FORCE_INLINE_TEMPLATE U32 XXH_readLE32(const void* ptr, XXH_endianess endian)
|
260
266
|
{
|
261
267
|
return XXH_readLE32_align(ptr, endian, XXH_unaligned);
|
262
268
|
}
|
@@ -266,7 +272,7 @@ static U32 XXH_readBE32(const void* ptr)
|
|
266
272
|
return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr);
|
267
273
|
}
|
268
274
|
|
269
|
-
|
275
|
+
FORCE_INLINE_TEMPLATE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
|
270
276
|
{
|
271
277
|
if (align==XXH_unaligned)
|
272
278
|
return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr));
|
@@ -274,7 +280,7 @@ FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_a
|
|
274
280
|
return endian==XXH_littleEndian ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr);
|
275
281
|
}
|
276
282
|
|
277
|
-
|
283
|
+
FORCE_INLINE_TEMPLATE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
|
278
284
|
{
|
279
285
|
return XXH_readLE64_align(ptr, endian, XXH_unaligned);
|
280
286
|
}
|
@@ -335,7 +341,7 @@ static U32 XXH32_round(U32 seed, U32 input)
|
|
335
341
|
return seed;
|
336
342
|
}
|
337
343
|
|
338
|
-
|
344
|
+
FORCE_INLINE_TEMPLATE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
|
339
345
|
{
|
340
346
|
const BYTE* p = (const BYTE*)input;
|
341
347
|
const BYTE* bEnd = p + len;
|
@@ -435,7 +441,7 @@ static U64 XXH64_mergeRound(U64 acc, U64 val)
|
|
435
441
|
return acc;
|
436
442
|
}
|
437
443
|
|
438
|
-
|
444
|
+
FORCE_INLINE_TEMPLATE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align)
|
439
445
|
{
|
440
446
|
const BYTE* p = (const BYTE*)input;
|
441
447
|
const BYTE* const bEnd = p + len;
|
@@ -584,7 +590,7 @@ XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long
|
|
584
590
|
}
|
585
591
|
|
586
592
|
|
587
|
-
|
593
|
+
FORCE_INLINE_TEMPLATE XXH_errorcode XXH32_update_endian (XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian)
|
588
594
|
{
|
589
595
|
const BYTE* p = (const BYTE*)input;
|
590
596
|
const BYTE* const bEnd = p + len;
|
@@ -654,7 +660,7 @@ XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void*
|
|
654
660
|
|
655
661
|
|
656
662
|
|
657
|
-
|
663
|
+
FORCE_INLINE_TEMPLATE U32 XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian)
|
658
664
|
{
|
659
665
|
const BYTE * p = (const BYTE*)state->mem32;
|
660
666
|
const BYTE* const bEnd = (const BYTE*)(state->mem32) + state->memsize;
|
@@ -704,7 +710,7 @@ XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state_in)
|
|
704
710
|
|
705
711
|
/* **** XXH64 **** */
|
706
712
|
|
707
|
-
|
713
|
+
FORCE_INLINE_TEMPLATE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian)
|
708
714
|
{
|
709
715
|
const BYTE* p = (const BYTE*)input;
|
710
716
|
const BYTE* const bEnd = p + len;
|
@@ -771,7 +777,7 @@ XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void*
|
|
771
777
|
|
772
778
|
|
773
779
|
|
774
|
-
|
780
|
+
FORCE_INLINE_TEMPLATE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian)
|
775
781
|
{
|
776
782
|
const BYTE * p = (const BYTE*)state->mem64;
|
777
783
|
const BYTE* const bEnd = (const BYTE*)state->mem64 + state->memsize;
|
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
2
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree
|
7
|
-
*
|
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
8
|
*/
|
9
9
|
|
10
10
|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
2
|
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
3
|
* All rights reserved.
|
4
4
|
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree
|
7
|
-
*
|
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
8
|
*/
|
9
9
|
|
10
10
|
#ifndef ZSTD_ERRORS_H_398273423
|
@@ -37,43 +37,41 @@ extern "C" {
|
|
37
37
|
/*-****************************************
|
38
38
|
* error codes list
|
39
39
|
* note : this API is still considered unstable
|
40
|
-
*
|
40
|
+
* and shall not be used with a dynamic library.
|
41
41
|
* only static linking is allowed
|
42
42
|
******************************************/
|
43
43
|
typedef enum {
|
44
|
-
ZSTD_error_no_error,
|
45
|
-
ZSTD_error_GENERIC,
|
46
|
-
ZSTD_error_prefix_unknown,
|
47
|
-
ZSTD_error_version_unsupported,
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
ZSTD_error_seekableIO,
|
69
|
-
ZSTD_error_maxCode
|
44
|
+
ZSTD_error_no_error = 0,
|
45
|
+
ZSTD_error_GENERIC = 1,
|
46
|
+
ZSTD_error_prefix_unknown = 10,
|
47
|
+
ZSTD_error_version_unsupported = 12,
|
48
|
+
ZSTD_error_frameParameter_unsupported = 14,
|
49
|
+
ZSTD_error_frameParameter_windowTooLarge = 16,
|
50
|
+
ZSTD_error_corruption_detected = 20,
|
51
|
+
ZSTD_error_checksum_wrong = 22,
|
52
|
+
ZSTD_error_dictionary_corrupted = 30,
|
53
|
+
ZSTD_error_dictionary_wrong = 32,
|
54
|
+
ZSTD_error_dictionaryCreation_failed = 34,
|
55
|
+
ZSTD_error_parameter_unsupported = 40,
|
56
|
+
ZSTD_error_parameter_outOfBound = 42,
|
57
|
+
ZSTD_error_tableLog_tooLarge = 44,
|
58
|
+
ZSTD_error_maxSymbolValue_tooLarge = 46,
|
59
|
+
ZSTD_error_maxSymbolValue_tooSmall = 48,
|
60
|
+
ZSTD_error_stage_wrong = 60,
|
61
|
+
ZSTD_error_init_missing = 62,
|
62
|
+
ZSTD_error_memory_allocation = 64,
|
63
|
+
ZSTD_error_dstSize_tooSmall = 70,
|
64
|
+
ZSTD_error_srcSize_wrong = 72,
|
65
|
+
ZSTD_error_frameIndex_tooLarge = 100,
|
66
|
+
ZSTD_error_seekableIO = 102,
|
67
|
+
ZSTD_error_maxCode = 120 /* never EVER use this value directly, it may change in future versions! Use ZSTD_isError() instead */
|
70
68
|
} ZSTD_ErrorCode;
|
71
69
|
|
72
70
|
/*! ZSTD_getErrorCode() :
|
73
71
|
convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
|
74
72
|
which can be used to compare with enum list published above */
|
75
73
|
ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
|
76
|
-
ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code);
|
74
|
+
ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */
|
77
75
|
|
78
76
|
|
79
77
|
#if defined (__cplusplus)
|