zstdlib 0.3.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +30 -1
  3. data/README.md +2 -2
  4. data/Rakefile +1 -1
  5. data/ext/zstdlib/extconf.rb +3 -3
  6. data/ext/zstdlib/ruby/zlib-2.7/zstdlib.c +4895 -0
  7. data/ext/zstdlib/ruby/zlib-3.0/zstdlib.c +4994 -0
  8. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/bitstream.h +59 -51
  9. data/ext/zstdlib/zstd-1.5.0/lib/common/compiler.h +289 -0
  10. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/cpu.h +1 -3
  11. data/ext/zstdlib/zstd-1.5.0/lib/common/debug.c +24 -0
  12. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/debug.h +22 -49
  13. data/ext/zstdlib/zstd-1.5.0/lib/common/entropy_common.c +362 -0
  14. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/error_private.c +3 -1
  15. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/error_private.h +8 -4
  16. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/fse.h +50 -42
  17. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/fse_decompress.c +149 -55
  18. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/huf.h +43 -39
  19. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/mem.h +69 -25
  20. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/pool.c +30 -20
  21. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/pool.h +3 -3
  22. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/threading.c +51 -4
  23. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/threading.h +36 -4
  24. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/xxhash.c +40 -92
  25. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/xxhash.h +12 -32
  26. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/common/zstd_common.c +10 -10
  27. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_deps.h +111 -0
  28. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_internal.h +490 -0
  29. data/ext/zstdlib/zstd-1.5.0/lib/common/zstd_trace.h +154 -0
  30. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/fse_compress.c +47 -63
  31. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/hist.c +41 -63
  32. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/hist.h +13 -33
  33. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/huf_compress.c +332 -193
  34. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress.c +6393 -0
  35. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_internal.h +522 -86
  36. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_literals.c +25 -16
  37. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_literals.h +2 -2
  38. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.c +50 -24
  39. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_compress_sequences.h +11 -4
  40. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_superblock.c +572 -0
  41. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_compress_superblock.h +32 -0
  42. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_cwksp.h +662 -0
  43. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_double_fast.c +43 -41
  44. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_double_fast.h +2 -2
  45. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_fast.c +85 -80
  46. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_fast.h +2 -2
  47. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.c +2184 -0
  48. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_lazy.h +125 -0
  49. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_ldm.c +333 -208
  50. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_ldm.h +15 -3
  51. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstd_ldm_geartab.h +103 -0
  52. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_opt.c +228 -129
  53. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstd_opt.h +1 -1
  54. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/compress/zstdmt_compress.c +151 -440
  55. data/ext/zstdlib/zstd-1.5.0/lib/compress/zstdmt_compress.h +110 -0
  56. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/huf_decompress.c +395 -276
  57. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_ddict.c +20 -16
  58. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_ddict.h +3 -3
  59. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress.c +628 -231
  60. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.c +606 -380
  61. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress_block.h +8 -5
  62. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/decompress/zstd_decompress_internal.h +39 -9
  63. data/ext/zstdlib/zstd-1.5.0/lib/zdict.h +452 -0
  64. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/lib/zstd.h +740 -153
  65. data/ext/zstdlib/{zstd-1.4.2/lib/common → zstd-1.5.0/lib}/zstd_errors.h +3 -1
  66. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzclose.c +1 -1
  67. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzcompatibility.h +1 -1
  68. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzguts.h +0 -0
  69. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzlib.c +9 -9
  70. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzread.c +16 -8
  71. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/gzwrite.c +8 -8
  72. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.c +131 -45
  73. data/ext/zstdlib/{zstd-1.4.2 → zstd-1.5.0}/zlibWrapper/zstd_zlibwrapper.h +1 -1
  74. data/lib/2.2/zstdlib.so +0 -0
  75. data/lib/2.3/zstdlib.so +0 -0
  76. data/lib/2.4/zstdlib.so +0 -0
  77. data/lib/2.5/zstdlib.so +0 -0
  78. data/lib/2.6/zstdlib.so +0 -0
  79. data/lib/2.7/zstdlib.so +0 -0
  80. metadata +76 -67
  81. data/ext/zstdlib/zstd-1.4.2/lib/common/compiler.h +0 -147
  82. data/ext/zstdlib/zstd-1.4.2/lib/common/debug.c +0 -44
  83. data/ext/zstdlib/zstd-1.4.2/lib/common/entropy_common.c +0 -236
  84. data/ext/zstdlib/zstd-1.4.2/lib/common/zstd_internal.h +0 -371
  85. data/ext/zstdlib/zstd-1.4.2/lib/compress/zstd_compress.c +0 -3904
  86. data/ext/zstdlib/zstd-1.4.2/lib/compress/zstd_lazy.c +0 -1111
  87. data/ext/zstdlib/zstd-1.4.2/lib/compress/zstd_lazy.h +0 -67
  88. data/ext/zstdlib/zstd-1.4.2/lib/compress/zstdmt_compress.h +0 -192
