zstd-ruby 1.3.7.0 → 1.3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/zstdruby/libzstd/BUCK +15 -2
  4. data/ext/zstdruby/libzstd/Makefile +37 -2
  5. data/ext/zstdruby/libzstd/README.md +67 -41
  6. data/ext/zstdruby/libzstd/common/bitstream.h +2 -2
  7. data/ext/zstdruby/libzstd/common/compiler.h +19 -12
  8. data/ext/zstdruby/libzstd/common/cpu.h +1 -1
  9. data/ext/zstdruby/libzstd/common/debug.h +22 -11
  10. data/ext/zstdruby/libzstd/common/error_private.c +6 -0
  11. data/ext/zstdruby/libzstd/common/fse.h +2 -2
  12. data/ext/zstdruby/libzstd/common/huf.h +25 -1
  13. data/ext/zstdruby/libzstd/common/pool.c +1 -1
  14. data/ext/zstdruby/libzstd/common/zstd_common.c +3 -1
  15. data/ext/zstdruby/libzstd/common/zstd_errors.h +1 -0
  16. data/ext/zstdruby/libzstd/common/zstd_internal.h +11 -2
  17. data/ext/zstdruby/libzstd/compress/fse_compress.c +3 -3
  18. data/ext/zstdruby/libzstd/compress/hist.c +19 -11
  19. data/ext/zstdruby/libzstd/compress/hist.h +11 -8
  20. data/ext/zstdruby/libzstd/compress/huf_compress.c +33 -31
  21. data/ext/zstdruby/libzstd/compress/zstd_compress.c +621 -371
  22. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +90 -28
  23. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +4 -4
  24. data/ext/zstdruby/libzstd/compress/zstd_fast.c +15 -15
  25. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +25 -18
  26. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +18 -67
  27. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +2 -6
  28. data/ext/zstdruby/libzstd/compress/zstd_opt.c +133 -48
  29. data/ext/zstdruby/libzstd/compress/zstd_opt.h +8 -0
  30. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +229 -73
  31. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +18 -10
  32. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +178 -42
  33. data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +240 -0
  34. data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +44 -0
  35. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +244 -1680
  36. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +1307 -0
  37. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +59 -0
  38. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +168 -0
  39. data/ext/zstdruby/libzstd/dictBuilder/cover.c +13 -11
  40. data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +15 -15
  41. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +28 -28
  42. data/ext/zstdruby/libzstd/dll/libzstd.def +0 -1
  43. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -10
  44. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +15 -15
  45. data/ext/zstdruby/libzstd/zstd.h +1208 -968
  46. data/lib/zstd-ruby/version.rb +1 -1
  47. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35d073986861ccb9bdb6a87e3f7335dd5d08249913c668a6d6279aadcfca7551
4
- data.tar.gz: 315406589d9487c367edd70a2dc9c090dd796b0764fb1d4200a32b4375c430bc
3
+ metadata.gz: '09569e18846a17f43eb0a6b5cfad3b2b2f6839e725dea1f9470ec3a12335a54f'
4
+ data.tar.gz: 6f7820cc8eda43d8e0e5de6cb9f9b40dafee7a63de5f78c645bc523d67232c72
5
5
  SHA512:
6
- metadata.gz: 4395106140fe83001703df637cb1632f7ef17cba187d9935c385d30b8c3a06a8688d9a169f4c9cbd1cb1d53463b895c1e414503f8030b7115ff8e612510cba9b
7
- data.tar.gz: ab48fc82d7d1eef1179242839d93ea3cd2eb88e27b3dc4957d3457a4cf125bf0764f48b2c28ae626346bb3866c6a81114da2de6c75547f80a4e1589dc8032689
6
+ metadata.gz: 35e224f5a80c71a84accbd6ad8973b7718bc424341edb4c9421bf4af97c9e79492e2d536ebcd940c14d2c538adf79e0e51934557764a7cc1b0c62c22d6f40a6a
7
+ data.tar.gz: 2e89cc6b4ab292b72abed39fbe09dab3d3254aa5f4a92a5fdf155af325540a354ceccca7359c33f39ef8c15c44c4d2896ffb07955789f011244bc200be67f172
data/README.md CHANGED
@@ -10,7 +10,7 @@ See https://github.com/facebook/zstd
10
10
  Fork from https://github.com/jarredholman/ruby-zstd.
