zstdlib 0.7.0-x86-mingw32 → 0.8.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/ext/zstdlib/extconf.rb +1 -1
  4. data/ext/zstdlib/ruby/zlib-3.0/zstdlib.c +4994 -0
  5. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/bitstream.h +25 -16
  6. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/compiler.h +118 -4
  7. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/cpu.h +1 -3
  8. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/debug.c +1 -1
  9. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/debug.h +12 -19
  10. data/ext/zstdlib/zstd-1.5.0/lib/common/entropy_common.c +362 -0
  11. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/error_private.c +2 -1
  12. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/error_private.h +3 -3
  13. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/fse.h +40 -12
  14. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/fse_decompress.c +139 -22
  15. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/huf.h +29 -7
  16. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/mem.h +69 -98
  17. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/pool.c +23 -17
  18. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/pool.h +2 -2
  19. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/threading.c +6 -5
  20. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/threading.h +0 -0
  21. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/xxhash.c +20 -60
  22. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/xxhash.h +2 -2
  23. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/zstd_common.c +10 -10
  24. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_deps.h +111 -0
  25. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/common/zstd_internal.h +105 -62
  26. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_trace.h +154 -0
  27. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/fse_compress.c +31 -24
  28. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/hist.c +27 -29
  29. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/hist.h +2 -2
  30. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/huf_compress.c +265 -126
  31. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress.c +2843 -728
  32. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_internal.h +305 -63
  33. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_literals.c +8 -8
  34. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_literals.h +1 -1
  35. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.c +29 -7
  36. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.h +1 -1
  37. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_superblock.c +22 -295
  38. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_compress_superblock.h +1 -1
  39. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_cwksp.h +204 -67
  40. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_double_fast.c +25 -25
  41. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_double_fast.h +1 -1
  42. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_fast.c +23 -23
  43. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_fast.h +1 -1
  44. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.c +2184 -0
  45. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.h +125 -0
  46. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_ldm.c +314 -211
  47. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_ldm.h +9 -2
  48. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm_geartab.h +103 -0
  49. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_opt.c +191 -46
  50. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstd_opt.h +1 -1
  51. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/compress/zstdmt_compress.c +93 -415
  52. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstdmt_compress.h +110 -0
  53. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/huf_decompress.c +342 -239
  54. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_ddict.c +9 -9
  55. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_ddict.h +2 -2
  56. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress.c +369 -87
  57. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.c +191 -75
  58. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.h +6 -3
  59. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/decompress/zstd_decompress_internal.h +27 -11
  60. data/ext/zstdlib/zstd-1.5.0/lib/zdict.h +452 -0
  61. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/lib/zstd.h +568 -126
  62. data/ext/zstdlib/{zstd-1.4.5/lib/common → zstd-1.5.0/lib}/zstd_errors.h +2 -1
  63. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzclose.c +0 -0
  64. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzcompatibility.h +1 -1
  65. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzguts.h +0 -0
  66. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzlib.c +0 -0
  67. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzread.c +0 -0
  68. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/gzwrite.c +0 -0
  69. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.c +126 -44
  70. data/ext/zstdlib/{zstd-1.4.5 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.h +1 -1
  71. data/lib/2.2/zstdlib.so +0 -0
  72. data/lib/2.3/zstdlib.so +0 -0
  73. data/lib/2.4/zstdlib.so +0 -0
  74. data/lib/2.5/zstdlib.so +0 -0
  75. data/lib/2.6/zstdlib.so +0 -0
  76. data/lib/2.7/zstdlib.so +0 -0
  77. metadata +69 -64
  78. data/ext/zstdlib/zstd-1.4.5/lib/common/entropy_common.c +0 -216
  79. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.c +0 -1138
  80. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstd_lazy.h +0 -67
  81. data/ext/zstdlib/zstd-1.4.5/lib/compress/zstdmt_compress.h +0 -192
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * xxHash - Extremely Fast Hash algorithm
3
3
  * Header File
4
- * Copyright (c) 2012-2020, Yann Collet, Facebook, Inc.
4
+ * Copyright (c) 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 <stddef.h> /* size_t */
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-2020, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 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
- #include <stdlib.h> /* malloc, calloc, free */
17
- #include <string.h> /* memset */
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* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
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 malloc(size);
60
+ return ZSTD_malloc(size);
61
61
  }