@@ -0,0 +1,110 @@
1
+ /*
2
+ * Copyright (c) Yann Collet, 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
+ #ifndef ZSTDMT_COMPRESS_H
12
+ #define ZSTDMT_COMPRESS_H
13
+
14
+ #if defined (__cplusplus)
15
+ extern "C" {
16
+ #endif
17
+
18
+
19
+ /* Note : This is an internal API.
20
+ * These APIs used to be exposed with ZSTDLIB_API,
21
+ * because it used to be the only way to invoke MT compression.
22
+ * Now, you must use ZSTD_compress2 and ZSTD_compressStream2() instead.
23
+ *
24
+ * This API requires ZSTD_MULTITHREAD to be defined during compilation,
25
+ * otherwise ZSTDMT_createCCtx*() will fail.
26
+ */
27
+
28
+ /* === Dependencies === */
29
+ #include "../common/zstd_deps.h" /* size_t */
30
+ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */
31
+ #include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
32
+
33
+
34
+ /* === Constants === */
35
+ #ifndef ZSTDMT_NBWORKERS_MAX /* a different value can be selected at compile time */
36
+ # define ZSTDMT_NBWORKERS_MAX ((sizeof(void*)==4) /*32-bit*/ ? 64 : 256)
37
+ #endif
38
+ #ifndef ZSTDMT_JOBSIZE_MIN /* a different value can be selected at compile time */
39
+ # define ZSTDMT_JOBSIZE_MIN (512 KB)
40
+ #endif
41
+ #define ZSTDMT_JOBLOG_MAX (MEM_32bits() ? 29 : 30)
42
+ #define ZSTDMT_JOBSIZE_MAX (MEM_32bits() ? (512 MB) : (1024 MB))
43
+
44
+
45
+ /* ========================================================
46
+ * === Private interface, for use by ZSTD_compress.c ===
47
+ * === Not exposed in libzstd. Never invoke directly ===
48
+ * ======================================================== */
49
+
50
+ /* === Memory management === */
51
+ typedef struct ZSTDMT_CCtx_s ZSTDMT_CCtx;
52
+ /* Requires ZSTD_MULTITHREAD to be defined during compilation, otherwise it will return NULL. */
53
+ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers,
54
+ ZSTD_customMem cMem,
55
+ ZSTD_threadPool *pool);
56
+ size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx);
57
+
58
+ size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx);
59
+
60
+ /* === Streaming functions === */
61
+
62
+ size_t ZSTDMT_nextInputSizeHint(const ZSTDMT_CCtx* mtctx);
63
+
64
+ /*! ZSTDMT_initCStream_internal() :
65
+ * Private use only. Init streaming operation.
66
+ * expects params to be valid.
67
+ * must receive dict, or cdict, or none, but not both.
68
+ * @return : 0, or an error code */
69
+ size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
70
+ const void* dict, size_t dictSize, ZSTD_dictContentType_e dictContentType,
71
+ const ZSTD_CDict* cdict,
72
+ ZSTD_CCtx_params params, unsigned long long pledgedSrcSize);
73
+
74
+ /*! ZSTDMT_compressStream_generic() :
75
+ * Combines ZSTDMT_compressStream() with optional ZSTDMT_flushStream() or ZSTDMT_endStream()
76
+ * depending on flush directive.
77
+ * @return : minimum amount of data still to be flushed
78
+ * 0 if fully flushed
79
+ * or an error code
80
+ * note : needs to be init using any ZSTD_initCStream*() variant */
81
+ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
82
+ ZSTD_outBuffer* output,
83
+ ZSTD_inBuffer* input,
84
+ ZSTD_EndDirective endOp);
85
+
86
+ /*! ZSTDMT_toFlushNow()
87
+ * Tell how many bytes are ready to be flushed immediately.
88
+ * Probe the oldest active job (not yet entirely flushed) and check its output buffer.
89
+ * If return 0, it means there is no active job,
90
+ * or, it means oldest job is still active, but everything produced has been flushed so far,
91
+ * therefore flushing is limited by speed of oldest job. */
92
+ size_t ZSTDMT_toFlushNow(ZSTDMT_CCtx* mtctx);
93
+
94
+ /*! ZSTDMT_updateCParams_whileCompressing() :
95
+ * Updates only a selected set of compression parameters, to remain compatible with current frame.
96
+ * New parameters will be applied to next compression job. */
97
+ void ZSTDMT_updateCParams_whileCompressing(ZSTDMT_CCtx* mtctx, const ZSTD_CCtx_params* cctxParams);
98
+
99
+ /*! ZSTDMT_getFrameProgression():
100
+ * tells how much data has been consumed (input) and produced (output) for current frame.
101
+ * able to count progression inside worker threads.
102
+ */
103
+ ZSTD_frameProgression ZSTDMT_getFrameProgression(ZSTDMT_CCtx* mtctx);
104
+
105
+
106
+ #if defined (__cplusplus)
107
+ }
108
+ #endif
109
+
110
+ #endif /* ZSTDMT_COMPRESS_H */
@@ -1,47 +1,27 @@
1
1
  /* ******************************************************************
2
- huff0 huffman decoder,
3
- part of Finite State Entropy library
4
- Copyright (C) 2013-present, Yann Collet.
5
-
6
- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
-
8
- Redistribution and use in source and binary forms, with or without
9
- modification, are permitted provided that the following conditions are
10
- met:
11
-
12
- * Redistributions of source code must retain the above copyright
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
- - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
2
+ * huff0 huffman decoder,
3
+ * part of Finite State Entropy library
4
+ * Copyright (c) Yann Collet, Facebook, Inc.
5
+ *
6
+ * You can contact the author at :
7
+ * - FSE+HUF 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
  /* **************************************************************
36
16
  * Dependencies
37
17
  ****************************************************************/
38
- #include <string.h> /* memcpy, memset */
39
- #include "compiler.h"
40
- #include "bitstream.h" /* BIT_* */
41
- #include "fse.h" /* to compress headers */
18
+ #include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset */
19
+ #include "../common/compiler.h"
20
+ #include "../common/bitstream.h" /* BIT_* */
21
+ #include "../common/fse.h" /* to compress headers */
42
22
  #define HUF_STATIC_LINKING_ONLY
43
- #include "huf.h"
44
- #include "error_private.h"
23
+ #include "../common/huf.h"
24
+ #include "../common/error_private.h"
45
25
 
46
26
  /* **************************************************************
47
27
  * Macros
@@ -61,7 +41,6 @@
61
41
  * Error Management
62
42
  ****************************************************************/
63
43
  #define HUF_isError ERR_isError
64
- #define CHECK_F(f) { size_t const err_ = (f); if (HUF_isError(err_)) return err_; }
65
44
 
66
45
 
67
46
  /* **************************************************************
@@ -124,7 +103,7 @@ typedef struct { BYTE maxTableLog; BYTE tableType; BYTE tableLog; BYTE reserved;
124
103
  static DTableDesc HUF_getDTableDesc(const HUF_DTable* table)
125
104
  {
126
105
  DTableDesc dtd;
127
- memcpy(&dtd, table, sizeof(dtd));
106
+ ZSTD_memcpy(&dtd, table, sizeof(dtd));
128
107
  return dtd;
129
108
  }
130
109
 
@@ -136,29 +115,51 @@ static DTableDesc HUF_getDTableDesc(const HUF_DTable* table)
136
115
  /*-***************************/
137
116
  typedef struct { BYTE byte; BYTE nbBits; } HUF_DEltX1; /* single-symbol decoding */
138
117
 
118
+ /**
119
+ * Packs 4 HUF_DEltX1 structs into a U64. This is used to lay down 4 entries at
120
+ * a time.
121
+ */
122
+ static U64 HUF_DEltX1_set4(BYTE symbol, BYTE nbBits) {
123
+ U64 D4;
124
+ if (MEM_isLittleEndian()) {
125
+ D4 = symbol + (nbBits << 8);
126
+ } else {
127
+ D4 = (symbol << 8) + nbBits;
128
+ }
129
+ D4 *= 0x0001000100010001ULL;
130
+ return D4;
131
+ }
132
+
133
+ typedef struct {
134
+ U32 rankVal[HUF_TABLELOG_ABSOLUTEMAX + 1];
135
+ U32 rankStart[HUF_TABLELOG_ABSOLUTEMAX + 1];
136
+ U32 statsWksp[HUF_READ_STATS_WORKSPACE_SIZE_U32];
137
+ BYTE symbols[HUF_SYMBOLVALUE_MAX + 1];
138
+ BYTE huffWeight[HUF_SYMBOLVALUE_MAX + 1];
139
+ } HUF_ReadDTableX1_Workspace;
140
+
141
+
139
142
  size_t HUF_readDTableX1_wksp(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize)
