zstd-ruby 1.5.1.1 → 1.5.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +57 -4
  4. data/Rakefile +8 -2
  5. data/ext/zstdruby/{zstdruby.h → common.h} +2 -0
  6. data/ext/zstdruby/libzstd/common/pool.c +11 -6
  7. data/ext/zstdruby/libzstd/common/pool.h +2 -2
  8. data/ext/zstdruby/libzstd/common/portability_macros.h +6 -0
  9. data/ext/zstdruby/libzstd/common/zstd_internal.h +3 -4
  10. data/ext/zstdruby/libzstd/compress/zstd_compress.c +114 -96
  11. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +72 -39
  12. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +10 -10
  13. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +1 -1
  14. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +38 -24
  15. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +10 -10
  16. data/ext/zstdruby/libzstd/compress/zstd_fast.c +11 -11
  17. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +66 -62
  18. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +5 -3
  19. data/ext/zstdruby/libzstd/compress/zstd_opt.c +66 -43
  20. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +17 -9
  21. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +4 -1
  22. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +2 -2
  23. data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +17 -3
  24. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +2 -2
  25. data/ext/zstdruby/libzstd/zstd.h +1 -1
  26. data/ext/zstdruby/main.c +14 -0
  27. data/ext/zstdruby/streaming_compress.c +183 -0
  28. data/ext/zstdruby/streaming_compress.h +5 -0
  29. data/ext/zstdruby/streaming_decompress.c +123 -0
  30. data/ext/zstdruby/zstdruby.c +4 -6
  31. data/lib/zstd-ruby/version.rb +1 -1
  32. data/zstd-ruby.gemspec +1 -1
  33. metadata +11 -40
  34. data/.github/dependabot.yml +0 -8
  35. data/.github/workflows/ruby.yml +0 -35
  36. data/ext/zstdruby/libzstd/.gitignore +0 -3
  37. data/ext/zstdruby/libzstd/BUCK +0 -232
  38. data/ext/zstdruby/libzstd/Makefile +0 -357
  39. data/ext/zstdruby/libzstd/README.md +0 -217
  40. data/ext/zstdruby/libzstd/deprecated/zbuff.h +0 -214
  41. data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +0 -26
  42. data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +0 -167
  43. data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +0 -75
  44. data/ext/zstdruby/libzstd/dll/example/Makefile +0 -48
  45. data/ext/zstdruby/libzstd/dll/example/README.md +0 -63
  46. data/ext/zstdruby/libzstd/dll/example/build_package.bat +0 -20
  47. data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +0 -25
  48. data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +0 -181
  49. data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +0 -415
  50. data/ext/zstdruby/libzstd/legacy/zstd_v01.c +0 -2158
  51. data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
  52. data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3518
  53. data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
  54. data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3160
  55. data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
  56. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3647
  57. data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
  58. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4050
  59. data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
  60. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4154
  61. data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
  62. data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4541
  63. data/ext/zstdruby/libzstd/legacy/zstd_v07.h +0 -187
  64. data/ext/zstdruby/libzstd/libzstd.mk +0 -185
  65. data/ext/zstdruby/libzstd/libzstd.pc.in +0 -16
  66. data/ext/zstdruby/libzstd/modulemap/module.modulemap +0 -4
