Skip to content

Commit 67d7191

Browse files
authored
Merge pull request #11 from SpringMT/update-zstd-for-v1.3.3
Update zstd to v1.3.3
2 parents 946b5cb + 838e9fe commit 67d7191

34 files changed

+1563
-1910
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ See https://github.com/facebook/zstd
99
Fork from https://github.com/jarredholman/ruby-zstd.
1010

1111
## Zstd version
12-
v1.3.2 (https://github.com/facebook/zstd/tree/v1.3.2)
12+
v1.3.3 (https://github.com/facebook/zstd/tree/v1.3.3)
1313

1414
## Installation
1515

ext/zstdruby/libzstd/BUCK

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,17 @@ cxx_library(
1515
header_namespace='',
1616
visibility=['PUBLIC'],
1717
exported_headers=subdir_glob([
18-
('compress', 'zstdmt_compress.h'),
18+
('compress', 'zstd*.h'),
1919
]),
20-
headers=subdir_glob([
21-
('compress', 'zstd_opt.h'),
22-
]),
23-
srcs=[
24-
'compress/zstd_compress.c',
25-
'compress/zstdmt_compress.c',
26-
],
20+
srcs=glob(['compress/zstd*.c']),
2721
deps=[':common'],
2822
)
2923

3024
cxx_library(
3125
name='decompress',
3226
header_namespace='',
3327
visibility=['PUBLIC'],
34-
srcs=['decompress/zstd_decompress.c'],
28+
srcs=glob(['decompress/zstd*.c']),
3529
deps=[
3630
':common',
3731
':legacy',
@@ -58,6 +52,9 @@ cxx_library(
5852
]),
5953
srcs=glob(['legacy/*.c']),
6054
deps=[':common'],
55+
exported_preprocessor_flags=[
56+
'-DZSTD_LEGACY_SUPPORT=4',
57+
],
6158
)
6259

6360
cxx_library(
@@ -74,6 +71,15 @@ cxx_library(
7471
deps=[':common'],
7572
)
7673

74+
cxx_library(
75+
name='compiler',
76+
header_namespace='',
77+
visibility=['PUBLIC'],
78+
exported_headers=subdir_glob([
79+
('common', 'compiler.h'),
80+
]),
81+
)
82+
7783
cxx_library(
7884
name='bitstream',
7985
header_namespace='',
@@ -100,6 +106,7 @@ cxx_library(
100106
],
101107
deps=[
102108
':bitstream',
109+
':compiler',
103110
':errors',
104111
':mem',
105112
],
@@ -133,7 +140,10 @@ cxx_library(
133140
('common', 'pool.h'),
134141
]),
135142
srcs=['common/pool.c'],
136-
deps=[':threading'],
143+
deps=[
144+
':threading',
145+
':zstd_common',
146+
],
137147
)
138148

139149
cxx_library(
@@ -144,6 +154,12 @@ cxx_library(
144154
('common', 'threading.h'),
145155
]),
146156
srcs=['common/threading.c'],
157+
exported_preprocessor_flags=[
158+
'-DZSTD_MULTITHREAD',
159+
],
160+
exported_linker_flags=[
161+
'-pthread',
162+
],
147163
)
148164

149165
cxx_library(
@@ -154,6 +170,9 @@ cxx_library(
154170
('common', 'xxhash.h'),
155171
]),
156172
srcs=['common/xxhash.c'],
173+
exported_preprocessor_flags=[
174+
'-DXXH_NAMESPACE=ZSTD_',
175+
],
157176
)
158177