62
62
 
63
- void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
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
- memset(ptr, 0, size);
69
+ ZSTD_memset(ptr, 0, size);
70
70
  return ptr;
71
71
  }
72
- return calloc(1, size);
72
+ return ZSTD_calloc(1, size);
73
73
  }
74
74
 
75
- void ZSTD_free(void* ptr, ZSTD_customMem customMem)
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
- free(ptr);
81
+ ZSTD_free(ptr);
82
82
  }
83
83
  }
@@ -0,0 +1,111 @@
1
+ /*
2
+ * Copyright (c) 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-2020, Yann Collet, Facebook, Inc.
2
+ * Copyright (c) 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
- #ifdef __aarch64__
22
+ #if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON)
23
23
  #include <arm_neon.h>
24
24
  #endif
25
25
  #include "compiler.h"
@@ -36,6 +36,11 @@
36
36
  # define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
37
37
  #endif
38
38
  #include "xxhash.h" /* XXH_reset, update, digest */
39
+ #ifndef ZSTD_NO_TRACE
40
+ # include "zstd_trace.h"
41
+ #else
42
+ # define ZSTD_TRACE 0
43
+ #endif
39
44
 
40
45
  #if defined (__cplusplus)
41
46
  extern "C" {
@@ -139,7 +144,7 @@ void _force_has_format_string(const char *format, ...) {
139
144
 
140
145
  #define ZSTD_REP_NUM 3 /* number of repcodes */
141
146
  #define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
142
- static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
147
+ static UNUSED_ATTR const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
143
148
 
144
149
  #define KB *(1 <<10)
145
150
  #define MB *(1 <<20)
@@ -153,13 +158,13 @@ static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
153
158
  #define BIT0 1
154
159
 
155
160
  #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 };
161
+ static UNUSED_ATTR const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
162
+ static UNUSED_ATTR const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
158
163
 
159
164
  #define ZSTD_FRAMEIDSIZE 4 /* magic number size */
160
165
 
161
166
  #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;
167
+ static UNUSED_ATTR const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
163
168
  typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
164
169
 
165
170
  #define ZSTD_FRAMECHECKSUMSIZE 4
@@ -186,61 +191,75 @@ typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingTy
186
191
  #define OffFSELog 8
187
192
  #define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
188
193
 
189
- static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
190
- 0, 0, 0, 0, 0, 0, 0, 0,
191
- 1, 1, 1, 1, 2, 2, 3, 3,
192
- 4, 6, 7, 8, 9,10,11,12,
193
- 13,14,15,16 };
194
- static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2,
195
- 2, 2, 2, 2, 2, 1, 1, 1,
196
- 2, 2, 2, 2, 2, 2, 2, 2,
197
- 2, 3, 2, 1, 1, 1, 1, 1,
198
- -1,-1,-1,-1 };
194
+ #define ZSTD_MAX_HUF_HEADER_SIZE 128 /* header + <= 127 byte tree description */
195
+ /* Each table cannot take more than #symbols * FSELog bits */
196
+ #define ZSTD_MAX_FSE_HEADERS_SIZE (((MaxML + 1) * MLFSELog + (MaxLL + 1) * LLFSELog + (MaxOff + 1) * OffFSELog + 7) / 8)
197
+
198
+ static UNUSED_ATTR const U32 LL_bits[MaxLL+1] = {
199
+ 0, 0, 0, 0, 0, 0, 0, 0,
200
+ 0, 0, 0, 0, 0, 0, 0, 0,
201
+ 1, 1, 1, 1, 2, 2, 3, 3,
202
+ 4, 6, 7, 8, 9,10,11,12,
203
+ 13,14,15,16
204
+ };
205
+ static UNUSED_ATTR const S16 LL_defaultNorm[MaxLL+1] = {
206
+ 4, 3, 2, 2, 2, 2, 2, 2,
207
+ 2, 2, 2, 2, 2, 1, 1, 1,
208
+ 2, 2, 2, 2, 2, 2, 2, 2,
209
+ 2, 3, 2, 1, 1, 1, 1, 1,
210
+ -1,-1,-1,-1
211
+ };
199
212
  #define LL_DEFAULTNORMLOG 6 /* for static allocation */