143
+ {
144
+ return HUF_readDTableX1_wksp_bmi2(DTable, src, srcSize, workSpace, wkspSize, /* bmi2 */ 0);
145
+ }
146
+
147
+ size_t HUF_readDTableX1_wksp_bmi2(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize, int bmi2)
140
148
  {
141
149
  U32 tableLog = 0;
142
150
  U32 nbSymbols = 0;
143
151
  size_t iSize;
144
152
  void* const dtPtr = DTable + 1;
145
153
  HUF_DEltX1* const dt = (HUF_DEltX1*)dtPtr;
154
+ HUF_ReadDTableX1_Workspace* wksp = (HUF_ReadDTableX1_Workspace*)workSpace;
146
155
 
147
- U32* rankVal;
148
- BYTE* huffWeight;
149
- size_t spaceUsed32 = 0;
150
-
151
- rankVal = (U32 *)workSpace + spaceUsed32;
152
- spaceUsed32 += HUF_TABLELOG_ABSOLUTEMAX + 1;
153
- huffWeight = (BYTE *)((U32 *)workSpace + spaceUsed32);
154
- spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
155
-
156
- if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge);
156
+ DEBUG_STATIC_ASSERT(HUF_DECOMPRESS_WORKSPACE_SIZE >= sizeof(*wksp));
157
+ if (sizeof(*wksp) > wkspSize) return ERROR(tableLog_tooLarge);
157
158
 
158
159
  DEBUG_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUF_DTable));
159
- /* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
160
+ /* ZSTD_memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
160
161
 
161
- iSize = HUF_readStats(huffWeight, HUF_SYMBOLVALUE_MAX + 1, rankVal, &nbSymbols, &tableLog, src, srcSize);
162
+ iSize = HUF_readStats_wksp(wksp->huffWeight, HUF_SYMBOLVALUE_MAX + 1, wksp->rankVal, &nbSymbols, &tableLog, src, srcSize, wksp->statsWksp, sizeof(wksp->statsWksp), bmi2);
162
163
  if (HUF_isError(iSize)) return iSize;
163
164
 
164
165
  /* Table header */
@@ -166,40 +167,117 @@ size_t HUF_readDTableX1_wksp(HUF_DTable* DTable, const void* src, size_t srcSize
166
167
  if (tableLog > (U32)(dtd.maxTableLog+1)) return ERROR(tableLog_tooLarge); /* DTable too small, Huffman tree cannot fit in */
167
168
  dtd.tableType = 0;
168
169
  dtd.tableLog = (BYTE)tableLog;
169
- memcpy(DTable, &dtd, sizeof(dtd));
170
+ ZSTD_memcpy(DTable, &dtd, sizeof(dtd));
170
171
  }
171
172
 
172
- /* Calculate starting value for each rank */
173
- { U32 n, nextRankStart = 0;
174
- for (n=1; n<tableLog+1; n++) {
175
- U32 const current = nextRankStart;
176
- nextRankStart += (rankVal[n] << (n-1));
177
- rankVal[n] = current;
178
- } }
179
-
180
- /* fill DTable */
181
- { U32 n;
182
- for (n=0; n<nbSymbols; n++) {
183
- U32 const w = huffWeight[n];
184
- U32 const length = (1 << w) >> 1;
185
- U32 u;
186
- HUF_DEltX1 D;
187
- D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w);
188
- for (u = rankVal[w]; u < rankVal[w] + length; u++)
189
- dt[u] = D;
190
- rankVal[w] += length;
191
- } }
173
+ /* Compute symbols and rankStart given rankVal:
174
+ *
175
+ * rankVal already contains the number of values of each weight.
176
+ *
177
+ * symbols contains the symbols ordered by weight. First are the rankVal[0]
178
+ * weight 0 symbols, followed by the rankVal[1] weight 1 symbols, and so on.
179
+ * symbols[0] is filled (but unused) to avoid a branch.
180
+ *
181
+ * rankStart contains the offset where each rank belongs in the DTable.
182
+ * rankStart[0] is not filled because there are no entries in the table for
183
+ * weight 0.
184
+ */
185
+ {
186
+ int n;
187
+ int nextRankStart = 0;
188
+ int const unroll = 4;
189
+ int const nLimit = (int)nbSymbols - unroll + 1;
190
+ for (n=0; n<(int)tableLog+1; n++) {
191
+ U32 const curr = nextRankStart;
192
+ nextRankStart += wksp->rankVal[n];
193
+ wksp->rankStart[n] = curr;
194
+ }
195
+ for (n=0; n < nLimit; n += unroll) {
196
+ int u;
197
+ for (u=0; u < unroll; ++u) {
198
+ size_t const w = wksp->huffWeight[n+u];
199
+ wksp->symbols[wksp->rankStart[w]++] = (BYTE)(n+u);
200
+ }
201
+ }
202
+ for (; n < (int)nbSymbols; ++n) {
203
+ size_t const w = wksp->huffWeight[n];
204
+ wksp->symbols[wksp->rankStart[w]++] = (BYTE)n;
205
+ }
206
+ }
192
207
 
208
+ /* fill DTable
209
+ * We fill all entries of each weight in order.
210
+ * That way length is a constant for each iteration of the outter loop.
211
+ * We can switch based on the length to a different inner loop which is
212
+ * optimized for that particular case.
213
+ */
214
+ {
215
+ U32 w;
216
+ int symbol=wksp->rankVal[0];
217
+ int rankStart=0;
218
+ for (w=1; w<tableLog+1; ++w) {
219
+ int const symbolCount = wksp->rankVal[w];
220
+ int const length = (1 << w) >> 1;
221
+ int uStart = rankStart;
222
+ BYTE const nbBits = (BYTE)(tableLog + 1 - w);
223
+ int s;
224
+ int u;
225
+ switch (length) {
226
+ case 1:
227
+ for (s=0; s<symbolCount; ++s) {
228
+ HUF_DEltX1 D;
229
+ D.byte = wksp->symbols[symbol + s];
230
+ D.nbBits = nbBits;
231
+ dt[uStart] = D;
232
+ uStart += 1;
233
+ }
234
+ break;
235
+ case 2:
236
+ for (s=0; s<symbolCount; ++s) {
237
+ HUF_DEltX1 D;
238
+ D.byte = wksp->symbols[symbol + s];
239
+ D.nbBits = nbBits;
240
+ dt[uStart+0] = D;
241
+ dt[uStart+1] = D;
242
+ uStart += 2;
243
+ }
244
+ break;
245
+ case 4:
246
+ for (s=0; s<symbolCount; ++s) {
247
+ U64 const D4 = HUF_DEltX1_set4(wksp->symbols[symbol + s], nbBits);
248
+ MEM_write64(dt + uStart, D4);
249
+ uStart += 4;
250
+ }
251
+ break;
252
+ case 8:
253
+ for (s=0; s<symbolCount; ++s) {
254
+ U64 const D4 = HUF_DEltX1_set4(wksp->symbols[symbol + s], nbBits);
255
+ MEM_write64(dt + uStart, D4);
256
+ MEM_write64(dt + uStart + 4, D4);
257
+ uStart += 8;
258
+ }
259
+ break;
260
+ default:
261
+ for (s=0; s<symbolCount; ++s) {
262
+ U64 const D4 = HUF_DEltX1_set4(wksp->symbols[symbol + s], nbBits);
263
+ for (u=0; u < length; u += 16) {
264
+ MEM_write64(dt + uStart + u + 0, D4);
265
+ MEM_write64(dt + uStart + u + 4, D4);
266
+ MEM_write64(dt + uStart + u + 8, D4);
267
+ MEM_write64(dt + uStart + u + 12, D4);
268
+ }
269
+ assert(u == length);
270
+ uStart += length;
271
+ }
272
+ break;
273
+ }
274
+ symbol += symbolCount;
275
+ rankStart += symbolCount * length;
276
+ }
277
+ }
193
278
  return iSize;
