Skip to content

Commit 2657582

Browse files
authored
Merge pull request #19 from SpringMT/update-zstd-for-v1.4.0
Update zstd to v1.4.0
2 parents 6230080 + dfcef61 commit 2657582

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2336
-1548
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
sudo: false
22
language: ruby
33
rvm:
4-
- 2.6.0
5-
- 2.5.3
6-
- 2.4.5
7-
- 2.3.8
4+
- 2.6
5+
- 2.5
6+
- 2.4
7+
- 2.3
88
- 2.2
99

10-
before_install: gem install bundler -v 1.14.3
10+
before_install:
11+
- gem install bundler -v 1.14.3
1112

1213
before_script:
1314
- bundle exec rake compile

README.md

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

1212
## Zstd version
13-
v1.3.8 (https://github.com/facebook/zstd/tree/v1.3.8)
13+
v1.4.0 (https://github.com/facebook/zstd/tree/v1.4.0)
1414

1515
## Installation
1616

ext/zstdruby/libzstd/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525
CFLAGS ?= -O3
2626
DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
2727
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
28-
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
28+
-Wstrict-prototypes -Wundef -Wpointer-arith \
2929
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
3030
-Wredundant-decls -Wmissing-prototypes -Wc++-compat
3131
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
@@ -56,6 +56,7 @@ ZSTD_FORCE_DECOMPRESS_SHORT ?= 0
5656
ZSTD_FORCE_DECOMPRESS_LONG ?= 0
5757
ZSTD_NO_INLINE ?= 0
5858
ZSTD_STRIP_ERROR_STRINGS ?= 0
59+
ZSTD_LEGACY_MULTITHREADED_API ?= 0
5960

6061
ifeq ($(ZSTD_LIB_COMPRESSION), 0)
6162
ZSTD_LIB_DICTBUILDER = 0
@@ -107,6 +108,10 @@ ifneq ($(ZSTD_STRIP_ERROR_STRINGS), 0)
107108
CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
108109
endif
109110

111+
ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
112+
CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
113+
endif
114+
110115
ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
111116
ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
112117
ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
@@ -151,8 +156,7 @@ ifneq (,$(filter Windows%,$(OS)))
151156
LIBZSTD = dll\libzstd.dll
152157
$(LIBZSTD): $(ZSTD_FILES)
153158
@echo compiling dynamic library $(LIBVER)
154-
@$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -shared $^ -o $@
155-
dlltool -D $@ -d dll\libzstd.def -l dll\libzstd.lib
159+
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll\libzstd.lib -shared $^ -o $@
156160

157161
else
158162

ext/zstdruby/libzstd/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ note that it's necessary to request the `-pthread` flag during link stage.
3131

3232
Multithreading capabilities are exposed
3333
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.3.8/lib/zstd.h#L592).
34-
This API is still labelled experimental,
35-
but is expected to become "stable" in the near future.
3634

3735

3836
#### API
@@ -110,6 +108,10 @@ The file structure is designed to make this selection manually achievable for an
110108
which removes the error messages that are otherwise returned by
111109
`ZSTD_getErrorName`.
112110

111+
- While invoking `make libzstd`, the build macro `ZSTD_LEGACY_MULTITHREADED_API=1`
112+
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
113+
the shared library, which is now hidden by default.
114+
113115

114116
#### Windows : using MinGW+MSYS to create DLL
115117

ext/zstdruby/libzstd/common/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
/**
4242
* FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
43-
* parameters. They must be inlined for the compiler to elimininate the constant
43+
* parameters. They must be inlined for the compiler to eliminate the constant
4444
* branches.
4545
*/
4646
#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR

ext/zstdruby/libzstd/common/fse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size
358358
typedef enum {
359359
FSE_repeat_none, /**< Cannot use the previous table */
360360
FSE_repeat_check, /**< Can use the previous table but it must be checked */
361-
FSE_repeat_valid /**< Can use the previous table and it is asumed to be valid */
361+
FSE_repeat_valid /**< Can use the previous table and it is assumed to be valid */
362362
} FSE_repeat;
363363

364364
/* *****************************************

ext/zstdruby/libzstd/common/threading.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* This file will hold wrapper for systems, which do not support pthreads
1515
*/
1616

17-
/* create fake symbol to avoid empty trnaslation unit warning */
18-
int g_ZSTD_threading_useles_symbol;
17+
/* create fake symbol to avoid empty translation unit warning */
18+
int g_ZSTD_threading_useless_symbol;
1919

2020
#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
2121

ext/zstdruby/libzstd/common/xxhash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
/* #define XXH_ACCEPT_NULL_INPUT_POINTER 1 */
6767

6868
/*!XXH_FORCE_NATIVE_FORMAT :
69-
* By default, xxHash library provides endian-independant Hash values, based on little-endian convention.
69+
* By default, xxHash library provides endian-independent Hash values, based on little-endian convention.
7070
* Results are therefore identical for little-endian and big-endian CPU.
7171
* This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format.
72-
* Should endian-independance be of no importance for your application, you may set the #define below to 1,
72+
* Should endian-independence be of no importance for your application, you may set the #define below to 1,
7373
* to improve speed for Big-endian CPU.
7474
* This option has no impact on Little_Endian CPU.
7575
*/

ext/zstdruby/libzstd/common/zstd_internal.h

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,50 @@ extern "C" {
5353
#undef MAX
5454
#define MIN(a,b) ((a)<(b) ? (a) : (b))
5555
#define MAX(a,b) ((a)>(b) ? (a) : (b))
56-
#define CHECK_F(f) { size_t const errcod = f; if (ERR_isError(errcod)) return errcod; } /* check and Forward error code */
57-
#define CHECK_E(f, e) { size_t const errcod = f; if (ERR_isError(errcod)) return ERROR(e); } /* check and send Error code */
56+
57+
/**
58+
* Return the specified error if the condition evaluates to true.
59+
*
60+
* In debug modes, prints additional information. In order to do that
61+
* (particularly, printing the conditional that failed), this can't just wrap
62+
* RETURN_ERROR().
63+
*/
64+
#define RETURN_ERROR_IF(cond, err, ...) \
65+
if (cond) { \
66+
RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \
67+
RAWLOG(3, ": " __VA_ARGS__); \
68+
RAWLOG(3, "\n"); \
69+
return ERROR(err); \
70+
}
71+
72+
/**
73+
* Unconditionally return the specified error.
74+
*
75+
* In debug modes, prints additional information.
76+
*/
77+
#define RETURN_ERROR(err, ...) \
78+
do { \
79+
RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(ERROR(err))); \
80+
RAWLOG(3, ": " __VA_ARGS__); \
81+
RAWLOG(3, "\n"); \
82+
return ERROR(err); \
83+
} while(0);
84+
85+
/**
86+
* If the provided expression evaluates to an error code, returns that error code.
87+
*
88+
* In debug modes, prints additional information.
89+
*/
90+
#define FORWARD_IF_ERROR(err, ...) \
91+
do { \
92+
size_t const err_code = (err); \
93+
if (ERR_isError(err_code)) { \
94+
RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", __FILE__, __LINE__, ZSTD_QUOTE(err), ERR_getErrorName(err_code)); \
95+
RAWLOG(3, ": " __VA_ARGS__); \
96+
RAWLOG(3, "\n"); \
97+
return err_code; \
98+
} \
99+
} while(0);
58100

59101

60102
/*-*************************************
@@ -200,6 +242,17 @@ typedef struct {
200242
U32 longLengthPos;
201243
} seqStore_t;
202244

245+
/**
246+
* Contains the compressed frame size and an upper-bound for the decompressed frame size.
247+
* Note: before using `compressedSize`, check for errors using ZSTD_isError().
248+
* similarly, before using `decompressedBound`, check for errors using:
249+
* `decompressedBound != ZSTD_CONTENTSIZE_ERROR`
250+
*/
251+
typedef struct {
252+
size_t compressedSize;
253+
unsigned long long decompressedBound;
254+
} ZSTD_frameSizeInfo; /* decompress & legacy */
255+
203256
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
204257
void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
205258

ext/zstdruby/libzstd/compress/fse_compress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ size_t FSE_buildCTable_wksp(FSE_CTable* ct,
129129
{ U32 position = 0;
130130
U32 symbol;
131131
for (symbol=0; symbol<=maxSymbolValue; symbol++) {
132-
int nbOccurences;
132+
int nbOccurrences;
133133
int const freq = normalizedCounter[symbol];
134-
for (nbOccurences=0; nbOccurences<freq; nbOccurences++) {
134+
for (nbOccurrences=0; nbOccurrences<freq; nbOccurrences++) {
135135
tableSymbol[position] = (FSE_FUNCTION_TYPE)symbol;
136136
position = (position + step) & tableMask;
137137
while (position > highThreshold)

0 commit comments

Comments
 (0)