159178
cxx_library(
@@ -166,6 +185,7 @@ cxx_library(
166185
]),
167186
srcs=['common/zstd_common.c'],
168187
deps=[
188+
':compiler',
169189
':errors',
170190
':mem',
171191
],
@@ -175,6 +195,7 @@ cxx_library(
175195
name='common',
176196
deps=[
177197
':bitstream',
198+
':compiler',
178199
':entropy',
179200
':errors',
180201
':mem',

ext/zstdruby/libzstd/common/bitstream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits);
167167
/*-**************************************************************
168168
* Internal functions
169169
****************************************************************/
170-
MEM_STATIC unsigned BIT_highbit32 (register U32 val)
170+
MEM_STATIC unsigned BIT_highbit32 (U32 val)
171171
{
172172
assert(val != 0);
173173
{

ext/zstdruby/libzstd/common/mem.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (size
5656
typedef int32_t S32;
5757
typedef uint64_t U64;
5858
typedef int64_t S64;
59-
typedef intptr_t iPtrDiff;
60-
typedef uintptr_t uPtrDiff;
6159
#else
6260
typedef unsigned char BYTE;
6361
typedef unsigned short U16;
@@ -66,8 +64,6 @@ MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (size
6664
typedef signed int S32;
6765
typedef unsigned long long U64;
6866
typedef signed long long S64;
69-
typedef ptrdiff_t iPtrDiff;
70-
typedef size_t uPtrDiff;
7167
#endif
7268

7369

@@ -123,20 +119,26 @@ MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
123119
/* currently only defined for gcc and icc */
124120
#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32))
125121
__pragma( pack(push, 1) )
126-
typedef union { U16 u16; U32 u32; U64 u64; size_t st; } unalign;
122+
typedef struct { U16 v; } unalign16;
123+
typedef struct { U32 v; } unalign32;
124+
typedef struct { U64 v; } unalign64;
125+
typedef struct { size_t v; } unalignArch;
127126
__pragma( pack(pop) )
128127
#else
129-
typedef union { U16 u16; U32 u32; U64 u64; size_t st; } __attribute__((packed)) unalign;
128+
typedef struct { U16 v; } __attribute__((packed)) unalign16;
129+
typedef struct { U32 v; } __attribute__((packed)) unalign32;
130+
typedef struct { U64 v; } __attribute__((packed)) unalign64;
131+
typedef struct { size_t v; } __attribute__((packed)) unalignArch;
130132
#endif
131133

132-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
133-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
134-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
135-
MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalign*)ptr)->st; }
134+
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign16*)ptr)->v; }
135+
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign32*)ptr)->v; }
136+
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign64*)ptr)->v; }
137+
MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalignArch*)ptr)->v; }
136138

137-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
138-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; }
139-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign*)memPtr)->u64 = value; }
139+
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign16*)memPtr)->v = value; }
140+
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign32*)memPtr)->v = value; }
141+
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign64*)memPtr)->v = value; }
140142

141143
#else
142144

ext/zstdruby/libzstd/common/pool.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
/* ====== Dependencies ======= */
1313
#include <stddef.h> /* size_t */
14-
#include <stdlib.h> /* malloc, calloc, free */
1514
#include "pool.h"
1615

1716
/* ====== Compiler specifics ====== */
@@ -115,7 +114,7 @@ POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize, ZSTD_customM
115114
* and full queues.
116115
*/
117116
ctx->queueSize = queueSize + 1;
118-
ctx->queue = (POOL_job*) malloc(ctx->queueSize * sizeof(POOL_job));
117+
ctx->queue = (POOL_job*)ZSTD_malloc(ctx->queueSize * sizeof(POOL_job), customMem);
119118
ctx->queueHead = 0;
120119
ctx->queueTail = 0;
121120
ctx->numThreadsBusy = 0;

ext/zstdruby/libzstd/common/zstd_common.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,27 @@ const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
3131
* ZSTD Error Management
3232
******************************************/
3333
/*! ZSTD_isError() :
34-
* tells if a return value is an error code */
34+
* tells if a return value is an error code */
3535
unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
3636

3737
/*! ZSTD_getErrorName() :
38-
* provides error code string from function result (useful for debugging) */
38+
* provides error code string from function result (useful for debugging) */
3939
const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
4040

4141
/*! ZSTD_getError() :
42-
* convert a `size_t` function result into a proper ZSTD_errorCode enum */
42+
* convert a `size_t` function result into a proper ZSTD_errorCode enum */
4343
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
4444

4545
/*! ZSTD_getErrorString() :
46-
* provides error code string from enum */
46+
* provides error code string from enum */
4747
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
4848

49+
/*! g_debuglog_enable :
50+
* turn on/off debug traces (global switch) */
51+
#if defined(ZSTD_DEBUG) && (ZSTD_DEBUG >= 2)
52+
int g_debuglog_enable = 1;
53+
#endif
54+
4955

5056
/*=**************************************************************
5157
* Custom allocator

0 commit comments

Comments
 (0)