200
- static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
201
-
202
- static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
203
- 0, 0, 0, 0, 0, 0, 0, 0,
204
- 0, 0, 0, 0, 0, 0, 0, 0,
205
- 0, 0, 0, 0, 0, 0, 0, 0,
206
- 1, 1, 1, 1, 2, 2, 3, 3,
207
- 4, 4, 5, 7, 8, 9,10,11,
208
- 12,13,14,15,16 };
209
- static const S16 ML_defaultNorm[MaxML+1] = { 1, 4, 3, 2, 2, 2, 2, 2,
210
- 2, 1, 1, 1, 1, 1, 1, 1,
211
- 1, 1, 1, 1, 1, 1, 1, 1,
212
- 1, 1, 1, 1, 1, 1, 1, 1,
213
- 1, 1, 1, 1, 1, 1, 1, 1,
214
- 1, 1, 1, 1, 1, 1,-1,-1,
215
- -1,-1,-1,-1,-1 };
213
+ static UNUSED_ATTR const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
214
+
215
+ static UNUSED_ATTR const U32 ML_bits[MaxML+1] = {
216
+ 0, 0, 0, 0, 0, 0, 0, 0,
217
+ 0, 0, 0, 0, 0, 0, 0, 0,
218
+ 0, 0, 0, 0, 0, 0, 0, 0,
219
+ 0, 0, 0, 0, 0, 0, 0, 0,
220
+ 1, 1, 1, 1, 2, 2, 3, 3,
221
+ 4, 4, 5, 7, 8, 9,10,11,
222
+ 12,13,14,15,16
223
+ };
224
+ static UNUSED_ATTR const S16 ML_defaultNorm[MaxML+1] = {
225
+ 1, 4, 3, 2, 2, 2, 2, 2,
226
+ 2, 1, 1, 1, 1, 1, 1, 1,
227
+ 1, 1, 1, 1, 1, 1, 1, 1,
228
+ 1, 1, 1, 1, 1, 1, 1, 1,
229
+ 1, 1, 1, 1, 1, 1, 1, 1,
230
+ 1, 1, 1, 1, 1, 1,-1,-1,
231
+ -1,-1,-1,-1,-1
232
+ };
216
233
  #define ML_DEFAULTNORMLOG 6 /* for static allocation */
217
- static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
218
-
219
- static const S16 OF_defaultNorm[DefaultMaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2,
220
- 2, 1, 1, 1, 1, 1, 1, 1,
221
- 1, 1, 1, 1, 1, 1, 1, 1,
222
- -1,-1,-1,-1,-1 };
234
+ static UNUSED_ATTR const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
235
+
236
+ static UNUSED_ATTR const S16 OF_defaultNorm[DefaultMaxOff+1] = {
237
+ 1, 1, 1, 1, 1, 1, 2, 2,
238
+ 2, 1, 1, 1, 1, 1, 1, 1,
239
+ 1, 1, 1, 1, 1, 1, 1, 1,
240
+ -1,-1,-1,-1,-1
241
+ };
223
242
  #define OF_DEFAULTNORMLOG 5 /* for static allocation */
224
- static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
243
+ static UNUSED_ATTR const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
225
244
 
226
245
 
227
246
  /*-*******************************************
228
247
  * Shared functions to include for inlining
229
248
  *********************************************/