11
11
 
12
12
  ## Zstd version
13
- v1.3.7 (https://github.com/facebook/zstd/tree/v1.3.7)
13
+ v1.3.8 (https://github.com/facebook/zstd/tree/v1.3.8)
14
14
 
15
15
  ## Installation
16
16
 
@@ -1,6 +1,7 @@
1
1
  cxx_library(
2
2
  name='zstd',
3
3
  header_namespace='',
4
+ exported_headers=['zstd.h'],
4
5
  visibility=['PUBLIC'],
5
6
  deps=[
6
7
  ':common',
@@ -17,7 +18,7 @@ cxx_library(
17
18
  exported_headers=subdir_glob([
18
19
  ('compress', 'zstd*.h'),
19
20
  ]),
20
- srcs=glob(['compress/zstd*.c']),
21
+ srcs=glob(['compress/zstd*.c', 'compress/hist.c']),
21
22
  deps=[':common'],
22
23
  )
23
24
 
@@ -40,7 +41,7 @@ cxx_library(
40
41
  header_namespace='',
41
42
  visibility=['PUBLIC'],
42
43
  exported_headers=subdir_glob([
43
- ('decprecated', '*.h'),
44
+ ('deprecated', '*.h'),
44
45
  ]),
45
46
  srcs=glob(['deprecated/*.c']),
46
47
  deps=[':common'],
@@ -118,6 +119,7 @@ cxx_library(
118
119
  'decompress/huf_decompress.c',
119
120
  ],
120
121
  deps=[
122
+ ':debug',
121
123
  ':bitstream',
122
124
  ':compiler',
123
125
  ':errors',
@@ -204,9 +206,20 @@ cxx_library(
204
206
  ],
205
207
  )
206
208
 
209
+ cxx_library(
210
+ name='debug',
211
+ header_namespace='',
212
+ visibility=['PUBLIC'],
213
+ exported_headers=subdir_glob([
214
+ ('common', 'debug.h'),
215
+ ]),
216
+ srcs=['common/debug.c'],
217
+ )
218
+
207
219
  cxx_library(
208
220
  name='common',
209
221
  deps=[
222
+ ':debug',
210
223
  ':bitstream',
211
224
  ':compiler',
212
225
  ':cpu',
@@ -27,11 +27,16 @@ DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
27
27
  -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
28
28
  -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
29
29
  -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
30
- -Wredundant-decls -Wmissing-prototypes
30
+ -Wredundant-decls -Wmissing-prototypes -Wc++-compat
31
31
  CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
32
32
  FLAGS = $(CPPFLAGS) $(CFLAGS)
33
33
 
34
- GREP = grep --color=never
34
+ HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
35
+ GREP_OPTIONS ?=
36
+ ifeq ($HAVE_COLORNEVER, 1)
37
+ GREP_OPTIONS += --color=never
38
+ endif
39
+ GREP = grep $(GREP_OPTIONS)
35
40
 
36
41
  ZSTDCOMMON_FILES := $(sort $(wildcard common/*.c))
37
42
  ZSTDCOMP_FILES := $(sort $(wildcard compress/*.c))
@@ -45,6 +50,12 @@ ZSTD_LIB_COMPRESSION ?= 1
45
50
  ZSTD_LIB_DECOMPRESSION ?= 1
46
51
  ZSTD_LIB_DICTBUILDER ?= 1
47
52
  ZSTD_LIB_DEPRECATED ?= 1
53
+ HUF_FORCE_DECOMPRESS_X1 ?= 0
54
+ HUF_FORCE_DECOMPRESS_X2 ?= 0
55
+ ZSTD_FORCE_DECOMPRESS_SHORT ?= 0
56
+ ZSTD_FORCE_DECOMPRESS_LONG ?= 0
57
+ ZSTD_NO_INLINE ?= 0
58
+ ZSTD_STRIP_ERROR_STRINGS ?= 0
48
59
 
49
60
  ifeq ($(ZSTD_LIB_COMPRESSION), 0)
50
61
  ZSTD_LIB_DICTBUILDER = 0
@@ -72,6 +83,30 @@ ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
72
83
  ZSTD_FILES += $(ZDICT_FILES)
73
84
  endif
74
85
 
86
+ ifneq ($(HUF_FORCE_DECOMPRESS_X1), 0)
87
+ CFLAGS += -DHUF_FORCE_DECOMPRESS_X1
88
+ endif
89
+
90
+ ifneq ($(HUF_FORCE_DECOMPRESS_X2), 0)
91
+ CFLAGS += -DHUF_FORCE_DECOMPRESS_X2
92
+ endif
93
+
94
+ ifneq ($(ZSTD_FORCE_DECOMPRESS_SHORT), 0)
95
+ CFLAGS += -DZSTD_FORCE_DECOMPRESS_SHORT
96
+ endif
97
+
98
+ ifneq ($(ZSTD_FORCE_DECOMPRESS_LONG), 0)
99
+ CFLAGS += -DZSTD_FORCE_DECOMPRESS_LONG
100
+ endif
101
+
102
+ ifneq ($(ZSTD_NO_INLINE), 0)
103
+ CFLAGS += -DZSTD_NO_INLINE
104
+ endif
105
+
106
+ ifneq ($(ZSTD_STRIP_ERROR_STRINGS), 0)
107
+ CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
108
+ endif
109
+
75
110
  ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
76
111
  ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
77
112
  ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
@@ -7,13 +7,32 @@ in order to make it easier to select or exclude features.
7
7
 
8
8
  #### Building
9
9
 
10
- `Makefile` script is provided, supporting all standard [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions),
10
+ `Makefile` script is provided, supporting [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions),
11
11
  including commands variables, staged install, directory variables and standard targets.
12
12
  - `make` : generates both static and dynamic libraries
13
- - `make install` : install libraries in default system directories
13
+ - `make install` : install libraries and headers in target system directories
14
14
 
15
- `libzstd` default scope includes compression, decompression, dictionary building,
16
- and decoding support for legacy formats >= v0.5.0.
15
+ `libzstd` default scope is pretty large, including compression, decompression, dictionary builder,
16
+ and support for decoding legacy formats >= v0.5.0.
17
+ The scope can be reduced on demand (see paragraph _modular build_).
18
+
19
+
20
+ #### Multithreading support
21
+
22
+ Multithreading is disabled by default when building with `make`.
23
+ Enabling multithreading requires 2 conditions :
24
+ - set build macro `ZSTD_MULTITHREAD` (`-DZSTD_MULTITHREAD` for `gcc`)
25
+ - for POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
26
+
27
+ Both conditions are automatically applied when invoking `make lib-mt` target.
28
+
29
+ When linking a POSIX program with a multithreaded version of `libzstd`,
30
+ note that it's necessary to request the `-pthread` flag during link stage.
31
+
32
+ Multithreading capabilities are exposed
33
+ 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.
17
36
 
18
37
 
19
38
  #### API
@@ -26,63 +45,70 @@ Zstandard's stable API is exposed within [lib/zstd.h](zstd.h).
26
45
  Optional advanced features are exposed via :
27
46
 
28
47
  - `lib/common/zstd_errors.h` : translates `size_t` function results
29
- into an `ZSTD_ErrorCode`, for accurate error handling.
48
+ into a `ZSTD_ErrorCode`, for accurate error handling.
49
+
30
50
  - `ZSTD_STATIC_LINKING_ONLY` : if this macro is defined _before_ including `zstd.h`,
31
- it unlocks access to advanced experimental API,
32
- exposed in second part of `zstd.h`.
33
- These APIs are not "stable", their definition may change in the future.
34
- As a consequence, it shall ___never be used with dynamic library___ !
51
+ it unlocks access to the experimental API,
52
+ exposed in the second part of `zstd.h`.
53
+ All definitions in the experimental APIs are unstable,
54
+ they may still change in the future, or even be removed.
55
+ As a consequence, experimental definitions shall ___never be used with dynamic library___ !
35
56
  Only static linking is allowed.
36
57
 
37
58
 
38
59
  #### Modular build
39
60
 
40
- It's possible to compile only a limited set of features.
61
+ It's possible to compile only a limited set of features within `libzstd`.
62
+ The file structure is designed to make this selection manually achievable for any build system :
41
63
 
42
64
  - Directory `lib/common` is always required, for all variants.
65
+
43
66
  - Compression source code lies in `lib/compress`
67
+
44
68
  - Decompression source code lies in `lib/decompress`
69
+
45
70
  - It's possible to include only `compress` or only `decompress`, they don't depend on each other.
71
+
46
72
  - `lib/dictBuilder` : makes it possible to generate dictionaries from a set of samples.
47
73
  The API is exposed in `lib/dictBuilder/zdict.h`.
48
74
  This module depends on both `lib/common` and `lib/compress` .
49
- - `lib/legacy` : source code to decompress legacy zstd formats, starting from `v0.1.0`.
75
+
76
+ - `lib/legacy` : makes it possible to decompress legacy zstd formats, starting from `v0.1.0`.
50
77
  This module depends on `lib/common` and `lib/decompress`.
51
78
  To enable this feature, define `ZSTD_LEGACY_SUPPORT` during compilation.
52
79
  Specifying a number limits versions supported to that version onward.
53
80
  For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats >= v0.2.0".
54
- `ZSTD_LEGACY_SUPPORT=3` means : "support legacy formats >= v0.3.0", and so on.
55
- Currently, the default library setting is `ZST_LEGACY_SUPPORT=5`.
56
- It can be changed at build by any other value.
57
- Note that any number >= 8 translates into "do __not__ support legacy formats",
58
- since all versions of `zstd` >= v0.8 are compatible with v1+ specification.
59
- `ZSTD_LEGACY_SUPPORT=0` also means "do __not__ support legacy formats".
60
- Once enabled, this capability is transparently triggered within decompression functions.
61
- It's also possible to invoke directly legacy API, as exposed in `lib/legacy/zstd_legacy.h`.
62
- Each version also provides an additional dedicated set of advanced API.
81
+ Conversely, `ZSTD_LEGACY_SUPPORT=0` means "do __not__ support legacy formats".
82
+ By default, this build macro is set as `ZSTD_LEGACY_SUPPORT=5`.
83
+ Decoding supported legacy format is a transparent capability triggered within decompression functions.
84
+ It's also allowed to invoke legacy API directly, exposed in `lib/legacy/zstd_legacy.h`.
85
+ Each version does also provide its own set of advanced API.
63
86
  For example, advanced API for version `v0.4` is exposed in `lib/legacy/zstd_v04.h` .
64
- Note : `lib/legacy` only supports _decoding_ legacy formats.
65
- - Similarly, you can define `ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
66
- and `ZSTD_LIB_DEPRECATED` as 0 to forgo compilation of the corresponding features. This will
67
- also disable compilation of all dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
68
- dictBuilder).
69
87
 
88
+ - While invoking `make libzstd`, it's possible to define build macros
89
+ `ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
90
+ and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the corresponding features.
91
+ This will also disable compilation of all dependencies
92
+ (eg. `ZSTD_LIB_COMPRESSION=0` will also disable dictBuilder).
70
93
 
71
- #### Multithreading support
94
+ - There are some additional build macros that can be used to minify the decoder.
72
95
 
73
- Multithreading is disabled by default when building with `make`.
74
- Enabling multithreading requires 2 conditions :
75
- - set macro `ZSTD_MULTITHREAD`
76
- - on POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
77
-
78
- Both conditions are automatically triggered by invoking `make lib-mt` target.
79
- Note that, when linking a POSIX program with a multithreaded version of `libzstd`,
80
- it's necessary to trigger `-pthread` flag during link stage.
96
+ Zstandard often has more than one implementation of a piece of functionality,
97
+ where each implementation optimizes for different scenarios. For example, the
98
+ Huffman decoder has complementary implementations that decode the stream one
99
+ symbol at a time or two symbols at a time. Zstd normally includes both (and
100
+ dispatches between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1`
101
+ or `HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
102
+ compilation of the other. Similarly, `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`
103
+ and `ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG` force the compilation and use of
104
+ only one or the other of two decompression implementations. The smallest
105
+ binary is achieved by using `HUF_FORCE_DECOMPRESS_X1` and
106
+ `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`.
81
107
 
82
- Multithreading capabilities are exposed
83
- via [advanced API `ZSTD_compress_generic()` defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/dev/lib/zstd.h#L919).
84
- This API is still considered experimental,
85
- but is expected to become "stable" at some point in the future.
108
+ For squeezing the last ounce of size out, you can also define
109
+ `ZSTD_NO_INLINE`, which disables inlining, and `ZSTD_STRIP_ERROR_STRINGS`,
110
+ which removes the error messages that are otherwise returned by
111
+ `ZSTD_getErrorName`.
86
112
 
87
113
 
88
114
  #### Windows : using MinGW+MSYS to create DLL
@@ -113,8 +139,8 @@ Consider migrating code towards supported streaming API exposed in `zstd.h`.
113
139
 
114
140
  The other files are not source code. There are :
115
141
 
116
- - `LICENSE` : contains the BSD license text
117
- - `Makefile` : `make` script to build and install zstd library (static and dynamic)
118
142
  - `BUCK` : support for `buck` build system (https://buckbuild.com/)
119
- - `libzstd.pc.in` : for `pkg-config` (used in `make install`)
143
+ - `Makefile` : `make` script to build and install zstd library (static and dynamic)
120
144
  - `README.md` : this file
145
+ - `dll/` : resources directory for Windows compilation
146
+ - `libzstd.pc.in` : script for `pkg-config` (used in `make install`)
@@ -389,7 +389,7 @@ MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
389
389
  * Read (consume) next n bits from local register and update.
390
390
  * Pay attention to not read more than nbBits contained into local register.
391
391
  * @return : extracted value. */
392
- MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits)
392
+ MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
393
393
  {
394
394
  size_t const value = BIT_lookBits(bitD, nbBits);
395
395
  BIT_skipBits(bitD, nbBits);
@@ -398,7 +398,7 @@ MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits)
398
398
 
399
399
  /*! BIT_readBitsFast() :
400
400
  * unsafe version; only works only if nbBits >= 1 */
401
- MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
401
+ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
402
402
  {
403
403
  size_t const value = BIT_lookBitsFast(bitD, nbBits);
404
404
  assert(nbBits >= 1);
@@ -15,6 +15,8 @@
15
15
  * Compiler specifics
16
16
  *********************************************************/
17
17
  /* force inlining */
18
+
19
+ #if !defined(ZSTD_NO_INLINE)
18
20
  #if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
19
21
  # define INLINE_KEYWORD inline
20
22
  #else
@@ -29,6 +31,13 @@
29
31
  # define FORCE_INLINE_ATTR
30
32
  #endif
31
33
 
34
+ #else
35
+
36
+ #define INLINE_KEYWORD
37
+ #define FORCE_INLINE_ATTR
38
+
39
+ #endif
40
+
32
41
  /**
33
42
  * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
34
43
  * parameters. They must be inlined for the compiler to elimininate the constant
@@ -89,23 +98,21 @@
89
98
  #endif
90
99
 
91
100
  /* prefetch
92
- * can be disabled, by declaring NO_PREFETCH macro
93
- * All prefetch invocations use a single default locality 2,
94
- * generating instruction prefetcht1,
95
- * which, according to Intel, means "load data into L2 cache".
96
- * This is a good enough "middle ground" for the time being,
97
- * though in theory, it would be better to specialize locality depending on data being prefetched.
98
- * Tests could not determine any sensible difference based on locality value. */
101
+ * can be disabled, by declaring NO_PREFETCH build macro */
99
102
  #if defined(NO_PREFETCH)
100
- # define PREFETCH(ptr) (void)(ptr) /* disabled */
103
+ # define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
104
+ # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
101
105
  #else
102
106
  # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
103
107
  # include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
104
- # define PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
108
+ # define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
109
+ # define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
105
110
  # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
106
- # define PREFETCH(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
111
+ # define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
112
+ # define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
107
113
  # else
108
- # define PREFETCH(ptr) (void)(ptr) /* disabled */
114
+ # define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
115
+ # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
109
116
  # endif
110
117
  #endif /* NO_PREFETCH */
111
118
 
@@ -116,7 +123,7 @@
116
123
  size_t const _size = (size_t)(s); \
117
124
  size_t _pos; \
118
125
  for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
119
- PREFETCH(_ptr + _pos); \
126
+ PREFETCH_L2(_ptr + _pos); \
120
127
  } \
121
128
  }
122
129
 
@@ -78,7 +78,7 @@ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
78
78
  __asm__(
79
79
  "pushl %%ebx\n\t"
80
80
  "cpuid\n\t"
81
- "movl %%ebx, %%eax\n\r"
81
+ "movl %%ebx, %%eax\n\t"
82
82
  "popl %%ebx"
83
83
  : "=a"(f7b), "=c"(f7c)
84
84
  : "a"(7), "c"(0)
@@ -57,9 +57,9 @@ extern "C" {
57
57
  #endif
58
58
 
59
59
 
60
- /* static assert is triggered at compile time, leaving no runtime artefact,
61
- * but can only work with compile-time constants.
62
- * This variant can only be used inside a function. */
60
+ /* static assert is triggered at compile time, leaving no runtime artefact.
61
+ * static assert only works with compile-time constants.
62
+ * Also, this variant can only be used inside a function. */
63
63
  #define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
64
64
 
65
65
 
@@ -70,9 +70,19 @@ extern "C" {
70
70
  # define DEBUGLEVEL 0
71
71
  #endif
72
72
 
73
+
74
+ /* DEBUGFILE can be defined externally,
75
+ * typically through compiler command line.
76
+ * note : currently useless.
77
+ * Value must be stderr or stdout */
78
+ #ifndef DEBUGFILE
79
+ # define DEBUGFILE stderr
80
+ #endif
81
+
82
+
73
83
  /* recommended values for DEBUGLEVEL :
74
- * 0 : no debug, all run-time functions disabled
75
- * 1 : no display, enables assert() only
84
+ * 0 : release mode, no debug, all run-time checks disabled
85
+ * 1 : enables assert() only, no display
76
86
  * 2 : reserved, for currently active debug path
77
87
  * 3 : events once per object lifetime (CCtx, CDict, etc.)
78
88
  * 4 : events once per frame
@@ -81,7 +91,7 @@ extern "C" {
81
91
  * 7+: events at every position (*very* verbose)
82
92
  *
83
93
  * It's generally inconvenient to output traces > 5.
84
- * In which case, it's possible to selectively enable higher verbosity levels
94
+ * In which case, it's possible to selectively trigger high verbosity levels
85
95
  * by modifying g_debug_level.
86
96
  */
87
97
 
@@ -95,11 +105,12 @@ extern "C" {
95
105
 
96
106
  #if (DEBUGLEVEL>=2)
97
107
  # include <stdio.h>
98
- extern int g_debuglevel; /* here, this variable is only declared,
99
- it actually lives in debug.c,
100
- and is shared by the whole process.
101
- It's typically used to enable very verbose levels
102
- on selective conditions (such as position in src) */
108
+ extern int g_debuglevel; /* the variable is only declared,
109
+ it actually lives in debug.c,
110
+ and is shared by the whole process.
111
+ It's not thread-safe.
112
+ It's useful when enabling very verbose levels
113
+ on selective conditions (such as position in src) */
103
114
 
104
115
  # define RAWLOG(l, ...) { \
105
116
  if (l<=g_debuglevel) { \
@@ -14,6 +14,10 @@
14
14
 
15
15
  const char* ERR_getErrorString(ERR_enum code)
16
16
  {
17
+ #ifdef ZSTD_STRIP_ERROR_STRINGS
18
+ (void)code;
19
+ return "Error strings stripped";
20
+ #else
17
21
  static const char* const notErrorCode = "Unspecified error code";
18
22
  switch( code )
19
23
  {
@@ -39,10 +43,12 @@ const char* ERR_getErrorString(ERR_enum code)
39
43
  case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
40
44
  case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
41
45
  case PREFIX(srcSize_wrong): return "Src size is incorrect";
46
+ case PREFIX(dstBuffer_null): return "Operation on NULL destination buffer";
42
47
  /* following error codes are not stable and may be removed or changed in a future version */
43
48
  case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
44
49
  case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
45
50
  case PREFIX(maxCode):
46
51
  default: return notErrorCode;
47
52
  }
53
+ #endif
48
54
  }