zstd-ruby 1.4.5.0 → 1.4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/README.md +2 -2
- data/ext/zstdruby/libzstd/Makefile +237 -138
- data/ext/zstdruby/libzstd/README.md +28 -0
- data/ext/zstdruby/libzstd/common/bitstream.h +25 -16
- data/ext/zstdruby/libzstd/common/compiler.h +118 -4
- data/ext/zstdruby/libzstd/common/cpu.h +1 -3
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +12 -19
- data/ext/zstdruby/libzstd/common/entropy_common.c +189 -43
- data/ext/zstdruby/libzstd/common/error_private.c +2 -1
- data/ext/zstdruby/libzstd/common/error_private.h +2 -2
- data/ext/zstdruby/libzstd/common/fse.h +40 -12
- data/ext/zstdruby/libzstd/common/fse_decompress.c +124 -17
- data/ext/zstdruby/libzstd/common/huf.h +27 -6
- data/ext/zstdruby/libzstd/common/mem.h +67 -94
- data/ext/zstdruby/libzstd/common/pool.c +23 -17
- data/ext/zstdruby/libzstd/common/pool.h +2 -2
- data/ext/zstdruby/libzstd/common/threading.c +6 -5
- data/ext/zstdruby/libzstd/common/xxhash.c +19 -57
- data/ext/zstdruby/libzstd/common/xxhash.h +2 -2
- data/ext/zstdruby/libzstd/common/zstd_common.c +10 -10
- data/ext/zstdruby/libzstd/common/zstd_deps.h +111 -0
- data/ext/zstdruby/libzstd/common/zstd_errors.h +2 -1
- data/ext/zstdruby/libzstd/common/zstd_internal.h +90 -59
- data/ext/zstdruby/libzstd/common/zstd_trace.c +42 -0
- data/ext/zstdruby/libzstd/common/zstd_trace.h +152 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +31 -24
- data/ext/zstdruby/libzstd/compress/hist.c +27 -29
- data/ext/zstdruby/libzstd/compress/hist.h +2 -2
- data/ext/zstdruby/libzstd/compress/huf_compress.c +217 -101
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +1495 -478
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +143 -44
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +7 -7
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +18 -4
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -21
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +62 -26
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +23 -23
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +21 -21
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +352 -78
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +21 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +276 -209
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +8 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +103 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +191 -46
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +79 -410
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +27 -109
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +303 -201
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +9 -9
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +370 -87
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +153 -45
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +6 -3
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +28 -11
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +40 -31
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +2 -2
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +26 -25
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +22 -24
- data/ext/zstdruby/libzstd/dictBuilder/zdict.h +5 -4
- data/ext/zstdruby/libzstd/dll/example/Makefile +1 -1
- data/ext/zstdruby/libzstd/dll/example/README.md +16 -22
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +6 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +6 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +6 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +7 -3
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +10 -6
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +10 -6
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +10 -6
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +1 -1
- data/ext/zstdruby/libzstd/libzstd.pc.in +3 -3
- data/ext/zstdruby/libzstd/zstd.h +414 -54
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +7 -3
- data/.travis.yml +0 -14
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* xxHash - Extremely Fast Hash algorithm
|
3
3
|
* Header File
|
4
|
-
* Copyright (c) 2012-
|
4
|
+
* Copyright (c) 2012-2021, Yann Collet, Facebook, Inc.
|
5
5
|
*
|
6
6
|
* You can contact the author at :
|
7
7
|
* - xxHash source repository : https://github.com/Cyan4973/xxHash
|
@@ -55,7 +55,7 @@ extern "C" {
|
|
55
55
|
/* ****************************
|
56
56
|
* Definitions
|
57
57
|
******************************/
|
58
|
-
#include
|
58
|
+
#include "zstd_deps.h"
|
59
59
|
typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
|
60
60
|
|
61
61
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2021, 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
|
@@ -13,8 +13,8 @@
|
|
13
13
|
/*-*************************************
|
14
14
|
* Dependencies
|
15
15
|
***************************************/
|
16
|
-
#
|
17
|
-
#include
|
16
|
+
#define ZSTD_DEPS_NEED_MALLOC
|
17
|
+
#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
|
18
18
|
#include "error_private.h"
|
19
19
|
#include "zstd_internal.h"
|
20
20
|
|
@@ -53,31 +53,31 @@ const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString
|
|
53
53
|
/*=**************************************************************
|
54
54
|
* Custom allocator
|
55
55
|
****************************************************************/
|
56
|
-
void*
|
56
|
+
void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
|
57
57
|
{
|
58
58
|
if (customMem.customAlloc)
|
59
59
|
return customMem.customAlloc(customMem.opaque, size);
|
60
|
-
return
|
60
|
+
return ZSTD_malloc(size);
|
61
61
|
}
|
62
62
|
|
63
|
-
void*
|
63
|
+
void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
|
64
64
|
{
|
65
65
|
if (customMem.customAlloc) {
|
66
66
|
/* calloc implemented as malloc+memset;
|
67
67
|
* not as efficient as calloc, but next best guess for custom malloc */
|
68
68
|
void* const ptr = customMem.customAlloc(customMem.opaque, size);
|
69
|
-
|
69
|
+
ZSTD_memset(ptr, 0, size);
|
70
70
|
return ptr;
|
71
71
|
}
|
72
|
-
return
|
72
|
+
return ZSTD_calloc(1, size);
|
73
73
|
}
|
74
74
|
|
75
|
-
void
|
75
|
+
void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
|
76
76
|
{
|
77
77
|
if (ptr!=NULL) {
|
78
78
|
if (customMem.customFree)
|
79
79
|
customMem.customFree(customMem.opaque, ptr);
|
80
80
|
else
|
81
|
-
|
81
|
+
ZSTD_free(ptr);
|
82
82
|
}
|
83
83
|
}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-2021, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under both the BSD-style license (found in the
|
6
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
+
* in the COPYING file in the root directory of this source tree).
|
8
|
+
* You may select, at your option, one of the above-listed licenses.
|
9
|
+
*/
|
10
|
+
|
11
|
+
/* This file provides common libc dependencies that zstd requires.
|
12
|
+
* The purpose is to allow replacing this file with a custom implementation
|
13
|
+
* to compile zstd without libc support.
|
14
|
+
*/
|
15
|
+
|
16
|
+
/* Need:
|
17
|
+
* NULL
|
18
|
+
* INT_MAX
|
19
|
+
* UINT_MAX
|
20
|
+
* ZSTD_memcpy()
|
21
|
+
* ZSTD_memset()
|
22
|
+
* ZSTD_memmove()
|
23
|
+
*/
|
24
|
+
#ifndef ZSTD_DEPS_COMMON
|
25
|
+
#define ZSTD_DEPS_COMMON
|
26
|
+
|
27
|
+
#include <limits.h>
|
28
|
+
#include <stddef.h>
|
29
|
+
#include <string.h>
|
30
|
+
|
31
|
+
#if defined(__GNUC__) && __GNUC__ >= 4
|
32
|
+
# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
|
33
|
+
# define ZSTD_memmove(d,s,l) __builtin_memmove((d),(s),(l))
|
34
|
+
# define ZSTD_memset(p,v,l) __builtin_memset((p),(v),(l))
|
35
|
+
#else
|
36
|
+
# define ZSTD_memcpy(d,s,l) memcpy((d),(s),(l))
|
37
|
+
# define ZSTD_memmove(d,s,l) memmove((d),(s),(l))
|
38
|
+
# define ZSTD_memset(p,v,l) memset((p),(v),(l))
|
39
|
+
#endif
|
40
|
+
|
41
|
+
#endif /* ZSTD_DEPS_COMMON */
|
42
|
+
|
43
|
+
/* Need:
|
44
|
+
* ZSTD_malloc()
|
45
|
+
* ZSTD_free()
|
46
|
+
* ZSTD_calloc()
|
47
|
+
*/
|
48
|
+
#ifdef ZSTD_DEPS_NEED_MALLOC
|
49
|
+
#ifndef ZSTD_DEPS_MALLOC
|
50
|
+
#define ZSTD_DEPS_MALLOC
|
51
|
+
|
52
|
+
#include <stdlib.h>
|
53
|
+
|
54
|
+
#define ZSTD_malloc(s) malloc(s)
|
55
|
+
#define ZSTD_calloc(n,s) calloc((n), (s))
|
56
|
+
#define ZSTD_free(p) free((p))
|
57
|
+
|
58
|
+
#endif /* ZSTD_DEPS_MALLOC */
|
59
|
+
#endif /* ZSTD_DEPS_NEED_MALLOC */
|
60
|
+
|
61
|
+
/*
|
62
|
+
* Provides 64-bit math support.
|
63
|
+
* Need:
|
64
|
+
* U64 ZSTD_div64(U64 dividend, U32 divisor)
|
65
|
+
*/
|
66
|
+
#ifdef ZSTD_DEPS_NEED_MATH64
|
67
|
+
#ifndef ZSTD_DEPS_MATH64
|
68
|
+
#define ZSTD_DEPS_MATH64
|
69
|
+
|
70
|
+
#define ZSTD_div64(dividend, divisor) ((dividend) / (divisor))
|
71
|
+
|
72
|
+
#endif /* ZSTD_DEPS_MATH64 */
|
73
|
+
#endif /* ZSTD_DEPS_NEED_MATH64 */
|
74
|
+
|
75
|
+
/* Need:
|
76
|
+
* assert()
|
77
|
+
*/
|
78
|
+
#ifdef ZSTD_DEPS_NEED_ASSERT
|
79
|
+
#ifndef ZSTD_DEPS_ASSERT
|
80
|
+
#define ZSTD_DEPS_ASSERT
|
81
|
+
|
82
|
+
#include <assert.h>
|
83
|
+
|
84
|
+
#endif /* ZSTD_DEPS_ASSERT */
|
85
|
+
#endif /* ZSTD_DEPS_NEED_ASSERT */
|
86
|
+
|
87
|
+
/* Need:
|
88
|
+
* ZSTD_DEBUG_PRINT()
|
89
|
+
*/
|
90
|
+
#ifdef ZSTD_DEPS_NEED_IO
|
91
|
+
#ifndef ZSTD_DEPS_IO
|
92
|
+
#define ZSTD_DEPS_IO
|
93
|
+
|
94
|
+
#include <stdio.h>
|
95
|
+
#define ZSTD_DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
|
96
|
+
|
97
|
+
#endif /* ZSTD_DEPS_IO */
|
98
|
+
#endif /* ZSTD_DEPS_NEED_IO */
|
99
|
+
|
100
|
+
/* Only requested when <stdint.h> is known to be present.
|
101
|
+
* Need:
|
102
|
+
* intptr_t
|
103
|
+
*/
|
104
|
+
#ifdef ZSTD_DEPS_NEED_STDINT
|
105
|
+
#ifndef ZSTD_DEPS_STDINT
|
106
|
+
#define ZSTD_DEPS_STDINT
|
107
|
+
|
108
|
+
#include <stdint.h>
|
109
|
+
|
110
|
+
#endif /* ZSTD_DEPS_STDINT */
|
111
|
+
#endif /* ZSTD_DEPS_NEED_STDINT */
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2021, 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
|
@@ -77,6 +77,7 @@ typedef enum {
|
|
77
77
|
ZSTD_error_frameIndex_tooLarge = 100,
|
78
78
|
ZSTD_error_seekableIO = 102,
|
79
79
|
ZSTD_error_dstBuffer_wrong = 104,
|
80
|
+
ZSTD_error_srcBuffer_wrong = 105,
|
80
81
|
ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
|
81
82
|
} ZSTD_ErrorCode;
|
82
83
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c) 2016-
|
2
|
+
* Copyright (c) 2016-2021, 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
|
@@ -19,7 +19,7 @@
|
|
19
19
|
/*-*************************************
|
20
20
|
* Dependencies
|
21
21
|
***************************************/
|
22
|
-
#
|
22
|
+
#if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON)
|
23
23
|
#include <arm_neon.h>
|
24
24
|
#endif
|
25
25
|
#include "compiler.h"
|
@@ -139,7 +139,7 @@ void _force_has_format_string(const char *format, ...) {
|
|
139
139
|
|
140
140
|
#define ZSTD_REP_NUM 3 /* number of repcodes */
|
141
141
|
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
142
|
-
static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
|
142
|
+
static UNUSED_ATTR const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
|
143
143
|
|
144
144
|
#define KB *(1 <<10)
|
145
145
|
#define MB *(1 <<20)
|
@@ -153,13 +153,13 @@ static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
|
|
153
153
|
#define BIT0 1
|
154
154
|
|
155
155
|
#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
|
156
|
-
static const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
|
157
|
-
static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
|
156
|
+
static UNUSED_ATTR const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
|
157
|
+
static UNUSED_ATTR const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
|
158
158
|
|
159
159
|
#define ZSTD_FRAMEIDSIZE 4 /* magic number size */
|
160
160
|
|
161
161
|
#define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */
|
162
|
-
static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
|
162
|
+
static UNUSED_ATTR const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
|
163
163
|
typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
|
164
164
|
|
165
165
|
#define ZSTD_FRAMECHECKSUMSIZE 4
|
@@ -186,61 +186,75 @@ typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingTy
|
|
186
186
|
#define OffFSELog 8
|
187
187
|
#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
|
188
188
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
189
|
+
#define ZSTD_MAX_HUF_HEADER_SIZE 128 /* header + <= 127 byte tree description */
|
190
|
+
/* Each table cannot take more than #symbols * FSELog bits */
|
191
|
+
#define ZSTD_MAX_FSE_HEADERS_SIZE (((MaxML + 1) * MLFSELog + (MaxLL + 1) * LLFSELog + (MaxOff + 1) * OffFSELog + 7) / 8)
|
192
|
+
|
193
|
+
static UNUSED_ATTR const U32 LL_bits[MaxLL+1] = {
|
194
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
195
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
196
|
+
1, 1, 1, 1, 2, 2, 3, 3,
|
197
|
+
4, 6, 7, 8, 9,10,11,12,
|
198
|
+
13,14,15,16
|
199
|
+
};
|
200
|
+
static UNUSED_ATTR const S16 LL_defaultNorm[MaxLL+1] = {
|
201
|
+
4, 3, 2, 2, 2, 2, 2, 2,
|
202
|
+
2, 2, 2, 2, 2, 1, 1, 1,
|
203
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
204
|
+
2, 3, 2, 1, 1, 1, 1, 1,
|
205
|
+
-1,-1,-1,-1
|
206
|
+
};
|
199
207
|
#define LL_DEFAULTNORMLOG 6 /* for static allocation */
|
200
|
-
static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
|
201
|
-
|
202
|
-
static const U32 ML_bits[MaxML+1] = {
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
208
|
+
static UNUSED_ATTR const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
|
209
|
+
|
210
|
+
static UNUSED_ATTR const U32 ML_bits[MaxML+1] = {
|
211
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
212
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
213
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
214
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
215
|
+
1, 1, 1, 1, 2, 2, 3, 3,
|
216
|
+
4, 4, 5, 7, 8, 9,10,11,
|
217
|
+
12,13,14,15,16
|
218
|
+
};
|
219
|
+
static UNUSED_ATTR const S16 ML_defaultNorm[MaxML+1] = {
|
220
|
+
1, 4, 3, 2, 2, 2, 2, 2,
|
221
|
+
2, 1, 1, 1, 1, 1, 1, 1,
|
222
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
223
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
224
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
225
|
+
1, 1, 1, 1, 1, 1,-1,-1,
|
226
|
+
-1,-1,-1,-1,-1
|
227
|
+
};
|
216
228
|
#define ML_DEFAULTNORMLOG 6 /* for static allocation */
|
217
|
-
static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
|
218
|
-
|
219
|
-
static const S16 OF_defaultNorm[DefaultMaxOff+1] = {
|
220
|
-
|
221
|
-
|
222
|
-
|
229
|
+
static UNUSED_ATTR const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
|
230
|
+
|
231
|
+
static UNUSED_ATTR const S16 OF_defaultNorm[DefaultMaxOff+1] = {
|
232
|
+
1, 1, 1, 1, 1, 1, 2, 2,
|
233
|
+
2, 1, 1, 1, 1, 1, 1, 1,
|
234
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
235
|
+
-1,-1,-1,-1,-1
|
236
|
+
};
|
223
237
|
#define OF_DEFAULTNORMLOG 5 /* for static allocation */
|
224
|
-
static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
238
|
+
static UNUSED_ATTR const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
|
225
239
|
|
226
240
|
|
227
241
|
/*-*******************************************
|
228
242
|
* Shared functions to include for inlining
|
229
243
|
*********************************************/
|
230
244
|
static void ZSTD_copy8(void* dst, const void* src) {
|
231
|
-
#
|
245
|
+
#if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON)
|
232
246
|
vst1_u8((uint8_t*)dst, vld1_u8((const uint8_t*)src));
|
233
247
|
#else
|
234
|
-
|
248
|
+
ZSTD_memcpy(dst, src, 8);
|
235
249
|
#endif
|
236
250
|
}
|
237
251
|
|
238
252
|
#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
|
239
253
|
static void ZSTD_copy16(void* dst, const void* src) {
|
240
|
-
#
|
254
|
+
#if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON)
|
241
255
|
vst1q_u8((uint8_t*)dst, vld1q_u8((const uint8_t*)src));
|
242
256
|
#else
|
243
|
-
|
257
|
+
ZSTD_memcpy(dst, src, 16);
|
244
258
|
#endif
|
245
259
|
}
|
246
260
|
#define COPY16(d,s) { ZSTD_copy16(d,s); d+=16; s+=16; }
|
@@ -255,13 +269,13 @@ typedef enum {
|
|
255
269
|
} ZSTD_overlap_e;
|
256
270
|
|
257
271
|
/*! ZSTD_wildcopy() :
|
258
|
-
* Custom version of
|
272
|
+
* Custom version of ZSTD_memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)
|
259
273
|
* @param ovtype controls the overlap detection
|
260
274
|
* - ZSTD_no_overlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
|
261
275
|
* - ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart.
|
262
276
|
* The src buffer must be before the dst buffer.
|
263
277
|
*/
|
264
|
-
MEM_STATIC FORCE_INLINE_ATTR
|
278
|
+
MEM_STATIC FORCE_INLINE_ATTR
|
265
279
|
void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
|
266
280
|
{
|
267
281
|
ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
|
@@ -284,14 +298,16 @@ void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e
|
|
284
298
|
* one COPY16() in the first call. Then, do two calls per loop since
|
285
299
|
* at that point it is more likely to have a high trip count.
|
286
300
|
*/
|
287
|
-
#
|
301
|
+
#ifdef __aarch64__
|
288
302
|
do {
|
289
303
|
COPY16(op, ip);
|
290
304
|
}
|
291
305
|
while (op < oend);
|
292
306
|
#else
|
293
|
-
|
294
|
-
if (
|
307
|
+
ZSTD_copy16(op, ip);
|
308
|
+
if (16 >= length) return;
|
309
|
+
op += 16;
|
310
|
+
ip += 16;
|
295
311
|
do {
|
296
312
|
COPY16(op, ip);
|
297
313
|
COPY16(op, ip);
|
@@ -305,7 +321,7 @@ MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src,
|
|
305
321
|
{
|
306
322
|
size_t const length = MIN(dstCapacity, srcSize);
|
307
323
|
if (length > 0) {
|
308
|
-
|
324
|
+
ZSTD_memcpy(dst, src, length);
|
309
325
|
}
|
310
326
|
return length;
|
311
327
|
}
|
@@ -320,28 +336,39 @@ MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src,
|
|
320
336
|
* In which case, resize it down to free some memory */
|
321
337
|
#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128
|
322
338
|
|
339
|
+
/* Controls whether the input/output buffer is buffered or stable. */
|
340
|
+
typedef enum {
|
341
|
+
ZSTD_bm_buffered = 0, /* Buffer the input/output */
|
342
|
+
ZSTD_bm_stable = 1 /* ZSTD_inBuffer/ZSTD_outBuffer is stable */
|
343
|
+
} ZSTD_bufferMode_e;
|
344
|
+
|
323
345
|
|
324
346
|
/*-*******************************************
|
325
347
|
* Private declarations
|
326
348
|
*********************************************/
|
327
349
|
typedef struct seqDef_s {
|
328
|
-
U32 offset;
|
350
|
+
U32 offset; /* Offset code of the sequence */
|
329
351
|
U16 litLength;
|
330
352
|
U16 matchLength;
|
331
353
|
} seqDef;
|
332
354
|
|
333
355
|
typedef struct {
|
334
356
|
seqDef* sequencesStart;
|
335
|
-
seqDef* sequences;
|
357
|
+
seqDef* sequences; /* ptr to end of sequences */
|
336
358
|
BYTE* litStart;
|
337
|
-
BYTE* lit;
|
359
|
+
BYTE* lit; /* ptr to end of literals */
|
338
360
|
BYTE* llCode;
|
339
361
|
BYTE* mlCode;
|
340
362
|
BYTE* ofCode;
|
341
363
|
size_t maxNbSeq;
|
342
364
|
size_t maxNbLit;
|
343
|
-
|
344
|
-
|
365
|
+
|
366
|
+
/* longLengthPos and longLengthID to allow us to represent either a single litLength or matchLength
|
367
|
+
* in the seqStore that has a value larger than U16 (if it exists). To do so, we increment
|
368
|
+
* the existing value of the litLength or matchLength by 0x10000.
|
369
|
+
*/
|
370
|
+
U32 longLengthID; /* 0 == no longLength; 1 == Represent the long literal; 2 == Represent the long match; */
|
371
|
+
U32 longLengthPos; /* Index of the sequence to apply long length modification to */
|
345
372
|
} seqStore_t;
|
346
373
|
|
347
374
|
typedef struct {
|
@@ -384,9 +411,9 @@ const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBu
|
|
384
411
|
void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
385
412
|
|
386
413
|
/* custom memory allocation functions */
|
387
|
-
void*
|
388
|
-
void*
|
389
|
-
void
|
414
|
+
void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem);
|
415
|
+
void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem);
|
416
|
+
void ZSTD_customFree(void* ptr, ZSTD_customMem customMem);
|
390
417
|
|
391
418
|
|
392
419
|
MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
|
@@ -394,8 +421,12 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus
|
|
394
421
|
assert(val != 0);
|
395
422
|
{
|
396
423
|
# if defined(_MSC_VER) /* Visual */
|
397
|
-
|
398
|
-
|
424
|
+
# if STATIC_BMI2 == 1
|
425
|
+
return _lzcnt_u32(val)^31;
|
426
|
+
# else
|
427
|
+
unsigned long r=0;
|
428
|
+
return _BitScanReverse(&r, val) ? (unsigned)r : 0;
|
429
|
+
# endif
|
399
430
|
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
|
400
431
|
return __builtin_clz (val) ^ 31;
|
401
432
|
# elif defined(__ICCARM__) /* IAR Intrinsic */
|