230
249
  static void ZSTD_copy8(void* dst, const void* src) {
231
- #ifdef __aarch64__
250
+ #if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON)
232
251
  vst1_u8((uint8_t*)dst, vld1_u8((const uint8_t*)src));
233
252
  #else
234
- memcpy(dst, src, 8);
253
+ ZSTD_memcpy(dst, src, 8);
235
254
  #endif
236
255
  }
237
256
 
238
257
  #define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
239
258
  static void ZSTD_copy16(void* dst, const void* src) {
240
- #ifdef __aarch64__
259
+ #if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON)
241
260
  vst1q_u8((uint8_t*)dst, vld1q_u8((const uint8_t*)src));
242
261
  #else
243
- memcpy(dst, src, 16);
262
+ ZSTD_memcpy(dst, src, 16);
244
263
  #endif
245
264
  }
246
265
  #define COPY16(d,s) { ZSTD_copy16(d,s); d+=16; s+=16; }
@@ -255,13 +274,13 @@ typedef enum {
255
274
  } ZSTD_overlap_e;
256
275
 
257
276
  /*! ZSTD_wildcopy() :
258
- * Custom version of memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)
277
+ * Custom version of ZSTD_memcpy(), can over read/write up to WILDCOPY_OVERLENGTH bytes (if length==0)
259
278
  * @param ovtype controls the overlap detection
260
279
  * - ZSTD_no_overlap: The source and destination are guaranteed to be at least WILDCOPY_VECLEN bytes apart.
261
280
  * - ZSTD_overlap_src_before_dst: The src and dst may overlap, but they MUST be at least 8 bytes apart.
262
281
  * The src buffer must be before the dst buffer.
263
282
  */
264
- MEM_STATIC FORCE_INLINE_ATTR
283
+ MEM_STATIC FORCE_INLINE_ATTR
265
284
  void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e const ovtype)
