Skip to content

Commit 4e234eb

Browse files
committed
Update zstd to v1.5.2
1 parent 2dfc01a commit 4e234eb

27 files changed

+508
-340
lines changed

ext/zstdruby/libzstd/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ $(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
212212

213213
$(ZSTD_DYNLIB_DIR)/%.o : %.S | $(ZSTD_DYNLIB_DIR)
214214
@echo AS $@
215-
$(COMPILE.c) $(OUTPUT_OPTION) $<
215+
$(COMPILE.S) $(OUTPUT_OPTION) $<
216216

217217
$(ZSTD_STATLIB_DIR)/%.o : %.S | $(ZSTD_STATLIB_DIR)
218218
@echo AS $@
219-
$(COMPILE.c) $(OUTPUT_OPTION) $<
219+
$(COMPILE.S) $(OUTPUT_OPTION) $<
220220

221221
MKDIR ?= mkdir
222222
$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):

ext/zstdruby/libzstd/common/pool.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static void* POOL_thread(void* opaque) {
8686
{ POOL_job const job = ctx->queue[ctx->queueHead];
8787
ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
8888
ctx->numThreadsBusy++;
89-
ctx->queueEmpty = ctx->queueHead == ctx->queueTail;
89+
ctx->queueEmpty = (ctx->queueHead == ctx->queueTail);
9090
/* Unlock the mutex, signal a pusher, and run the job */
9191
ZSTD_pthread_cond_signal(&ctx->queuePushCond);
9292
ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
@@ -105,6 +105,7 @@ static void* POOL_thread(void* opaque) {
105105
assert(0); /* Unreachable */
106106
}
107107

108+
/* ZSTD_createThreadPool() : public access point */
108109
POOL_ctx* ZSTD_createThreadPool(size_t numThreads) {
109110
return POOL_create (numThreads, 0);
110111
}
@@ -114,7 +115,8 @@ POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
114115
}
115116

116117
POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
117-
ZSTD_customMem customMem) {
118+
ZSTD_customMem customMem)
119+
{
118120
POOL_ctx* ctx;
119121
/* Check parameters */
120122
if (!numThreads) { return NULL; }
@@ -192,7 +194,7 @@ void ZSTD_freeThreadPool (ZSTD_threadPool* pool) {
192194
POOL_free (pool);
193195
}
194196

195-
size_t POOL_sizeof(POOL_ctx *ctx) {
197+
size_t POOL_sizeof(const POOL_ctx* ctx) {
196198
if (ctx==NULL) return 0; /* supports sizeof NULL */
197199
return sizeof(*ctx)
198200
+ ctx->queueSize * sizeof(POOL_job)
@@ -257,7 +259,8 @@ static int isQueueFull(POOL_ctx const* ctx) {
257259
}
258260

259261

260-
static void POOL_add_internal(POOL_ctx* ctx, POOL_function function, void *opaque)
262+
static void
263+
POOL_add_internal(POOL_ctx* ctx, POOL_function function, void *opaque)
261264
{
262265
POOL_job const job = {function, opaque};
263266
assert(ctx != NULL);
@@ -313,7 +316,9 @@ POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
313316
return POOL_create_advanced(numThreads, queueSize, ZSTD_defaultCMem);
314317
}
315318

316-
POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize, ZSTD_customMem customMem) {
319+
POOL_ctx*
320+
POOL_create_advanced(size_t numThreads, size_t queueSize, ZSTD_customMem customMem)
321+
{
317322
(void)numThreads;
318323
(void)queueSize;
319324
(void)customMem;
@@ -341,7 +346,7 @@ int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque) {
341346
return 1;
342347
}
343348

344-
size_t POOL_sizeof(POOL_ctx* ctx) {
349+
size_t POOL_sizeof(const POOL_ctx* ctx) {
345350
if (ctx==NULL) return 0; /* supports sizeof NULL */
346351
assert(ctx == &g_poolCtx);
347352
return sizeof(*ctx);

ext/zstdruby/libzstd/common/pool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int POOL_resize(POOL_ctx* ctx, size_t numThreads);
5353
* @return threadpool memory usage
5454
* note : compatible with NULL (returns 0 in this case)
5555
*/
56-
size_t POOL_sizeof(POOL_ctx* ctx);
56+
size_t POOL_sizeof(const POOL_ctx* ctx);
5757

5858
/*! POOL_function :
5959
* The function type that can be added to a thread pool.
@@ -70,7 +70,7 @@ void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque);
7070

7171

7272
/*! POOL_tryAdd() :
73-
* Add the job `function(opaque)` to thread pool _if_ a worker is available.
73+
* Add the job `function(opaque)` to thread pool _if_ a queue slot is available.
7474
* Returns immediately even if not (does not block).
7575
* @return : 1 if successful, 0 if not.
7676
*/

ext/zstdruby/libzstd/common/portability_macros.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
# endif
6666
#endif
6767

68+
/* Mark the internal assembly functions as hidden */
69+
#ifdef __ELF__
70+
# define ZSTD_HIDE_ASM_FUNCTION(func) .hidden func
71+
#else
72+
# define ZSTD_HIDE_ASM_FUNCTION(func)
73+
#endif
6874

6975
/* Enable runtime BMI2 dispatch based on the CPU.
7076
* Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.

ext/zstdruby/libzstd/common/zstd_internal.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ extern "C" {
6767
#define ZSTD_OPT_NUM (1<<12)
6868

6969
#define ZSTD_REP_NUM 3 /* number of repcodes */
70-
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
7170
static UNUSED_ATTR const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
7271

7372
#define KB *(1 <<10)
@@ -285,9 +284,9 @@ typedef enum {
285284
* Private declarations
286285
*********************************************/
287286
typedef struct seqDef_s {
288-
U32 offset; /* offset == rawOffset + ZSTD_REP_NUM, or equivalently, offCode + 1 */
287+
U32 offBase; /* offBase == Offset + ZSTD_REP_NUM, or repcode 1,2,3 */
289288
U16 litLength;
290-
U16 matchLength;
289+
U16 mlBase; /* mlBase == matchLength - MINMATCH */
291290
} seqDef;
292291

293292
/* Controls whether seqStore has a single "long" litLength or matchLength. See seqStore_t. */
@@ -329,7 +328,7 @@ MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore
329328
{
330329
ZSTD_sequenceLength seqLen;
331330
seqLen.litLength = seq->litLength;
332-
seqLen.matchLength = seq->matchLength + MINMATCH;
331+
seqLen.matchLength = seq->mlBase + MINMATCH;
333332
if (seqStore->longLengthPos == (U32)(seq - seqStore->sequencesStart)) {
334333
if (seqStore->longLengthType == ZSTD_llt_literalLength) {
335334
seqLen.litLength += 0xFFFF;

0 commit comments

Comments
 (0)