extzstd 0.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY.ja.md +8 -0
- data/README.md +1 -1
- data/contrib/zstd/CHANGELOG +94 -0
- data/contrib/zstd/CONTRIBUTING.md +351 -1
- data/contrib/zstd/Makefile +32 -10
- data/contrib/zstd/README.md +33 -10
- data/contrib/zstd/TESTING.md +2 -2
- data/contrib/zstd/appveyor.yml +42 -4
- data/contrib/zstd/lib/Makefile +128 -60
- data/contrib/zstd/lib/README.md +47 -16
- data/contrib/zstd/lib/common/bitstream.h +38 -39
- data/contrib/zstd/lib/common/compiler.h +40 -5
- data/contrib/zstd/lib/common/cpu.h +1 -1
- data/contrib/zstd/lib/common/debug.c +11 -31
- data/contrib/zstd/lib/common/debug.h +11 -31
- data/contrib/zstd/lib/common/entropy_common.c +13 -33
- data/contrib/zstd/lib/common/error_private.c +2 -1
- data/contrib/zstd/lib/common/error_private.h +6 -2
- data/contrib/zstd/lib/common/fse.h +12 -32
- data/contrib/zstd/lib/common/fse_decompress.c +12 -35
- data/contrib/zstd/lib/common/huf.h +15 -33
- data/contrib/zstd/lib/common/mem.h +75 -2
- data/contrib/zstd/lib/common/pool.c +8 -4
- data/contrib/zstd/lib/common/pool.h +2 -2
- data/contrib/zstd/lib/common/threading.c +50 -4
- data/contrib/zstd/lib/common/threading.h +36 -4
- data/contrib/zstd/lib/common/xxhash.c +23 -35
- data/contrib/zstd/lib/common/xxhash.h +11 -31
- data/contrib/zstd/lib/common/zstd_common.c +1 -1
- data/contrib/zstd/lib/common/zstd_errors.h +2 -1
- data/contrib/zstd/lib/common/zstd_internal.h +154 -26
- data/contrib/zstd/lib/compress/fse_compress.c +17 -40
- data/contrib/zstd/lib/compress/hist.c +15 -35
- data/contrib/zstd/lib/compress/hist.h +12 -32
- data/contrib/zstd/lib/compress/huf_compress.c +92 -92
- data/contrib/zstd/lib/compress/zstd_compress.c +1191 -1330
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +317 -55
- data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
- data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.c +419 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +845 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
- data/contrib/zstd/lib/compress/zstd_cwksp.h +525 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.c +65 -43
- data/contrib/zstd/lib/compress/zstd_double_fast.h +2 -2
- data/contrib/zstd/lib/compress/zstd_fast.c +92 -66
- data/contrib/zstd/lib/compress/zstd_fast.h +2 -2
- data/contrib/zstd/lib/compress/zstd_lazy.c +74 -42
- data/contrib/zstd/lib/compress/zstd_lazy.h +1 -1
- data/contrib/zstd/lib/compress/zstd_ldm.c +32 -10
- data/contrib/zstd/lib/compress/zstd_ldm.h +7 -2
- data/contrib/zstd/lib/compress/zstd_opt.c +81 -114
- data/contrib/zstd/lib/compress/zstd_opt.h +1 -1
- data/contrib/zstd/lib/compress/zstdmt_compress.c +95 -51
- data/contrib/zstd/lib/compress/zstdmt_compress.h +3 -2
- data/contrib/zstd/lib/decompress/huf_decompress.c +76 -60
- data/contrib/zstd/lib/decompress/zstd_ddict.c +12 -8
- data/contrib/zstd/lib/decompress/zstd_ddict.h +2 -2
- data/contrib/zstd/lib/decompress/zstd_decompress.c +292 -172
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +459 -338
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +3 -3
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +18 -4
- data/contrib/zstd/lib/deprecated/zbuff.h +9 -8
- data/contrib/zstd/lib/deprecated/zbuff_common.c +2 -2
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +1 -1
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +1 -1
- data/contrib/zstd/lib/dictBuilder/cover.c +164 -54
- data/contrib/zstd/lib/dictBuilder/cover.h +52 -7
- data/contrib/zstd/lib/dictBuilder/fastcover.c +60 -43
- data/contrib/zstd/lib/dictBuilder/zdict.c +43 -19
- data/contrib/zstd/lib/dictBuilder/zdict.h +56 -28
- data/contrib/zstd/lib/legacy/zstd_legacy.h +8 -4
- data/contrib/zstd/lib/legacy/zstd_v01.c +110 -110
- data/contrib/zstd/lib/legacy/zstd_v01.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v02.c +23 -13
- data/contrib/zstd/lib/legacy/zstd_v02.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v03.c +23 -13
- data/contrib/zstd/lib/legacy/zstd_v03.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v04.c +30 -17
- data/contrib/zstd/lib/legacy/zstd_v04.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v05.c +113 -102
- data/contrib/zstd/lib/legacy/zstd_v05.h +2 -2
- data/contrib/zstd/lib/legacy/zstd_v06.c +20 -18
- data/contrib/zstd/lib/legacy/zstd_v06.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v07.c +25 -19
- data/contrib/zstd/lib/legacy/zstd_v07.h +1 -1
- data/contrib/zstd/lib/libzstd.pc.in +3 -2
- data/contrib/zstd/lib/zstd.h +265 -88
- data/ext/extzstd.h +1 -1
- data/ext/libzstd_conf.h +8 -0
- data/ext/zstd_common.c +1 -3
- data/ext/zstd_compress.c +3 -3
- data/ext/zstd_decompress.c +1 -5
- data/ext/zstd_dictbuilder.c +2 -3
- data/ext/zstd_dictbuilder_fastcover.c +1 -3
- data/ext/zstd_legacy_v01.c +2 -0
- data/ext/zstd_legacy_v02.c +2 -0
- data/ext/zstd_legacy_v03.c +2 -0
- data/ext/zstd_legacy_v04.c +2 -0
- data/ext/zstd_legacy_v05.c +2 -0
- data/ext/zstd_legacy_v06.c +2 -0
- data/ext/zstd_legacy_v07.c +2 -0
- data/lib/extzstd.rb +18 -10
- data/lib/extzstd/version.rb +1 -1
- metadata +15 -6
data/contrib/zstd/lib/README.md
CHANGED
|
@@ -27,10 +27,10 @@ Enabling multithreading requires 2 conditions :
|
|
|
27
27
|
Both conditions are automatically applied when invoking `make lib-mt` target.
|
|
28
28
|
|
|
29
29
|
When linking a POSIX program with a multithreaded version of `libzstd`,
|
|
30
|
-
note that it's necessary to
|
|
30
|
+
note that it's necessary to invoke the `-pthread` flag during link stage.
|
|
31
31
|
|
|
32
32
|
Multithreading capabilities are exposed
|
|
33
|
-
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.3
|
|
33
|
+
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
#### API
|
|
@@ -85,33 +85,64 @@ The file structure is designed to make this selection manually achievable for an
|
|
|
85
85
|
|
|
86
86
|
- While invoking `make libzstd`, it's possible to define build macros
|
|
87
87
|
`ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
|
|
88
|
-
and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
|
|
89
|
-
This will also disable compilation of all
|
|
90
|
-
(eg. `ZSTD_LIB_COMPRESSION=0` will also disable
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
|
|
89
|
+
corresponding features. This will also disable compilation of all
|
|
90
|
+
dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
|
|
91
|
+
dictBuilder).
|
|
92
|
+
|
|
93
|
+
- There are a number of options that can help minimize the binary size of
|
|
94
|
+
`libzstd`.
|
|
95
|
+
|
|
96
|
+
The first step is to select the components needed (using the above-described
|
|
97
|
+
`ZSTD_LIB_COMPRESSION` etc.).
|
|
98
|
+
|
|
99
|
+
The next step is to set `ZSTD_LIB_MINIFY` to `1` when invoking `make`. This
|
|
100
|
+
disables various optional components and changes the compilation flags to
|
|
101
|
+
prioritize space-saving.
|
|
102
|
+
|
|
103
|
+
Detailed options: Zstandard's code and build environment is set up by default
|
|
104
|
+
to optimize above all else for performance. In pursuit of this goal, Zstandard
|
|
105
|
+
makes significant trade-offs in code size. For example, Zstandard often has
|
|
106
|
+
more than one implementation of a particular component, with each
|
|
107
|
+
implementation optimized for different scenarios. For example, the Huffman
|
|
108
|
+
decoder has complementary implementations that decode the stream one symbol at
|
|
109
|
+
a time or two symbols at a time. Zstd normally includes both (and dispatches
|
|
110
|
+
between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1` or
|
|
111
|
+
`HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
|
|
100
112
|
compilation of the other. Similarly, `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`
|
|
101
113
|
and `ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG` force the compilation and use of
|
|
102
114
|
only one or the other of two decompression implementations. The smallest
|
|
103
115
|
binary is achieved by using `HUF_FORCE_DECOMPRESS_X1` and
|
|
104
|
-
`ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT
|
|
116
|
+
`ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT` (implied by `ZSTD_LIB_MINIFY`).
|
|
105
117
|
|
|
106
118
|
For squeezing the last ounce of size out, you can also define
|
|
107
119
|
`ZSTD_NO_INLINE`, which disables inlining, and `ZSTD_STRIP_ERROR_STRINGS`,
|
|
108
120
|
which removes the error messages that are otherwise returned by
|
|
109
|
-
`ZSTD_getErrorName
|
|
121
|
+
`ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
|
|
122
|
+
|
|
123
|
+
Finally, when integrating into your application, make sure you're doing link-
|
|
124
|
+
time optimation and unused symbol garbage collection (via some combination of,
|
|
125
|
+
e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
|
|
126
|
+
`-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
|
|
127
|
+
`-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
|
|
128
|
+
the compiler's intermediate representation, e.g., `AR=gcc-ar`). Consult your
|
|
129
|
+
compiler's documentation.
|
|
110
130
|
|
|
111
131
|
- While invoking `make libzstd`, the build macro `ZSTD_LEGACY_MULTITHREADED_API=1`
|
|
112
132
|
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
|
|
113
133
|
the shared library, which is now hidden by default.
|
|
114
134
|
|
|
135
|
+
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
|
|
136
|
+
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
|
|
137
|
+
These instructions contribute to better performance, notably on the decoder side.
|
|
138
|
+
By default, this feature is automatically enabled on detecting
|
|
139
|
+
the right instruction set (x64) and compiler (clang or gcc >= 5).
|
|
140
|
+
It's obviously disabled for different cpus,
|
|
141
|
+
or when BMI2 instruction set is _required_ by the compiler command line
|
|
142
|
+
(in this case, only the BMI2 code path is generated).
|
|
143
|
+
Setting this macro will either force to generate the BMI2 dispatcher (1)
|
|
144
|
+
or prevent it (0). It overrides automatic detection.
|
|
145
|
+
|
|
115
146
|
|
|
116
147
|
#### Windows : using MinGW+MSYS to create DLL
|
|
117
148
|
|
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
/* ******************************************************************
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
|
14
|
-
* Redistributions in binary form must reproduce the above
|
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
16
|
-
in the documentation and/or other materials provided with the
|
|
17
|
-
distribution.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
-
|
|
31
|
-
You can contact the author at :
|
|
32
|
-
- Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
2
|
+
* bitstream
|
|
3
|
+
* Part of FSE library
|
|
4
|
+
* Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
|
|
5
|
+
*
|
|
6
|
+
* You can contact the author at :
|
|
7
|
+
* - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
|
33
13
|
****************************************************************** */
|
|
34
14
|
#ifndef BITSTREAM_H_MODULE
|
|
35
15
|
#define BITSTREAM_H_MODULE
|
|
@@ -48,6 +28,7 @@ extern "C" {
|
|
|
48
28
|
* Dependencies
|
|
49
29
|
******************************************/
|
|
50
30
|
#include "mem.h" /* unaligned access routines */
|
|
31
|
+
#include "compiler.h" /* UNLIKELY() */
|
|
51
32
|
#include "debug.h" /* assert(), DEBUGLOG(), RAWLOG() */
|
|
52
33
|
#include "error_private.h" /* error codes and messages */
|
|
53
34
|
|
|
@@ -57,6 +38,8 @@ extern "C" {
|
|
|
57
38
|
=========================================*/
|
|
58
39
|
#if defined(__BMI__) && defined(__GNUC__)
|
|
59
40
|
# include <immintrin.h> /* support for bextr (experimental) */
|
|
41
|
+
#elif defined(__ICCARM__)
|
|
42
|
+
# include <intrinsics.h>
|
|
60
43
|
#endif
|
|
61
44
|
|
|
62
45
|
#define STREAM_ACCUMULATOR_MIN_32 25
|
|
@@ -159,10 +142,11 @@ MEM_STATIC unsigned BIT_highbit32 (U32 val)
|
|
|
159
142
|
{
|
|
160
143
|
# if defined(_MSC_VER) /* Visual */
|
|
161
144
|
unsigned long r=0;
|
|
162
|
-
_BitScanReverse ( &r, val );
|
|
163
|
-
return (unsigned) r;
|
|
145
|
+
return _BitScanReverse ( &r, val ) ? (unsigned)r : 0;
|
|
164
146
|
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
|
|
165
|
-
return
|
|
147
|
+
return __builtin_clz (val) ^ 31;
|
|
148
|
+
# elif defined(__ICCARM__) /* IAR Intrinsic */
|
|
149
|
+
return 31 - __CLZ(val);
|
|
166
150
|
# else /* Software version */
|
|
167
151
|
static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29,
|
|
168
152
|
11, 14, 16, 18, 22, 25, 3, 30,
|
|
@@ -240,9 +224,9 @@ MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC)
|
|
|
240
224
|
{
|
|
241
225
|
size_t const nbBytes = bitC->bitPos >> 3;
|
|
242
226
|
assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
|
227
|
+
assert(bitC->ptr <= bitC->endPtr);
|
|
243
228
|
MEM_writeLEST(bitC->ptr, bitC->bitContainer);
|
|
244
229
|
bitC->ptr += nbBytes;
|
|
245
|
-
assert(bitC->ptr <= bitC->endPtr);
|
|
246
230
|
bitC->bitPos &= 7;
|
|
247
231
|
bitC->bitContainer >>= nbBytes*8;
|
|
248
232
|
}
|
|
@@ -256,6 +240,7 @@ MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC)
|
|
|
256
240
|
{
|
|
257
241
|
size_t const nbBytes = bitC->bitPos >> 3;
|
|
258
242
|
assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
|
|
243
|
+
assert(bitC->ptr <= bitC->endPtr);
|
|
259
244
|
MEM_writeLEST(bitC->ptr, bitC->bitContainer);
|
|
260
245
|
bitC->ptr += nbBytes;
|
|
261
246
|
if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr;
|
|
@@ -406,6 +391,23 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
|
|
|
406
391
|
return value;
|
|
407
392
|
}
|
|
408
393
|
|
|
394
|
+
/*! BIT_reloadDStreamFast() :
|
|
395
|
+
* Similar to BIT_reloadDStream(), but with two differences:
|
|
396
|
+
* 1. bitsConsumed <= sizeof(bitD->bitContainer)*8 must hold!
|
|
397
|
+
* 2. Returns BIT_DStream_overflow when bitD->ptr < bitD->limitPtr, at this
|
|
398
|
+
* point you must use BIT_reloadDStream() to reload.
|
|
399
|
+
*/
|
|
400
|
+
MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD)
|
|
401
|
+
{
|
|
402
|
+
if (UNLIKELY(bitD->ptr < bitD->limitPtr))
|
|
403
|
+
return BIT_DStream_overflow;
|
|
404
|
+
assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8);
|
|
405
|
+
bitD->ptr -= bitD->bitsConsumed >> 3;
|
|
406
|
+
bitD->bitsConsumed &= 7;
|
|
407
|
+
bitD->bitContainer = MEM_readLEST(bitD->ptr);
|
|
408
|
+
return BIT_DStream_unfinished;
|
|
409
|
+
}
|
|
410
|
+
|
|
409
411
|
/*! BIT_reloadDStream() :
|
|
410
412
|
* Refill `bitD` from buffer previously set in BIT_initDStream() .
|
|
411
413
|
* This function is safe, it guarantees it will not read beyond src buffer.
|
|
@@ -417,10 +419,7 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
|
|
|
417
419
|
return BIT_DStream_overflow;
|
|
418
420
|
|
|
419
421
|
if (bitD->ptr >= bitD->limitPtr) {
|
|
420
|
-
|
|
421
|
-
bitD->bitsConsumed &= 7;
|
|
422
|
-
bitD->bitContainer = MEM_readLEST(bitD->ptr);
|
|
423
|
-
return BIT_DStream_unfinished;
|
|
422
|
+
return BIT_reloadDStreamFast(bitD);
|
|
424
423
|
}
|
|
425
424
|
if (bitD->ptr == bitD->start) {
|
|
426
425
|
if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2016-
|
|
2
|
+
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
/* force inlining */
|
|
18
18
|
|
|
19
19
|
#if !defined(ZSTD_NO_INLINE)
|
|
20
|
-
#if defined
|
|
20
|
+
#if (defined(__GNUC__) && !defined(__STRICT_ANSI__)) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
|
21
21
|
# define INLINE_KEYWORD inline
|
|
22
22
|
#else
|
|
23
23
|
# define INLINE_KEYWORD
|
|
24
24
|
#endif
|
|
25
25
|
|
|
26
|
-
#if defined(__GNUC__)
|
|
26
|
+
#if defined(__GNUC__) || defined(__ICCARM__)
|
|
27
27
|
# define FORCE_INLINE_ATTR __attribute__((always_inline))
|
|
28
28
|
#elif defined(_MSC_VER)
|
|
29
29
|
# define FORCE_INLINE_ATTR __forceinline
|
|
@@ -61,11 +61,18 @@
|
|
|
61
61
|
# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
|
|
62
62
|
#endif
|
|
63
63
|
|
|
64
|
+
/* UNUSED_ATTR tells the compiler it is okay if the function is unused. */
|
|
65
|
+
#if defined(__GNUC__)
|
|
66
|
+
# define UNUSED_ATTR __attribute__((unused))
|
|
67
|
+
#else
|
|
68
|
+
# define UNUSED_ATTR
|
|
69
|
+
#endif
|
|
70
|
+
|
|
64
71
|
/* force no inlining */
|
|
65
72
|
#ifdef _MSC_VER
|
|
66
73
|
# define FORCE_NOINLINE static __declspec(noinline)
|
|
67
74
|
#else
|
|
68
|
-
#
|
|
75
|
+
# if defined(__GNUC__) || defined(__ICCARM__)
|
|
69
76
|
# define FORCE_NOINLINE static __attribute__((__noinline__))
|
|
70
77
|
# else
|
|
71
78
|
# define FORCE_NOINLINE static
|
|
@@ -76,7 +83,7 @@
|
|
|
76
83
|
#ifndef __has_attribute
|
|
77
84
|
#define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
|
78
85
|
#endif
|
|
79
|
-
#if defined(__GNUC__)
|
|
86
|
+
#if defined(__GNUC__) || defined(__ICCARM__)
|
|
80
87
|
# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
|
|
81
88
|
#else
|
|
82
89
|
# define TARGET_ATTRIBUTE(target)
|
|
@@ -107,6 +114,9 @@
|
|
|
107
114
|
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
|
|
108
115
|
# define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
|
|
109
116
|
# define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
|
|
117
|
+
# elif defined(__aarch64__)
|
|
118
|
+
# define PREFETCH_L1(ptr) __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr)))
|
|
119
|
+
# define PREFETCH_L2(ptr) __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr)))
|
|
110
120
|
# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
|
|
111
121
|
# define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
|
|
112
122
|
# define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
|
|
@@ -127,6 +137,31 @@
|
|
|
127
137
|
} \
|
|
128
138
|
}
|
|
129
139
|
|
|
140
|
+
/* vectorization
|
|
141
|
+
* older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */
|
|
142
|
+
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__)
|
|
143
|
+
# if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5)
|
|
144
|
+
# define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
|
|
145
|
+
# else
|
|
146
|
+
# define DONT_VECTORIZE _Pragma("GCC optimize(\"no-tree-vectorize\")")
|
|
147
|
+
# endif
|
|
148
|
+
#else
|
|
149
|
+
# define DONT_VECTORIZE
|
|
150
|
+
#endif
|
|
151
|
+
|
|
152
|
+
/* Tell the compiler that a branch is likely or unlikely.
|
|
153
|
+
* Only use these macros if it causes the compiler to generate better code.
|
|
154
|
+
* If you can remove a LIKELY/UNLIKELY annotation without speed changes in gcc
|
|
155
|
+
* and clang, please do.
|
|
156
|
+
*/
|
|
157
|
+
#if defined(__GNUC__)
|
|
158
|
+
#define LIKELY(x) (__builtin_expect((x), 1))
|
|
159
|
+
#define UNLIKELY(x) (__builtin_expect((x), 0))
|
|
160
|
+
#else
|
|
161
|
+
#define LIKELY(x) (x)
|
|
162
|
+
#define UNLIKELY(x) (x)
|
|
163
|
+
#endif
|
|
164
|
+
|
|
130
165
|
/* disable warnings */
|
|
131
166
|
#ifdef _MSC_VER /* Visual Studio */
|
|
132
167
|
# include <intrin.h> /* For Visual 2005 */
|
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
/* ******************************************************************
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
|
14
|
-
* Redistributions in binary form must reproduce the above
|
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
16
|
-
in the documentation and/or other materials provided with the
|
|
17
|
-
distribution.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
-
|
|
31
|
-
You can contact the author at :
|
|
32
|
-
- Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
2
|
+
* debug
|
|
3
|
+
* Part of FSE library
|
|
4
|
+
* Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
|
|
5
|
+
*
|
|
6
|
+
* You can contact the author at :
|
|
7
|
+
* - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
|
33
13
|
****************************************************************** */
|
|
34
14
|
|
|
35
15
|
|
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
/* ******************************************************************
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
notice, this list of conditions and the following disclaimer.
|
|
14
|
-
* Redistributions in binary form must reproduce the above
|
|
15
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
16
|
-
in the documentation and/or other materials provided with the
|
|
17
|
-
distribution.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
-
|
|
31
|
-
You can contact the author at :
|
|
32
|
-
- Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
2
|
+
* debug
|
|
3
|
+
* Part of FSE library
|
|
4
|
+
* Copyright (c) 2013-2020, Yann Collet, Facebook, Inc.
|
|
5
|
+
*
|
|
6
|
+
* You can contact the author at :
|
|
7
|
+
* - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
|
33
13
|
****************************************************************** */
|
|
34
14
|
|
|
35
15
|
|
|
@@ -1,36 +1,16 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
15
|
-
in the documentation and/or other materials provided with the
|
|
16
|
-
distribution.
|
|
17
|
-
|
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
19
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
20
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
21
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
22
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
23
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
24
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
25
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
26
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
-
|
|
30
|
-
You can contact the author at :
|
|
31
|
-
- FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
32
|
-
- Public forum : https://groups.google.com/forum/#!forum/lz4c
|
|
33
|
-
*************************************************************************** */
|
|
1
|
+
/* ******************************************************************
|
|
2
|
+
* Common functions of New Generation Entropy library
|
|
3
|
+
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
|
|
4
|
+
*
|
|
5
|
+
* You can contact the author at :
|
|
6
|
+
* - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
|
7
|
+
* - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under both the BSD-style license (found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
11
|
+
* in the COPYING file in the root directory of this source tree).
|
|
12
|
+
* You may select, at your option, one of the above-listed licenses.
|
|
13
|
+
****************************************************************** */
|
|
34
14
|
|
|
35
15
|
/* *************************************
|
|
36
16
|
* Dependencies
|