266
285
  {
267
286
  ptrdiff_t diff = (BYTE*)dst - (const BYTE*)src;
@@ -284,14 +303,16 @@ void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e
284
303
  * one COPY16() in the first call. Then, do two calls per loop since
285
304
  * at that point it is more likely to have a high trip count.
286
305
  */
287
- #ifndef __aarch64__
306
+ #ifdef __aarch64__
288
307
  do {
289
308
  COPY16(op, ip);
290
309
  }
291
310
  while (op < oend);
292
311
  #else
293
- COPY16(op, ip);
294
- if (op >= oend) return;
312
+ ZSTD_copy16(op, ip);
313
+ if (16 >= length) return;
314
+ op += 16;
315
+ ip += 16;
295
316
  do {
296
317
  COPY16(op, ip);
297
318
  COPY16(op, ip);
@@ -305,7 +326,7 @@ MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src,
305
326
  {
306
327
  size_t const length = MIN(dstCapacity, srcSize);
307
328
  if (length > 0) {
308
- memcpy(dst, src, length);
329
+ ZSTD_memcpy(dst, src, length);
309
330
  }
310
331
  return length;
311
332
  }
@@ -320,28 +341,46 @@ MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src,
320
341
  * In which case, resize it down to free some memory */
321
342
  #define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128
322
343
 
344
+ /* Controls whether the input/output buffer is buffered or stable. */
345
+ typedef enum {
346
+ ZSTD_bm_buffered = 0, /* Buffer the input/output */
347
+ ZSTD_bm_stable = 1 /* ZSTD_inBuffer/ZSTD_outBuffer is stable */
348
+ } ZSTD_bufferMode_e;
349
+
323
350
 
324
351
  /*-*******************************************
325
352
  * Private declarations
326
353
  *********************************************/
327
354
  typedef struct seqDef_s {
328
- U32 offset;
355
+ U32 offset; /* offset == rawOffset + ZSTD_REP_NUM, or equivalently, offCode + 1 */
329
356
  U16 litLength;
330
357
  U16 matchLength;
331
358
  } seqDef;
332
359
 
360
+ /* Controls whether seqStore has a single "long" litLength or matchLength. See seqStore_t. */
361
+ typedef enum {
362
+ ZSTD_llt_none = 0, /* no longLengthType */
363
+ ZSTD_llt_literalLength = 1, /* represents a long literal */
364
+ ZSTD_llt_matchLength = 2 /* represents a long match */
365
+ } ZSTD_longLengthType_e;
366
+
333
367
  typedef struct {
334
368
  seqDef* sequencesStart;
335
- seqDef* sequences;
369
+ seqDef* sequences; /* ptr to end of sequences */
336
370
  BYTE* litStart;
337
- BYTE* lit;
371
+ BYTE* lit; /* ptr to end of literals */
338
372
  BYTE* llCode;
339
373
  BYTE* mlCode;
340
374
  BYTE* ofCode;
341
375
  size_t maxNbSeq;
342
376
  size_t maxNbLit;
343
- U32 longLengthID; /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */
344
- U32 longLengthPos;
377
+
378
+ /* longLengthPos and longLengthType to allow us to represent either a single litLength or matchLength
379
+ * in the seqStore that has a value larger than U16 (if it exists). To do so, we increment
380
+ * the existing value of the litLength or matchLength by 0x10000.
381
+ */
382
+ ZSTD_longLengthType_e longLengthType;
383
+ U32 longLengthPos; /* Index of the sequence to apply long length modification to */
345
384
  } seqStore_t;
346
385
 
347
386
  typedef struct {
@@ -351,7 +390,7 @@ typedef struct {
351
390
 
352
391
  /**
353
392
  * Returns the ZSTD_sequenceLength for the given sequences. It handles the decoding of long sequences
354
- * indicated by longLengthPos and longLengthID, and adds MINMATCH back to matchLength.
393
+ * indicated by longLengthPos and longLengthType, and adds MINMATCH back to matchLength.
355
394
  */
356
395
  MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore, seqDef const* seq)
357
396
  {
@@ -359,10 +398,10 @@ MEM_STATIC ZSTD_sequenceLength ZSTD_getSequenceLength(seqStore_t const* seqStore
359
398
  seqLen.litLength = seq->litLength;
360
399
  seqLen.matchLength = seq->matchLength + MINMATCH;
361
400
  if (seqStore->longLengthPos == (U32)(seq - seqStore->sequencesStart)) {
362
- if (seqStore->longLengthID == 1) {
401
+ if (seqStore->longLengthType == ZSTD_llt_literalLength) {
363
402
  seqLen.litLength += 0xFFFF;
364
403
  }
365
- if (seqStore->longLengthID == 2) {
404
+ if (seqStore->longLengthType == ZSTD_llt_matchLength) {
366
405
  seqLen.matchLength += 0xFFFF;
367
406
  }
368
407
  }
@@ -384,9 +423,9 @@ const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBu
384
423
  void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
385
424
 
386
425
  /* custom memory allocation functions */
387
- void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
388
- void* ZSTD_calloc(size_t size, ZSTD_customMem customMem);
389
- void ZSTD_free(void* ptr, ZSTD_customMem customMem);
426
+ void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem);
427
+ void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem);
428
+ void ZSTD_customFree(void* ptr, ZSTD_customMem customMem);
390
429
 
391
430
 
392
431
  MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
@@ -394,8 +433,12 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus
394
433
  assert(val != 0);
395
434
  {
396
435
  # if defined(_MSC_VER) /* Visual */
397
- unsigned long r=0;
398
- return _BitScanReverse(&r, val) ? (unsigned)r : 0;
436
+ # if STATIC_BMI2 == 1
437
+ return _lzcnt_u32(val)^31;
438
+ # else
439
+ unsigned long r=0;
440
+ return _BitScanReverse(&r, val) ? (unsigned)r : 0;
441
+ # endif
399
442
  # elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
400
443
  return __builtin_clz (val) ^ 31;
401
444
  # elif defined(__ICCARM__) /* IAR Intrinsic */