@@ -1,214 +0,0 @@
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
- /* ***************************************************************
12
- * NOTES/WARNINGS
13
- ******************************************************************/
14
- /* The streaming API defined here is deprecated.
15
- * Consider migrating towards ZSTD_compressStream() API in `zstd.h`
16
- * See 'lib/README.md'.
17
- *****************************************************************/
18
-
19
-
20
- #if defined (__cplusplus)
21
- extern "C" {
22
- #endif
23
-
24
- #ifndef ZSTD_BUFFERED_H_23987
25
- #define ZSTD_BUFFERED_H_23987
26
-
27
- /* *************************************
28
- * Dependencies
29
- ***************************************/
30
- #include <stddef.h> /* size_t */
31
- #include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
32
-
33
-
34
- /* ***************************************************************
35
- * Compiler specifics
36
- *****************************************************************/
37
- /* Deprecation warnings */
38
- /* Should these warnings be a problem,
39
- * it is generally possible to disable them,
40
- * typically with -Wno-deprecated-declarations for gcc
41
- * or _CRT_SECURE_NO_WARNINGS in Visual.
42
- * Otherwise, it's also possible to define ZBUFF_DISABLE_DEPRECATE_WARNINGS
43
- */
44
- #ifdef ZBUFF_DISABLE_DEPRECATE_WARNINGS
45
- # define ZBUFF_DEPRECATED(message) ZSTDLIB_API /* disable deprecation warnings */
46
- #else
47
- # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
48
- # define ZBUFF_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_API
49
- # elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
50
- # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
51
- # elif defined(__GNUC__) && (__GNUC__ >= 3)
52
- # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
53
- # elif defined(_MSC_VER)
54
- # define ZBUFF_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
55
- # else
56
- # pragma message("WARNING: You need to implement ZBUFF_DEPRECATED for this compiler")
57
- # define ZBUFF_DEPRECATED(message) ZSTDLIB_API
58
- # endif
59
- #endif /* ZBUFF_DISABLE_DEPRECATE_WARNINGS */
60
-
61
-
62
- /* *************************************
63
- * Streaming functions
64
- ***************************************/
65
- /* This is the easier "buffered" streaming API,
66
- * using an internal buffer to lift all restrictions on user-provided buffers
67
- * which can be any size, any place, for both input and output.
68
- * ZBUFF and ZSTD are 100% interoperable,
69
- * frames created by one can be decoded by the other one */
70
-
71
- typedef ZSTD_CStream ZBUFF_CCtx;
72
- ZBUFF_DEPRECATED("use ZSTD_createCStream") ZBUFF_CCtx* ZBUFF_createCCtx(void);
73
- ZBUFF_DEPRECATED("use ZSTD_freeCStream") size_t ZBUFF_freeCCtx(ZBUFF_CCtx* cctx);
74
-
75
- ZBUFF_DEPRECATED("use ZSTD_initCStream") size_t ZBUFF_compressInit(ZBUFF_CCtx* cctx, int compressionLevel);
76
- ZBUFF_DEPRECATED("use ZSTD_initCStream_usingDict") size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
77
-
78
- ZBUFF_DEPRECATED("use ZSTD_compressStream") size_t ZBUFF_compressContinue(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr, const void* src, size_t* srcSizePtr);
79
- ZBUFF_DEPRECATED("use ZSTD_flushStream") size_t ZBUFF_compressFlush(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
80
- ZBUFF_DEPRECATED("use ZSTD_endStream") size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
81
-
82
- /*-*************************************************
83
- * Streaming compression - howto
84
- *
85
- * A ZBUFF_CCtx object is required to track streaming operation.
86
- * Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
87
- * ZBUFF_CCtx objects can be reused multiple times.
88
- *
89
- * Start by initializing ZBUF_CCtx.
90
- * Use ZBUFF_compressInit() to start a new compression operation.
91
- * Use ZBUFF_compressInitDictionary() for a compression which requires a dictionary.
92
- *
93
- * Use ZBUFF_compressContinue() repetitively to consume input stream.
94
- * *srcSizePtr and *dstCapacityPtr can be any size.
95
- * The function will report how many bytes were read or written within *srcSizePtr and *dstCapacityPtr.
96
- * Note that it may not consume the entire input, in which case it's up to the caller to present again remaining data.
97
- * The content of `dst` will be overwritten (up to *dstCapacityPtr) at each call, so save its content if it matters or change @dst .
98
- * @return : a hint to preferred nb of bytes to use as input for next function call (it's just a hint, to improve latency)
99
- * or an error code, which can be tested using ZBUFF_isError().
100
- *
101
- * At any moment, it's possible to flush whatever data remains within buffer, using ZBUFF_compressFlush().
102
- * The nb of bytes written into `dst` will be reported into *dstCapacityPtr.
103
- * Note that the function cannot output more than *dstCapacityPtr,
104
- * therefore, some content might still be left into internal buffer if *dstCapacityPtr is too small.
105
- * @return : nb of bytes still present into internal buffer (0 if it's empty)
106
- * or an error code, which can be tested using ZBUFF_isError().
107
- *
108
- * ZBUFF_compressEnd() instructs to finish a frame.
109
- * It will perform a flush and write frame epilogue.
110
- * The epilogue is required for decoders to consider a frame completed.
111
- * Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
112
- * In which case, call again ZBUFF_compressFlush() to complete the flush.
113
- * @return : nb of bytes still present into internal buffer (0 if it's empty)
114
- * or an error code, which can be tested using ZBUFF_isError().
115
- *
116
- * Hint : _recommended buffer_ sizes (not compulsory) : ZBUFF_recommendedCInSize() / ZBUFF_recommendedCOutSize()
117
- * input : ZBUFF_recommendedCInSize==128 KB block size is the internal unit, use this value to reduce intermediate stages (better latency)
118
- * output : ZBUFF_recommendedCOutSize==ZSTD_compressBound(128 KB) + 3 + 3 : ensures it's always possible to write/flush/end a full block. Skip some buffering.
119
- * By using both, it ensures that input will be entirely consumed, and output will always contain the result, reducing intermediate buffering.
120
- * **************************************************/
121
-
122
-
123
- typedef ZSTD_DStream ZBUFF_DCtx;
124
- ZBUFF_DEPRECATED("use ZSTD_createDStream") ZBUFF_DCtx* ZBUFF_createDCtx(void);
125
- ZBUFF_DEPRECATED("use ZSTD_freeDStream") size_t ZBUFF_freeDCtx(ZBUFF_DCtx* dctx);
126
-
127
- ZBUFF_DEPRECATED("use ZSTD_initDStream") size_t ZBUFF_decompressInit(ZBUFF_DCtx* dctx);
128
- ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* dctx, const void* dict, size_t dictSize);
129
-
130
- ZBUFF_DEPRECATED("use ZSTD_decompressStream") size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
131
- void* dst, size_t* dstCapacityPtr,
132
- const void* src, size_t* srcSizePtr);
133
-
134
- /*-***************************************************************************
135
- * Streaming decompression howto
136
- *
137
- * A ZBUFF_DCtx object is required to track streaming operations.
138
- * Use ZBUFF_createDCtx() and ZBUFF_freeDCtx() to create/release resources.
139
- * Use ZBUFF_decompressInit() to start a new decompression operation,
140
- * or ZBUFF_decompressInitDictionary() if decompression requires a dictionary.
141
- * Note that ZBUFF_DCtx objects can be re-init multiple times.
142
- *
143
- * Use ZBUFF_decompressContinue() repetitively to consume your input.
144
- * *srcSizePtr and *dstCapacityPtr can be any size.
145
- * The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
146
- * Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
147
- * The content of `dst` will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters, or change `dst`.
148
- * @return : 0 when a frame is completely decoded and fully flushed,
149
- * 1 when there is still some data left within internal buffer to flush,
150
- * >1 when more data is expected, with value being a suggested next input size (it's just a hint, which helps latency),
151
- * or an error code, which can be tested using ZBUFF_isError().
152
- *
153
- * Hint : recommended buffer sizes (not compulsory) : ZBUFF_recommendedDInSize() and ZBUFF_recommendedDOutSize()
154
- * output : ZBUFF_recommendedDOutSize== 128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
155
- * input : ZBUFF_recommendedDInSize == 128KB + 3;
156
- * just follow indications from ZBUFF_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
157
- * *******************************************************************************/
158
-
159
-
160
- /* *************************************
161
- * Tool functions
162
- ***************************************/
163
- ZBUFF_DEPRECATED("use ZSTD_isError") unsigned ZBUFF_isError(size_t errorCode);
164
- ZBUFF_DEPRECATED("use ZSTD_getErrorName") const char* ZBUFF_getErrorName(size_t errorCode);
165
-
166
- /** Functions below provide recommended buffer sizes for Compression or Decompression operations.
167
- * These sizes are just hints, they tend to offer better latency */
168
- ZBUFF_DEPRECATED("use ZSTD_CStreamInSize") size_t ZBUFF_recommendedCInSize(void);
169
- ZBUFF_DEPRECATED("use ZSTD_CStreamOutSize") size_t ZBUFF_recommendedCOutSize(void);
170
- ZBUFF_DEPRECATED("use ZSTD_DStreamInSize") size_t ZBUFF_recommendedDInSize(void);
171
- ZBUFF_DEPRECATED("use ZSTD_DStreamOutSize") size_t ZBUFF_recommendedDOutSize(void);
172
-
173
- #endif /* ZSTD_BUFFERED_H_23987 */
174
-
175
-
176
- #ifdef ZBUFF_STATIC_LINKING_ONLY
177
- #ifndef ZBUFF_STATIC_H_30298098432
178
- #define ZBUFF_STATIC_H_30298098432
179
-
180
- /* ====================================================================================
181
- * The definitions in this section are considered experimental.
182
- * They should never be used in association with a dynamic library, as they may change in the future.
183
- * They are provided for advanced usages.
184
- * Use them only in association with static linking.
185
- * ==================================================================================== */
186
-
187
- /*--- Dependency ---*/
188
- #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_customMem */
189
- #include "../zstd.h"
190
-
191
-
192
- /*--- Custom memory allocator ---*/
193
- /*! ZBUFF_createCCtx_advanced() :
194
- * Create a ZBUFF compression context using external alloc and free functions */
195
- ZBUFF_DEPRECATED("use ZSTD_createCStream_advanced") ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
196
-
197
- /*! ZBUFF_createDCtx_advanced() :
198
- * Create a ZBUFF decompression context using external alloc and free functions */
199
- ZBUFF_DEPRECATED("use ZSTD_createDStream_advanced") ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
200
-
201
-
202
- /*--- Advanced Streaming Initialization ---*/
203
- ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
204
- const void* dict, size_t dictSize,
205
- ZSTD_parameters params, unsigned long long pledgedSrcSize);
206
-
207
-
208
- #endif /* ZBUFF_STATIC_H_30298098432 */
209
- #endif /* ZBUFF_STATIC_LINKING_ONLY */
210
-
211
-
212
- #if defined (__cplusplus)
213
- }
214
- #endif
@@ -1,26 +0,0 @@
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
- /*-*************************************
12
- * Dependencies
13
- ***************************************/
14
- #include "../common/error_private.h"
15
- #include "zbuff.h"
16
-
17
- /*-****************************************
18
- * ZBUFF Error Management (deprecated)
19
- ******************************************/
20
-
21
- /*! ZBUFF_isError() :
22
- * tells if a return value is an error code */
23
- unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
24
- /*! ZBUFF_getErrorName() :
25
- * provides error code string from function result (useful for debugging) */
26
- const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
@@ -1,167 +0,0 @@
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
-
12
-
13
- /* *************************************
14
- * Dependencies
15
- ***************************************/
16
- #define ZBUFF_STATIC_LINKING_ONLY
17
- #include "zbuff.h"
18
- #include "../common/error_private.h"
19
-
20
-
21
- /*-***********************************************************
22
- * Streaming compression
23
- *
24
- * A ZBUFF_CCtx object is required to track streaming operation.
25
- * Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
26
- * Use ZBUFF_compressInit() to start a new compression operation.
27
- * ZBUFF_CCtx objects can be reused multiple times.
28
- *
29
- * Use ZBUFF_compressContinue() repetitively to consume your input.
30
- * *srcSizePtr and *dstCapacityPtr can be any size.
31
- * The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
32
- * Note that it may not consume the entire input, in which case it's up to the caller to call again the function with remaining input.
33
- * The content of dst will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters or change dst .
34
- * @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to improve latency)
35
- * or an error code, which can be tested using ZBUFF_isError().
36
- *
37
- * ZBUFF_compressFlush() can be used to instruct ZBUFF to compress and output whatever remains within its buffer.
38
- * Note that it will not output more than *dstCapacityPtr.
39
- * Therefore, some content might still be left into its internal buffer if dst buffer is too small.
40
- * @return : nb of bytes still present into internal buffer (0 if it's empty)
41
- * or an error code, which can be tested using ZBUFF_isError().
42
- *
43
- * ZBUFF_compressEnd() instructs to finish a frame.
44
- * It will perform a flush and write frame epilogue.
45
- * Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
46
- * @return : nb of bytes still present into internal buffer (0 if it's empty)
47
- * or an error code, which can be tested using ZBUFF_isError().
48
- *
49
- * Hint : recommended buffer sizes (not compulsory)
50
- * input : ZSTD_BLOCKSIZE_MAX (128 KB), internal unit size, it improves latency to use this value.
51
- * output : ZSTD_compressBound(ZSTD_BLOCKSIZE_MAX) + ZSTD_blockHeaderSize + ZBUFF_endFrameSize : ensures it's always possible to write/flush/end a full block at best speed.
52
- * ***********************************************************/
53
-
54
- ZBUFF_CCtx* ZBUFF_createCCtx(void)
55
- {
56
- return ZSTD_createCStream();
57
- }
58
-
59
- ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
60
- {
61
- return ZSTD_createCStream_advanced(customMem);
62
- }
63
-
64
- size_t ZBUFF_freeCCtx(ZBUFF_CCtx* zbc)
65
- {
66
- return ZSTD_freeCStream(zbc);
67
- }
68
-
69
-
70
- /* ====== Initialization ====== */
71
-
72
- size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
73
- const void* dict, size_t dictSize,
74
- ZSTD_parameters params, unsigned long long pledgedSrcSize)
75
- {
76
- if (pledgedSrcSize==0) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN; /* preserve "0 == unknown" behavior */
77
- FORWARD_IF_ERROR(ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only), "");
78
- FORWARD_IF_ERROR(ZSTD_CCtx_setPledgedSrcSize(zbc, pledgedSrcSize), "");
79
-
80
- FORWARD_IF_ERROR(ZSTD_checkCParams(params.cParams), "");
81
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_windowLog, params.cParams.windowLog), "");
82
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_hashLog, params.cParams.hashLog), "");
83
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_chainLog, params.cParams.chainLog), "");
84
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_searchLog, params.cParams.searchLog), "");
85
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_minMatch, params.cParams.minMatch), "");
86
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_targetLength, params.cParams.targetLength), "");
87
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_strategy, params.cParams.strategy), "");
88
-
89
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_contentSizeFlag, params.fParams.contentSizeFlag), "");
90
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_checksumFlag, params.fParams.checksumFlag), "");
91
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_dictIDFlag, params.fParams.noDictIDFlag), "");
92
-
93
- FORWARD_IF_ERROR(ZSTD_CCtx_loadDictionary(zbc, dict, dictSize), "");
94
- return 0;
95
- }
96
-
97
- size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* zbc, const void* dict, size_t dictSize, int compressionLevel)
98
- {
99
- FORWARD_IF_ERROR(ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only), "");
100
- FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_compressionLevel, compressionLevel), "");
101
- FORWARD_IF_ERROR(ZSTD_CCtx_loadDictionary(zbc, dict, dictSize), "");
102
- return 0;
103
- }
104
-
105
- size_t ZBUFF_compressInit(ZBUFF_CCtx* zbc, int compressionLevel)
106
- {
107
- return ZSTD_initCStream(zbc, compressionLevel);
108
- }
109
-
110
- /* ====== Compression ====== */
111
-
112
-
113
- size_t ZBUFF_compressContinue(ZBUFF_CCtx* zbc,
114
- void* dst, size_t* dstCapacityPtr,
115
- const void* src, size_t* srcSizePtr)
116
- {
117
- size_t result;
118
- ZSTD_outBuffer outBuff;
119
- ZSTD_inBuffer inBuff;
120
- outBuff.dst = dst;
121
- outBuff.pos = 0;
122
- outBuff.size = *dstCapacityPtr;
123
- inBuff.src = src;
124
- inBuff.pos = 0;
125
- inBuff.size = *srcSizePtr;
126
- result = ZSTD_compressStream(zbc, &outBuff, &inBuff);
127
- *dstCapacityPtr = outBuff.pos;
128
- *srcSizePtr = inBuff.pos;
129
- return result;
130
- }
131
-
132
-
133
-
134
- /* ====== Finalize ====== */
135
-
136
- size_t ZBUFF_compressFlush(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
137
- {
138
- size_t result;
139
- ZSTD_outBuffer outBuff;
140
- outBuff.dst = dst;
141
- outBuff.pos = 0;
142
- outBuff.size = *dstCapacityPtr;
143
- result = ZSTD_flushStream(zbc, &outBuff);
144
- *dstCapacityPtr = outBuff.pos;
145
- return result;
146
- }
147
-
148
-
149
- size_t ZBUFF_compressEnd(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
150
- {
151
- size_t result;
152
- ZSTD_outBuffer outBuff;
153
- outBuff.dst = dst;
154
- outBuff.pos = 0;
155
- outBuff.size = *dstCapacityPtr;
156
- result = ZSTD_endStream(zbc, &outBuff);
157
- *dstCapacityPtr = outBuff.pos;
158
- return result;
159
- }
160
-
161
-
162
-
163
- /* *************************************
164
- * Tool functions
165
- ***************************************/
166
- size_t ZBUFF_recommendedCInSize(void) { return ZSTD_CStreamInSize(); }
167
- size_t ZBUFF_recommendedCOutSize(void) { return ZSTD_CStreamOutSize(); }
@@ -1,75 +0,0 @@
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
-
12
-
13
- /* *************************************
14
- * Dependencies
15
- ***************************************/
16
- #define ZBUFF_STATIC_LINKING_ONLY
17
- #include "zbuff.h"
18
-
19
-
20
- ZBUFF_DCtx* ZBUFF_createDCtx(void)
21
- {
22
- return ZSTD_createDStream();
23
- }
24
-
25
- ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
26
- {
27
- return ZSTD_createDStream_advanced(customMem);
28
- }
29
-
30
- size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
31
- {
32
- return ZSTD_freeDStream(zbd);
33
- }
34
-
35
-
36
- /* *** Initialization *** */
37
-
38
- size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
39
- {
40
- return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
41
- }
42
-
43
- size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
44
- {
45
- return ZSTD_initDStream(zbd);
46
- }
47
-
48
-
49
- /* *** Decompression *** */
50
-
51
- size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
52
- void* dst, size_t* dstCapacityPtr,
53
- const void* src, size_t* srcSizePtr)
54
- {
55
- ZSTD_outBuffer outBuff;
56
- ZSTD_inBuffer inBuff;
57
- size_t result;
58
- outBuff.dst = dst;
59
- outBuff.pos = 0;
60
- outBuff.size = *dstCapacityPtr;
61
- inBuff.src = src;
62
- inBuff.pos = 0;
63
- inBuff.size = *srcSizePtr;
64
- result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);
65
- *dstCapacityPtr = outBuff.pos;
66
- *srcSizePtr = inBuff.pos;
67
- return result;
68
- }
69
-
70
-
71
- /* *************************************
72
- * Tool functions
73
- ***************************************/
74
- size_t ZBUFF_recommendedDInSize(void) { return ZSTD_DStreamInSize(); }
75
- size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }
@@ -1,48 +0,0 @@
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
- VOID := /dev/null
12
- ZSTDDIR := ../include
13
- LIBDIR := ../static
14
- DLLDIR := ../dll
15
-
16
- CFLAGS ?= -O3 # can select custom flags. For example : CFLAGS="-O2 -g" make
17
- CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \
18
- -Wdeclaration-after-statement -Wstrict-prototypes \
19
- -Wpointer-arith -Wstrict-aliasing=1
20
- CFLAGS += $(MOREFLAGS)
21
- CPPFLAGS:= -I$(ZSTDDIR) -DXXH_NAMESPACE=ZSTD_
22
- FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
23
-
24
-
25
- # Define *.exe as extension for Windows systems
26
- ifneq (,$(filter Windows%,$(OS)))
27
- EXT =.exe
28
- else
29
- EXT =
30
- endif
31
-
32
- .PHONY: default fullbench-dll fullbench-lib
33
-
34
-
35
- default: all
36
-
37
- all: fullbench-dll fullbench-lib
38
-
39
-
40
- fullbench-lib: fullbench.c datagen.c
41
- $(CC) $(FLAGS) $^ -o $@$(EXT) $(LIBDIR)/libzstd_static.lib
42
-
43
- fullbench-dll: fullbench.c datagen.c
44
- $(CC) $(FLAGS) $^ -o $@$(EXT) -DZSTD_DLL_IMPORT=1 $(DLLDIR)/libzstd.dll
45
-
46
- clean:
47
- @$(RM) fullbench-dll$(EXT) fullbench-lib$(EXT) \
48
- @echo Cleaning completed
@@ -1,63 +0,0 @@
1
- # ZSTD Windows binary package
2
-
3
- ## The package contents
4
-
5
- - `zstd.exe` : Command Line Utility, supporting gzip-like arguments
6
- - `dll\libzstd.dll` : The ZSTD dynamic library (DLL)
7
- - `dll\libzstd.lib` : The import library of the ZSTD dynamic library (DLL) for Visual C++
8
- - `example\` : The example of usage of the ZSTD library
9
- - `include\` : Header files required by the ZSTD library
10
- - `static\libzstd_static.lib` : The static ZSTD library (LIB)
11
-
12
- ## Usage of Command Line Interface
13
-
14
- Command Line Interface (CLI) supports gzip-like arguments.
15
- By default CLI takes an input file and compresses it to an output file:
16
-
17
- Usage: zstd [arg] [input] [output]
18
-
19
- The full list of commands for CLI can be obtained with `-h` or `-H`. The ratio can
20
- be improved with commands from `-3` to `-16` but higher levels also have slower
21
- compression. CLI includes in-memory compression benchmark module with compression
22
- levels starting from `-b` and ending with `-e` with iteration time of `-i` seconds.
23
- CLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined
24
- into `-b1e18i1`.
25
-
26
- ## The example of usage of static and dynamic ZSTD libraries with gcc/MinGW
27
-
28
- Use `cd example` and `make` to build `fullbench-dll` and `fullbench-lib`.
29
- `fullbench-dll` uses a dynamic ZSTD library from the `dll` directory.
30
- `fullbench-lib` uses a static ZSTD library from the `lib` directory.
31
-
32
- ## Using ZSTD DLL with gcc/MinGW
33
-
34
- The header files from `include\` and the dynamic library `dll\libzstd.dll`
35
- are required to compile a project using gcc/MinGW.
36
- The dynamic library has to be added to linking options.
37
- It means that if a project that uses ZSTD consists of a single `test-dll.c`
38
- file it should be linked with `dll\libzstd.dll`. For example:
39
-
40
- gcc $(CFLAGS) -Iinclude\ test-dll.c -o test-dll dll\libzstd.dll
41
-
42
- The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
43
-
44
- ## The example of usage of static and dynamic ZSTD libraries with Visual C++
45
-
46
- Open `example\fullbench-dll.sln` to compile `fullbench-dll` that uses a
47
- dynamic ZSTD library from the `dll` directory. The solution works with Visual C++
48
- 2010 or newer. When one will open the solution with Visual C++ newer than 2010
49
- then the solution will upgraded to the current version.
50
-
51
- ## Using ZSTD DLL with Visual C++
52
-
53
- The header files from `include\` and the import library `dll\libzstd.lib`
54
- are required to compile a project using Visual C++.
55
-
56
- 1. The path to header files should be added to `Additional Include Directories` that can
57
- be found in project properties `C/C++` then `General`.
58
- 2. The import library has to be added to `Additional Dependencies` that can
59
- be found in project properties `Linker` then `Input`.
60
- If one will provide only the name `libzstd.lib` without a full path to the library
61
- the directory has to be added to `Linker\General\Additional Library Directories`.
62
-
63
- The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
@@ -1,20 +0,0 @@
1
- @ECHO OFF
2
- MKDIR bin\dll bin\static bin\example bin\include
3
- COPY tests\fullbench.c bin\example\
4
- COPY programs\datagen.c bin\example\
5
- COPY programs\datagen.h bin\example\
6
- COPY programs\util.h bin\example\
7
- COPY programs\platform.h bin\example\
8
- COPY lib\common\mem.h bin\example\
9
- COPY lib\common\zstd_internal.h bin\example\
10
- COPY lib\common\error_private.h bin\example\
11
- COPY lib\common\xxhash.h bin\example\
12
- COPY lib\libzstd.a bin\static\libzstd_static.lib
13
- COPY lib\dll\libzstd.* bin\dll\
14
- COPY lib\dll\example\Makefile bin\example\
15
- COPY lib\dll\example\fullbench-dll.* bin\example\
16
- COPY lib\dll\example\README.md bin\
17
- COPY lib\zstd.h bin\include\
18
- COPY lib\common\zstd_errors.h bin\include\
19
- COPY lib\dictBuilder\zdict.h bin\include\
20
- COPY programs\zstd.exe bin\zstd.exe
@@ -1,25 +0,0 @@
1
- Microsoft Visual Studio Solution File, Format Version 12.00
2
- # Visual Studio Express 2012 for Windows Desktop
3
- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll.vcxproj", "{13992FD2-077E-4954-B065-A428198201A9}"
4
- EndProject
5
- Global
6
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
7
- Debug|Win32 = Debug|Win32
8
- Debug|x64 = Debug|x64
9
- Release|Win32 = Release|Win32
10
- Release|x64 = Release|x64
11
- EndGlobalSection
12
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
13
- {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.ActiveCfg = Debug|Win32
14
- {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.Build.0 = Debug|Win32
15
- {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.ActiveCfg = Debug|x64
16
- {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.Build.0 = Debug|x64
17
- {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.ActiveCfg = Release|Win32
18
- {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.Build.0 = Release|Win32
19
- {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.ActiveCfg = Release|x64
20
- {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.Build.0 = Release|x64
21
- EndGlobalSection
22
- GlobalSection(SolutionProperties) = preSolution
23
- HideSolutionNode = FALSE
24
- EndGlobalSection
25
- EndGlobal