194
279
  }
195
280
 
196
- size_t HUF_readDTableX1(HUF_DTable* DTable, const void* src, size_t srcSize)
197
- {
198
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
199
- return HUF_readDTableX1_wksp(DTable, src, srcSize,
200
- workSpace, sizeof(workSpace));
201
- }
202
-
203
281
  FORCE_INLINE_TEMPLATE BYTE
204
282
  HUF_decodeSymbolX1(BIT_DStream_t* Dstream, const HUF_DEltX1* dt, const U32 dtLog)
205
283
  {
@@ -280,6 +358,7 @@ HUF_decompress4X1_usingDTable_internal_body(
280
358
  { const BYTE* const istart = (const BYTE*) cSrc;
281
359
  BYTE* const ostart = (BYTE*) dst;
282
360
  BYTE* const oend = ostart + dstSize;
361
+ BYTE* const olimit = oend - 3;
283
362
  const void* const dtPtr = DTable + 1;
284
363
  const HUF_DEltX1* const dt = (const HUF_DEltX1*)dtPtr;
285
364
 
@@ -304,9 +383,9 @@ HUF_decompress4X1_usingDTable_internal_body(
304
383
  BYTE* op2 = opStart2;
305
384
  BYTE* op3 = opStart3;
306
385
  BYTE* op4 = opStart4;
307
- U32 endSignal = BIT_DStream_unfinished;
308
386
  DTableDesc const dtd = HUF_getDTableDesc(DTable);
309
387
  U32 const dtLog = dtd.tableLog;
388
+ U32 endSignal = 1;
310
389
 
311
390
  if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */
312
391
  CHECK_F( BIT_initDStream(&bitD1, istart1, length1) );
@@ -315,8 +394,7 @@ HUF_decompress4X1_usingDTable_internal_body(
315
394
  CHECK_F( BIT_initDStream(&bitD4, istart4, length4) );
316
395
 
317
396
  /* up to 16 symbols per loop (4 symbols per stream) in 64-bit mode */
318
- endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
319
- while ( (endSignal==BIT_DStream_unfinished) && (op4<(oend-3)) ) {
397
+ for ( ; (endSignal) & (op4 < olimit) ; ) {
320
398
  HUF_DECODE_SYMBOLX1_2(op1, &bitD1);
321
399
  HUF_DECODE_SYMBOLX1_2(op2, &bitD2);
322
400
  HUF_DECODE_SYMBOLX1_2(op3, &bitD3);
@@ -333,10 +411,10 @@ HUF_decompress4X1_usingDTable_internal_body(
333
411
  HUF_DECODE_SYMBOLX1_0(op2, &bitD2);
334
412
  HUF_DECODE_SYMBOLX1_0(op3, &bitD3);
335
413
  HUF_DECODE_SYMBOLX1_0(op4, &bitD4);
336
- BIT_reloadDStream(&bitD1);
337
- BIT_reloadDStream(&bitD2);
338
- BIT_reloadDStream(&bitD3);
339
- BIT_reloadDStream(&bitD4);
414
+ endSignal &= BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished;
415
+ endSignal &= BIT_reloadDStreamFast(&bitD2) == BIT_DStream_unfinished;
416
+ endSignal &= BIT_reloadDStreamFast(&bitD3) == BIT_DStream_unfinished;
417
+ endSignal &= BIT_reloadDStreamFast(&bitD4) == BIT_DStream_unfinished;
340
418
  }
341
419
 
342
420
  /* check corruption */
@@ -398,20 +476,6 @@ size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
398
476
  }
399
477
 
400
478
 
401
- size_t HUF_decompress1X1_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
402
- const void* cSrc, size_t cSrcSize)
403
- {
404
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
405
- return HUF_decompress1X1_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
406
- workSpace, sizeof(workSpace));
407
- }
408
-
409
- size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
410
- {
411
- HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
412
- return HUF_decompress1X1_DCtx (DTable, dst, dstSize, cSrc, cSrcSize);
413
- }
414
-
415
479
  size_t HUF_decompress4X1_usingDTable(
416
480
  void* dst, size_t dstSize,
417
481
  const void* cSrc, size_t cSrcSize,
@@ -428,8 +492,7 @@ static size_t HUF_decompress4X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size
428
492
  {
429
493
  const BYTE* ip = (const BYTE*) cSrc;
430
494
 
431
- size_t const hSize = HUF_readDTableX1_wksp (dctx, cSrc, cSrcSize,
432
- workSpace, wkspSize);
495
+ size_t const hSize = HUF_readDTableX1_wksp_bmi2(dctx, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
433
496
  if (HUF_isError(hSize)) return hSize;
434
497
  if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
435
498
  ip += hSize; cSrcSize -= hSize;
@@ -445,18 +508,6 @@ size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
445
508
  }
446
509
 
447
510
 
448
- size_t HUF_decompress4X1_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
449
- {
450
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
451
- return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
452
- workSpace, sizeof(workSpace));
453
- }
454
- size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
455
- {
456
- HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
457
- return HUF_decompress4X1_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
458
- }
459
-
460
511
  #endif /* HUF_FORCE_DECOMPRESS_X2 */
461
512
 
462
513
 
@@ -477,13 +528,15 @@ typedef rankValCol_t rankVal_t[HUF_TABLELOG_MAX];
477
528
  static void HUF_fillDTableX2Level2(HUF_DEltX2* DTable, U32 sizeLog, const U32 consumed,
478
529
  const U32* rankValOrigin, const int minWeight,
479
530
  const sortedSymbol_t* sortedSymbols, const U32 sortedListSize,
480
- U32 nbBitsBaseline, U16 baseSeq)
531
+ U32 nbBitsBaseline, U16 baseSeq, U32* wksp, size_t wkspSize)
481
532
  {
482
533
  HUF_DEltX2 DElt;
483
- U32 rankVal[HUF_TABLELOG_MAX + 1];
534
+ U32* rankVal = wksp;
484
535
 
536
+ assert(wkspSize >= HUF_TABLELOG_MAX + 1);
537
+ (void)wkspSize;
485
538
  /* get pre-calculated rankVal */
486
- memcpy(rankVal, rankValOrigin, sizeof(rankVal));
539
+ ZSTD_memcpy(rankVal, rankValOrigin, sizeof(U32) * (HUF_TABLELOG_MAX + 1));
487
540
 
488
541
  /* fill skipped values */
489
542
  if (minWeight>1) {
@@ -518,14 +571,18 @@ static void HUF_fillDTableX2Level2(HUF_DEltX2* DTable, U32 sizeLog, const U32 co
518
571
  static void HUF_fillDTableX2(HUF_DEltX2* DTable, const U32 targetLog,
519
572
  const sortedSymbol_t* sortedList, const U32 sortedListSize,
520
573
  const U32* rankStart, rankVal_t rankValOrigin, const U32 maxWeight,
521
- const U32 nbBitsBaseline)
574
+ const U32 nbBitsBaseline, U32* wksp, size_t wkspSize)
522
575
  {
523
- U32 rankVal[HUF_TABLELOG_MAX + 1];
576
+ U32* rankVal = wksp;
524
577
  const int scaleLog = nbBitsBaseline - targetLog; /* note : targetLog >= srcLog, hence scaleLog <= 1 */
525
578
  const U32 minBits = nbBitsBaseline - maxWeight;
526
579
  U32 s;
527
580
 
528
- memcpy(rankVal, rankValOrigin, sizeof(rankVal));
581
+ assert(wkspSize >= HUF_TABLELOG_MAX + 1);
582
+ wksp += HUF_TABLELOG_MAX + 1;
583
+ wkspSize -= HUF_TABLELOG_MAX + 1;
584
+
585
+ ZSTD_memcpy(rankVal, rankValOrigin, sizeof(U32) * (HUF_TABLELOG_MAX + 1));
529
586
 
530
587
  /* fill DTable */
531
588
  for (s=0; s<sortedListSize; s++) {
@@ -543,7 +600,7 @@ static void HUF_fillDTableX2(HUF_DEltX2* DTable, const U32 targetLog,
543
600
  HUF_fillDTableX2Level2(DTable+start, targetLog-nbBits, nbBits,
544
601
  rankValOrigin[nbBits], minWeight,
545
602
  sortedList+sortedRank, sortedListSize-sortedRank,
546
- nbBitsBaseline, symbol);
603
+ nbBitsBaseline, symbol, wksp, wkspSize);
547
604
  } else {
548
605
  HUF_DEltX2 DElt;
549
606
  MEM_writeLE16(&(DElt.sequence), symbol);
@@ -557,6 +614,15 @@ static void HUF_fillDTableX2(HUF_DEltX2* DTable, const U32 targetLog,
557
614
  }
558
615
  }
559
616
 
617
+ typedef struct {
618
+ rankValCol_t rankVal[HUF_TABLELOG_MAX];
619
+ U32 rankStats[HUF_TABLELOG_MAX + 1];
620
+ U32 rankStart0[HUF_TABLELOG_MAX + 2];
621
+ sortedSymbol_t sortedSymbol[HUF_SYMBOLVALUE_MAX + 1];
622
+ BYTE weightList[HUF_SYMBOLVALUE_MAX + 1];
623
+ U32 calleeWksp[HUF_READ_STATS_WORKSPACE_SIZE_U32];
624
+ } HUF_ReadDTableX2_Workspace;
625
+
560
626
  size_t HUF_readDTableX2_wksp(HUF_DTable* DTable,
561
627
  const void* src, size_t srcSize,
562
628
  void* workSpace, size_t wkspSize)
@@ -569,48 +635,33 @@ size_t HUF_readDTableX2_wksp(HUF_DTable* DTable,
569
635
  HUF_DEltX2* const dt = (HUF_DEltX2*)dtPtr;
570
636
  U32 *rankStart;
571
637
 
572
- rankValCol_t* rankVal;
573
- U32* rankStats;
574
- U32* rankStart0;
575
- sortedSymbol_t* sortedSymbol;
576
- BYTE* weightList;
577
- size_t spaceUsed32 = 0;
578
-
579
- rankVal = (rankValCol_t *)((U32 *)workSpace + spaceUsed32);
580
- spaceUsed32 += (sizeof(rankValCol_t) * HUF_TABLELOG_MAX) >> 2;
581
- rankStats = (U32 *)workSpace + spaceUsed32;
582
- spaceUsed32 += HUF_TABLELOG_MAX + 1;
583
- rankStart0 = (U32 *)workSpace + spaceUsed32;
584
- spaceUsed32 += HUF_TABLELOG_MAX + 2;
585
- sortedSymbol = (sortedSymbol_t *)workSpace + (spaceUsed32 * sizeof(U32)) / sizeof(sortedSymbol_t);
586
- spaceUsed32 += HUF_ALIGN(sizeof(sortedSymbol_t) * (HUF_SYMBOLVALUE_MAX + 1), sizeof(U32)) >> 2;
587
- weightList = (BYTE *)((U32 *)workSpace + spaceUsed32);
588
- spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
589
-
590
- if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge);
591
-
592
- rankStart = rankStart0 + 1;
593
- memset(rankStats, 0, sizeof(U32) * (2 * HUF_TABLELOG_MAX + 2 + 1));
638
+ HUF_ReadDTableX2_Workspace* const wksp = (HUF_ReadDTableX2_Workspace*)workSpace;
639
+
640
+ if (sizeof(*wksp) > wkspSize) return ERROR(GENERIC);
641
+
642
+ rankStart = wksp->rankStart0 + 1;
643
+ ZSTD_memset(wksp->rankStats, 0, sizeof(wksp->rankStats));
644
+ ZSTD_memset(wksp->rankStart0, 0, sizeof(wksp->rankStart0));
594
645
 
595
646
  DEBUG_STATIC_ASSERT(sizeof(HUF_DEltX2) == sizeof(HUF_DTable)); /* if compiler fails here, assertion is wrong */
596
647
  if (maxTableLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
597
- /* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
648
+ /* ZSTD_memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
598
649
 
599
- iSize = HUF_readStats(weightList, HUF_SYMBOLVALUE_MAX + 1, rankStats, &nbSymbols, &tableLog, src, srcSize);
650
+ iSize = HUF_readStats_wksp(wksp->weightList, HUF_SYMBOLVALUE_MAX + 1, wksp->rankStats, &nbSymbols, &tableLog, src, srcSize, wksp->calleeWksp, sizeof(wksp->calleeWksp), /* bmi2 */ 0);
600
651
  if (HUF_isError(iSize)) return iSize;
601
652
 
602
653
  /* check result */
603
654
  if (tableLog > maxTableLog) return ERROR(tableLog_tooLarge); /* DTable can't fit code depth */
604
655
 
605
656
  /* find maxWeight */
606
- for (maxW = tableLog; rankStats[maxW]==0; maxW--) {} /* necessarily finds a solution before 0 */
657
+ for (maxW = tableLog; wksp->rankStats[maxW]==0; maxW--) {} /* necessarily finds a solution before 0 */
607
658
 
608
659
  /* Get start index of each weight */
609
660
  { U32 w, nextRankStart = 0;
610
661
  for (w=1; w<maxW+1; w++) {
611
- U32 current = nextRankStart;
612
- nextRankStart += rankStats[w];
613
- rankStart[w] = current;
662
+ U32 curr = nextRankStart;
663
+ nextRankStart += wksp->rankStats[w];
664
+ rankStart[w] = curr;
614
665
  }
615
666
  rankStart[0] = nextRankStart; /* put all 0w symbols at the end of sorted list*/
616
667
  sizeOfSort = nextRankStart;
@@ -619,57 +670,51 @@ size_t HUF_readDTableX2_wksp(HUF_DTable* DTable,
619
670
  /* sort symbols by weight */
620
671
  { U32 s;
621
672
  for (s=0; s<nbSymbols; s++) {
622
- U32 const w = weightList[s];
673
+ U32 const w = wksp->weightList[s];
623
674
  U32 const r = rankStart[w]++;
624
- sortedSymbol[r].symbol = (BYTE)s;
625
- sortedSymbol[r].weight = (BYTE)w;
675
+ wksp->sortedSymbol[r].symbol = (BYTE)s;
676
+ wksp->sortedSymbol[r].weight = (BYTE)w;
626
677
  }
627
678
  rankStart[0] = 0; /* forget 0w symbols; this is beginning of weight(1) */
628
679
  }
629
680
 
630
681
  /* Build rankVal */
631
- { U32* const rankVal0 = rankVal[0];
682
+ { U32* const rankVal0 = wksp->rankVal[0];
632
683
  { int const rescale = (maxTableLog-tableLog) - 1; /* tableLog <= maxTableLog */
633
684
  U32 nextRankVal = 0;
634
685
  U32 w;
635
686
  for (w=1; w<maxW+1; w++) {
636
- U32 current = nextRankVal;
637
- nextRankVal += rankStats[w] << (w+rescale);
638
- rankVal0[w] = current;
687
+ U32 curr = nextRankVal;
688
+ nextRankVal += wksp->rankStats[w] << (w+rescale);
689
+ rankVal0[w] = curr;
639
690
  } }
640
691
  { U32 const minBits = tableLog+1 - maxW;
641
692
  U32 consumed;
642
693
  for (consumed = minBits; consumed < maxTableLog - minBits + 1; consumed++) {
643
- U32* const rankValPtr = rankVal[consumed];
694
+ U32* const rankValPtr = wksp->rankVal[consumed];
644
695
  U32 w;
645
696
  for (w = 1; w < maxW+1; w++) {
646
697
  rankValPtr[w] = rankVal0[w] >> consumed;
647
698
  } } } }
648
699
 
649
700
  HUF_fillDTableX2(dt, maxTableLog,
650
- sortedSymbol, sizeOfSort,
651
- rankStart0, rankVal, maxW,
652
- tableLog+1);
701
+ wksp->sortedSymbol, sizeOfSort,
702
+ wksp->rankStart0, wksp->rankVal, maxW,
703
+ tableLog+1,
704
+ wksp->calleeWksp, sizeof(wksp->calleeWksp) / sizeof(U32));
653
705
 
654
706
  dtd.tableLog = (BYTE)maxTableLog;
655
707
  dtd.tableType = 1;
656
- memcpy(DTable, &dtd, sizeof(dtd));
708
+ ZSTD_memcpy(DTable, &dtd, sizeof(dtd));
657
709
  return iSize;
658
710
  }
659
711
 
660
- size_t HUF_readDTableX2(HUF_DTable* DTable, const void* src, size_t srcSize)
661
- {
662
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
663
- return HUF_readDTableX2_wksp(DTable, src, srcSize,
664
- workSpace, sizeof(workSpace));
665
- }
666
-
667
712
 
668
713
  FORCE_INLINE_TEMPLATE U32
669
714
  HUF_decodeSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog)
670
715
  {
671
716
  size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */
672
- memcpy(op, dt+val, 2);
717
+ ZSTD_memcpy(op, dt+val, 2);
673
718
  BIT_skipBits(DStream, dt[val].nbBits);
674
719
  return dt[val].length;
675
720
  }
@@ -678,7 +723,7 @@ FORCE_INLINE_TEMPLATE U32
678
723
  HUF_decodeLastSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog)
679
724
  {
680
725
  size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */
681
- memcpy(op, dt+val, 1);
726
+ ZSTD_memcpy(op, dt+val, 1);
682
727
  if (dt[val].length==1) BIT_skipBits(DStream, dt[val].nbBits);
683
728
  else {
684
729
  if (DStream->bitsConsumed < (sizeof(DStream->bitContainer)*8)) {
@@ -755,7 +800,6 @@ HUF_decompress1X2_usingDTable_internal_body(
755
800
  return dstSize;
756
801
  }
757
802
 
758
-
759
803
  FORCE_INLINE_TEMPLATE size_t
760
804
  HUF_decompress4X2_usingDTable_internal_body(
761
805
  void* dst, size_t dstSize,
@@ -767,6 +811,7 @@ HUF_decompress4X2_usingDTable_internal_body(
767
811
  { const BYTE* const istart = (const BYTE*) cSrc;
768
812
  BYTE* const ostart = (BYTE*) dst;
769
813
  BYTE* const oend = ostart + dstSize;
814
+ BYTE* const olimit = oend - (sizeof(size_t)-1);
770
815
  const void* const dtPtr = DTable+1;
771
816
  const HUF_DEltX2* const dt = (const HUF_DEltX2*)dtPtr;
772
817
 
@@ -791,7 +836,7 @@ HUF_decompress4X2_usingDTable_internal_body(
791
836
  BYTE* op2 = opStart2;
792
837
  BYTE* op3 = opStart3;
793
838
  BYTE* op4 = opStart4;
794
- U32 endSignal;
839
+ U32 endSignal = 1;
795
840
  DTableDesc const dtd = HUF_getDTableDesc(DTable);
796
841
  U32 const dtLog = dtd.tableLog;
797
842
 
@@ -802,8 +847,29 @@ HUF_decompress4X2_usingDTable_internal_body(
802
847
  CHECK_F( BIT_initDStream(&bitD4, istart4, length4) );
803
848
 
804
849
  /* 16-32 symbols per loop (4-8 symbols per stream) */
805
- endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
806
- for ( ; (endSignal==BIT_DStream_unfinished) & (op4<(oend-(sizeof(bitD4.bitContainer)-1))) ; ) {
850
+ for ( ; (endSignal) & (op4 < olimit); ) {
851
+ #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__))
852
+ HUF_DECODE_SYMBOLX2_2(op1, &bitD1);
853
+ HUF_DECODE_SYMBOLX2_1(op1, &bitD1);
854
+ HUF_DECODE_SYMBOLX2_2(op1, &bitD1);
855
+ HUF_DECODE_SYMBOLX2_0(op1, &bitD1);
856
+ HUF_DECODE_SYMBOLX2_2(op2, &bitD2);
857
+ HUF_DECODE_SYMBOLX2_1(op2, &bitD2);
858
+ HUF_DECODE_SYMBOLX2_2(op2, &bitD2);
859
+ HUF_DECODE_SYMBOLX2_0(op2, &bitD2);
860
+ endSignal &= BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished;
861
+ endSignal &= BIT_reloadDStreamFast(&bitD2) == BIT_DStream_unfinished;
862
+ HUF_DECODE_SYMBOLX2_2(op3, &bitD3);
863
+ HUF_DECODE_SYMBOLX2_1(op3, &bitD3);
864
+ HUF_DECODE_SYMBOLX2_2(op3, &bitD3);
865
+ HUF_DECODE_SYMBOLX2_0(op3, &bitD3);
866
+ HUF_DECODE_SYMBOLX2_2(op4, &bitD4);
867
+ HUF_DECODE_SYMBOLX2_1(op4, &bitD4);
868
+ HUF_DECODE_SYMBOLX2_2(op4, &bitD4);
869
+ HUF_DECODE_SYMBOLX2_0(op4, &bitD4);
870
+ endSignal &= BIT_reloadDStreamFast(&bitD3) == BIT_DStream_unfinished;
871
+ endSignal &= BIT_reloadDStreamFast(&bitD4) == BIT_DStream_unfinished;
872
+ #else
807
873
  HUF_DECODE_SYMBOLX2_2(op1, &bitD1);
808
874
  HUF_DECODE_SYMBOLX2_2(op2, &bitD2);
809
875
  HUF_DECODE_SYMBOLX2_2(op3, &bitD3);
@@ -820,8 +886,12 @@ HUF_decompress4X2_usingDTable_internal_body(
820
886
  HUF_DECODE_SYMBOLX2_0(op2, &bitD2);
821
887
  HUF_DECODE_SYMBOLX2_0(op3, &bitD3);
822
888
  HUF_DECODE_SYMBOLX2_0(op4, &bitD4);
823
-
824
- endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
889
+ endSignal = (U32)LIKELY(
890
+ (BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished)
891
+ & (BIT_reloadDStreamFast(&bitD2) == BIT_DStream_unfinished)
892
+ & (BIT_reloadDStreamFast(&bitD3) == BIT_DStream_unfinished)
893
+ & (BIT_reloadDStreamFast(&bitD4) == BIT_DStream_unfinished));
894
+ #endif
825
895
  }
826
896
 
827
897
  /* check corruption */
@@ -874,20 +944,6 @@ size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
874
944
  }
875
945
 
876
946
 
877
- size_t HUF_decompress1X2_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
878
- const void* cSrc, size_t cSrcSize)
879
- {
880
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
881
- return HUF_decompress1X2_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
882
- workSpace, sizeof(workSpace));
883
- }
884
-
885
- size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
886
- {
887
- HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
888
- return HUF_decompress1X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
889
- }
890
-
891
947
  size_t HUF_decompress4X2_usingDTable(
892
948
  void* dst, size_t dstSize,
893
949
  const void* cSrc, size_t cSrcSize,
@@ -921,20 +977,6 @@ size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
921
977
  }
922
978
 
923
979
 
924
- size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
925
- const void* cSrc, size_t cSrcSize)
926
- {
927
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
928
- return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
929
- workSpace, sizeof(workSpace));
930
- }
931
-
932
- size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
933
- {
934
- HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
935
- return HUF_decompress4X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
936
- }
937
-
938
980
  #endif /* HUF_FORCE_DECOMPRESS_X1 */
939
981
 
940
982
 
@@ -1035,67 +1077,6 @@ U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize)
1035
1077
  }
1036
1078
 
1037
1079
 
1038
- typedef size_t (*decompressionAlgo)(void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
1039
-
1040
- size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1041
- {
1042
- #if !defined(HUF_FORCE_DECOMPRESS_X1) && !defined(HUF_FORCE_DECOMPRESS_X2)
1043
- static const decompressionAlgo decompress[2] = { HUF_decompress4X1, HUF_decompress4X2 };
1044
- #endif
1045
-
1046
- /* validation checks */
1047
- if (dstSize == 0) return ERROR(dstSize_tooSmall);
1048
- if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
1049
- if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1050
- if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1051
-
1052
- { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
1053
- #if defined(HUF_FORCE_DECOMPRESS_X1)
1054
- (void)algoNb;
1055
- assert(algoNb == 0);
1056
- return HUF_decompress4X1(dst, dstSize, cSrc, cSrcSize);
1057
- #elif defined(HUF_FORCE_DECOMPRESS_X2)
1058
- (void)algoNb;
1059
- assert(algoNb == 1);
1060
- return HUF_decompress4X2(dst, dstSize, cSrc, cSrcSize);
1061
- #else
1062
- return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
1063
- #endif
1064
- }
1065
- }
1066
-
1067
- size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1068
- {
1069
- /* validation checks */
1070
- if (dstSize == 0) return ERROR(dstSize_tooSmall);
1071
- if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
1072
- if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1073
- if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1074
-
1075
- { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
1076
- #if defined(HUF_FORCE_DECOMPRESS_X1)
1077
- (void)algoNb;
1078
- assert(algoNb == 0);
1079
- return HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
1080
- #elif defined(HUF_FORCE_DECOMPRESS_X2)
1081
- (void)algoNb;
1082
- assert(algoNb == 1);
1083
- return HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
1084
- #else
1085
- return algoNb ? HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) :
1086
- HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ;
1087
- #endif
1088
- }
1089
- }
1090
-
1091
- size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1092
- {
1093
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1094
- return HUF_decompress4X_hufOnly_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
1095
- workSpace, sizeof(workSpace));
1096
- }
1097
-
1098
-
1099
1080
  size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst,
1100
1081
  size_t dstSize, const void* cSrc,
1101
1082
  size_t cSrcSize, void* workSpace,
@@ -1129,8 +1110,8 @@ size_t HUF_decompress1X_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
1129
1110
  /* validation checks */
1130
1111
  if (dstSize == 0) return ERROR(dstSize_tooSmall);
1131
1112
  if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
1132
- if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1133
- if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1113
+ if (cSrcSize == dstSize) { ZSTD_memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1114
+ if (cSrcSize == 1) { ZSTD_memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1134
1115
 
1135
1116
  { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
1136
1117
  #if defined(HUF_FORCE_DECOMPRESS_X1)
@@ -1152,14 +1133,6 @@ size_t HUF_decompress1X_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
1152
1133
  }
1153
1134
  }
1154
1135
 
1155
- size_t HUF_decompress1X_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
1156
- const void* cSrc, size_t cSrcSize)
1157
- {
1158
- U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1159
- return HUF_decompress1X_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
1160
- workSpace, sizeof(workSpace));
1161
- }
1162
-
1163
1136
 
1164
1137
  size_t HUF_decompress1X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2)
1165
1138
  {
@@ -1183,7 +1156,7 @@ size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstS
1183
1156
  {
1184
1157
  const BYTE* ip = (const BYTE*) cSrc;
1185
1158
 
1186
- size_t const hSize = HUF_readDTableX1_wksp(dctx, cSrc, cSrcSize, workSpace, wkspSize);
1159
+ size_t const hSize = HUF_readDTableX1_wksp_bmi2(dctx, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
1187
1160
  if (HUF_isError(hSize)) return hSize;
1188
1161
  if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
1189
1162
  ip += hSize; cSrcSize -= hSize;
@@ -1230,3 +1203,149 @@ size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t ds
1230
1203
  #endif
1231
1204
  }
1232
1205
  }
1206
+
1207
+ #ifndef ZSTD_NO_UNUSED_FUNCTIONS
1208
+ #ifndef HUF_FORCE_DECOMPRESS_X2
1209
+ size_t HUF_readDTableX1(HUF_DTable* DTable, const void* src, size_t srcSize)
1210
+ {
1211
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1212
+ return HUF_readDTableX1_wksp(DTable, src, srcSize,
1213
+ workSpace, sizeof(workSpace));
1214
+ }
1215
+
1216
+ size_t HUF_decompress1X1_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
1217
+ const void* cSrc, size_t cSrcSize)
1218
+ {
1219
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1220
+ return HUF_decompress1X1_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
1221
+ workSpace, sizeof(workSpace));
1222
+ }
1223
+
1224
+ size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1225
+ {
1226
+ HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
1227
+ return HUF_decompress1X1_DCtx (DTable, dst, dstSize, cSrc, cSrcSize);
1228
+ }
1229
+ #endif
1230
+
1231
+ #ifndef HUF_FORCE_DECOMPRESS_X1
1232
+ size_t HUF_readDTableX2(HUF_DTable* DTable, const void* src, size_t srcSize)
1233
+ {
1234
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1235
+ return HUF_readDTableX2_wksp(DTable, src, srcSize,
1236
+ workSpace, sizeof(workSpace));
1237
+ }
1238
+
1239
+ size_t HUF_decompress1X2_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
1240
+ const void* cSrc, size_t cSrcSize)
1241
+ {
1242
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1243
+ return HUF_decompress1X2_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
1244
+ workSpace, sizeof(workSpace));
1245
+ }
1246
+
1247
+ size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1248
+ {
1249
+ HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
1250
+ return HUF_decompress1X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
1251
+ }
1252
+ #endif
1253
+
1254
+ #ifndef HUF_FORCE_DECOMPRESS_X2
1255
+ size_t HUF_decompress4X1_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1256
+ {
1257
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1258
+ return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
1259
+ workSpace, sizeof(workSpace));
1260
+ }
1261
+ size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1262
+ {
1263
+ HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
1264
+ return HUF_decompress4X1_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
1265
+ }
1266
+ #endif
1267
+
1268
+ #ifndef HUF_FORCE_DECOMPRESS_X1
1269
+ size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
1270
+ const void* cSrc, size_t cSrcSize)
1271
+ {
1272
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1273
+ return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
1274
+ workSpace, sizeof(workSpace));
1275
+ }
1276
+
1277
+ size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1278
+ {
1279
+ HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
1280
+ return HUF_decompress4X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
1281
+ }
1282
+ #endif
1283
+
1284
+ typedef size_t (*decompressionAlgo)(void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
1285
+
1286
+ size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1287
+ {
1288
+ #if !defined(HUF_FORCE_DECOMPRESS_X1) && !defined(HUF_FORCE_DECOMPRESS_X2)
1289
+ static const decompressionAlgo decompress[2] = { HUF_decompress4X1, HUF_decompress4X2 };
1290
+ #endif
1291
+
1292
+ /* validation checks */
1293
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
1294
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
1295
+ if (cSrcSize == dstSize) { ZSTD_memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1296
+ if (cSrcSize == 1) { ZSTD_memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1297
+
1298
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
1299
+ #if defined(HUF_FORCE_DECOMPRESS_X1)
1300
+ (void)algoNb;
1301
+ assert(algoNb == 0);
1302
+ return HUF_decompress4X1(dst, dstSize, cSrc, cSrcSize);
1303
+ #elif defined(HUF_FORCE_DECOMPRESS_X2)
1304
+ (void)algoNb;
1305
+ assert(algoNb == 1);
1306
+ return HUF_decompress4X2(dst, dstSize, cSrc, cSrcSize);
1307
+ #else
1308
+ return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
1309
+ #endif
1310
+ }
1311
+ }
1312
+
1313
+ size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1314
+ {
1315
+ /* validation checks */
1316
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
1317
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
1318
+ if (cSrcSize == dstSize) { ZSTD_memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
1319
+ if (cSrcSize == 1) { ZSTD_memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
1320
+
1321
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
1322
+ #if defined(HUF_FORCE_DECOMPRESS_X1)
1323
+ (void)algoNb;
1324
+ assert(algoNb == 0);
1325
+ return HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
1326
+ #elif defined(HUF_FORCE_DECOMPRESS_X2)
1327
+ (void)algoNb;
1328
+ assert(algoNb == 1);
1329
+ return HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
1330
+ #else
1331
+ return algoNb ? HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) :
1332
+ HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ;
1333
+ #endif
1334
+ }
1335
+ }
1336
+
1337
+ size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
1338
+ {
1339
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1340
+ return HUF_decompress4X_hufOnly_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
1341
+ workSpace, sizeof(workSpace));
1342
+ }
1343
+
1344
+ size_t HUF_decompress1X_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
1345
+ const void* cSrc, size_t cSrcSize)
1346
+ {
1347
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
1348
+ return HUF_decompress1X_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
1349
+ workSpace, sizeof(workSpace));
1350
+ }
1351
+ #endif