zstd-ruby 1.4.5.0 → 1.5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +78 -5
- data/Rakefile +8 -2
- data/ext/zstdruby/common.h +15 -0
- data/ext/zstdruby/extconf.rb +3 -2
- data/ext/zstdruby/libzstd/common/allocations.h +55 -0
- data/ext/zstdruby/libzstd/common/bits.h +200 -0
- data/ext/zstdruby/libzstd/common/bitstream.h +45 -62
- data/ext/zstdruby/libzstd/common/compiler.h +205 -22
- data/ext/zstdruby/libzstd/common/cpu.h +1 -3
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +12 -19
- data/ext/zstdruby/libzstd/common/entropy_common.c +172 -48
- data/ext/zstdruby/libzstd/common/error_private.c +10 -2
- data/ext/zstdruby/libzstd/common/error_private.h +82 -3
- data/ext/zstdruby/libzstd/common/fse.h +37 -86
- data/ext/zstdruby/libzstd/common/fse_decompress.c +117 -92
- data/ext/zstdruby/libzstd/common/huf.h +99 -166
- data/ext/zstdruby/libzstd/common/mem.h +124 -142
- data/ext/zstdruby/libzstd/common/pool.c +54 -27
- data/ext/zstdruby/libzstd/common/pool.h +10 -4
- data/ext/zstdruby/libzstd/common/portability_macros.h +156 -0
- data/ext/zstdruby/libzstd/common/threading.c +74 -19
- data/ext/zstdruby/libzstd/common/threading.h +5 -10
- data/ext/zstdruby/libzstd/common/xxhash.c +7 -847
- data/ext/zstdruby/libzstd/common/xxhash.h +5568 -167
- data/ext/zstdruby/libzstd/common/zstd_common.c +2 -37
- data/ext/zstdruby/libzstd/common/zstd_deps.h +111 -0
- data/ext/zstdruby/libzstd/common/zstd_internal.h +132 -187
- data/ext/zstdruby/libzstd/common/zstd_trace.h +163 -0
- data/ext/zstdruby/libzstd/compress/clevels.h +134 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +83 -157
- data/ext/zstdruby/libzstd/compress/hist.c +27 -29
- data/ext/zstdruby/libzstd/compress/hist.h +2 -2
- data/ext/zstdruby/libzstd/compress/huf_compress.c +916 -279
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +3773 -1019
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +610 -203
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +119 -42
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +16 -6
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +42 -19
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +49 -317
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +320 -103
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +388 -151
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +729 -265
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +1270 -251
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +61 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +324 -219
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +9 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +481 -209
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +181 -457
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +34 -113
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +1199 -565
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +576 -0
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +12 -12
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +627 -157
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +1086 -326
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +19 -5
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +62 -13
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +73 -52
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +7 -6
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +44 -35
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +103 -111
- data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +203 -34
- data/ext/zstdruby/libzstd/zstd.h +1217 -287
- data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +28 -8
- data/ext/zstdruby/main.c +20 -0
- data/ext/zstdruby/skippable_frame.c +63 -0
- data/ext/zstdruby/streaming_compress.c +177 -0
- data/ext/zstdruby/streaming_compress.h +5 -0
- data/ext/zstdruby/streaming_decompress.c +123 -0
- data/ext/zstdruby/zstdruby.c +114 -32
- data/lib/zstd-ruby/version.rb +1 -1
- data/lib/zstd-ruby.rb +0 -1
- data/zstd-ruby.gemspec +1 -1
- metadata +19 -36
- data/.travis.yml +0 -14
- data/ext/zstdruby/libzstd/.gitignore +0 -3
- data/ext/zstdruby/libzstd/BUCK +0 -234
- data/ext/zstdruby/libzstd/Makefile +0 -354
- data/ext/zstdruby/libzstd/README.md +0 -179
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +0 -214
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +0 -26
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +0 -147
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +0 -75
- data/ext/zstdruby/libzstd/dll/example/Makefile +0 -48
- data/ext/zstdruby/libzstd/dll/example/README.md +0 -69
- data/ext/zstdruby/libzstd/dll/example/build_package.bat +0 -20
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +0 -25
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +0 -181
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +0 -415
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +0 -2158
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3518
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3160
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3647
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4050
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4154
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4541
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +0 -187
- data/ext/zstdruby/libzstd/libzstd.pc.in +0 -15
- data/ext/zstdruby/zstdruby.h +0 -6
@@ -1,214 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 2016-2020, 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) 2016-2020, 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,147 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 2016-2020, 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
|
-
/*-***********************************************************
|
21
|
-
* Streaming compression
|
22
|
-
*
|
23
|
-
* A ZBUFF_CCtx object is required to track streaming operation.
|
24
|
-
* Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
|
25
|
-
* Use ZBUFF_compressInit() to start a new compression operation.
|
26
|
-
* ZBUFF_CCtx objects can be reused multiple times.
|
27
|
-
*
|
28
|
-
* Use ZBUFF_compressContinue() repetitively to consume your input.
|
29
|
-
* *srcSizePtr and *dstCapacityPtr can be any size.
|
30
|
-
* The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
|
31
|
-
* 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.
|
32
|
-
* The content of dst will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters or change dst .
|
33
|
-
* @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to improve latency)
|
34
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
35
|
-
*
|
36
|
-
* ZBUFF_compressFlush() can be used to instruct ZBUFF to compress and output whatever remains within its buffer.
|
37
|
-
* Note that it will not output more than *dstCapacityPtr.
|
38
|
-
* Therefore, some content might still be left into its internal buffer if dst buffer is too small.
|
39
|
-
* @return : nb of bytes still present into internal buffer (0 if it's empty)
|
40
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
41
|
-
*
|
42
|
-
* ZBUFF_compressEnd() instructs to finish a frame.
|
43
|
-
* It will perform a flush and write frame epilogue.
|
44
|
-
* Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
|
45
|
-
* @return : nb of bytes still present into internal buffer (0 if it's empty)
|
46
|
-
* or an error code, which can be tested using ZBUFF_isError().
|
47
|
-
*
|
48
|
-
* Hint : recommended buffer sizes (not compulsory)
|
49
|
-
* input : ZSTD_BLOCKSIZE_MAX (128 KB), internal unit size, it improves latency to use this value.
|
50
|
-
* 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.
|
51
|
-
* ***********************************************************/
|
52
|
-
|
53
|
-
ZBUFF_CCtx* ZBUFF_createCCtx(void)
|
54
|
-
{
|
55
|
-
return ZSTD_createCStream();
|
56
|
-
}
|
57
|
-
|
58
|
-
ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
|
59
|
-
{
|
60
|
-
return ZSTD_createCStream_advanced(customMem);
|
61
|
-
}
|
62
|
-
|
63
|
-
size_t ZBUFF_freeCCtx(ZBUFF_CCtx* zbc)
|
64
|
-
{
|
65
|
-
return ZSTD_freeCStream(zbc);
|
66
|
-
}
|
67
|
-
|
68
|
-
|
69
|
-
/* ====== Initialization ====== */
|
70
|
-
|
71
|
-
size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
|
72
|
-
const void* dict, size_t dictSize,
|
73
|
-
ZSTD_parameters params, unsigned long long pledgedSrcSize)
|
74
|
-
{
|
75
|
-
if (pledgedSrcSize==0) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN; /* preserve "0 == unknown" behavior */
|
76
|
-
return ZSTD_initCStream_advanced(zbc, dict, dictSize, params, pledgedSrcSize);
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* zbc, const void* dict, size_t dictSize, int compressionLevel)
|
81
|
-
{
|
82
|
-
return ZSTD_initCStream_usingDict(zbc, dict, dictSize, compressionLevel);
|
83
|
-
}
|
84
|
-
|
85
|
-
size_t ZBUFF_compressInit(ZBUFF_CCtx* zbc, int compressionLevel)
|
86
|
-
{
|
87
|
-
return ZSTD_initCStream(zbc, compressionLevel);
|
88
|
-
}
|
89
|
-
|
90
|
-
/* ====== Compression ====== */
|
91
|
-
|
92
|
-
|
93
|
-
size_t ZBUFF_compressContinue(ZBUFF_CCtx* zbc,
|
94
|
-
void* dst, size_t* dstCapacityPtr,
|
95
|
-
const void* src, size_t* srcSizePtr)
|
96
|
-
{
|
97
|
-
size_t result;
|
98
|
-
ZSTD_outBuffer outBuff;
|
99
|
-
ZSTD_inBuffer inBuff;
|
100
|
-
outBuff.dst = dst;
|
101
|
-
outBuff.pos = 0;
|
102
|
-
outBuff.size = *dstCapacityPtr;
|
103
|
-
inBuff.src = src;
|
104
|
-
inBuff.pos = 0;
|
105
|
-
inBuff.size = *srcSizePtr;
|
106
|
-
result = ZSTD_compressStream(zbc, &outBuff, &inBuff);
|
107
|
-
*dstCapacityPtr = outBuff.pos;
|
108
|
-
*srcSizePtr = inBuff.pos;
|
109
|
-
return result;
|
110
|
-
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
/* ====== Finalize ====== */
|
115
|
-
|
116
|
-
size_t ZBUFF_compressFlush(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
|
117
|
-
{
|
118
|
-
size_t result;
|
119
|
-
ZSTD_outBuffer outBuff;
|
120
|
-
outBuff.dst = dst;
|
121
|
-
outBuff.pos = 0;
|
122
|
-
outBuff.size = *dstCapacityPtr;
|
123
|
-
result = ZSTD_flushStream(zbc, &outBuff);
|
124
|
-
*dstCapacityPtr = outBuff.pos;
|
125
|
-
return result;
|
126
|
-
}
|
127
|
-
|
128
|
-
|
129
|
-
size_t ZBUFF_compressEnd(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
|
130
|
-
{
|
131
|
-
size_t result;
|
132
|
-
ZSTD_outBuffer outBuff;
|
133
|
-
outBuff.dst = dst;
|
134
|
-
outBuff.pos = 0;
|
135
|
-
outBuff.size = *dstCapacityPtr;
|
136
|
-
result = ZSTD_endStream(zbc, &outBuff);
|
137
|
-
*dstCapacityPtr = outBuff.pos;
|
138
|
-
return result;
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
/* *************************************
|
144
|
-
* Tool functions
|
145
|
-
***************************************/
|
146
|
-
size_t ZBUFF_recommendedCInSize(void) { return ZSTD_CStreamInSize(); }
|
147
|
-
size_t ZBUFF_recommendedCOutSize(void) { return ZSTD_CStreamOutSize(); }
|
@@ -1,75 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (c) 2016-2020, 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) 2016-2020, 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,69 +0,0 @@
|
|
1
|
-
ZSTD Windows binary package
|
2
|
-
====================================
|
3
|
-
|
4
|
-
#### The package contents
|
5
|
-
|
6
|
-
- `zstd.exe` : Command Line Utility, supporting gzip-like arguments
|
7
|
-
- `dll\libzstd.dll` : The ZSTD dynamic library (DLL)
|
8
|
-
- `dll\libzstd.lib` : The import library of the ZSTD dynamic library (DLL) for Visual C++
|
9
|
-
- `example\` : The example of usage of the ZSTD library
|
10
|
-
- `include\` : Header files required by the ZSTD library
|
11
|
-
- `static\libzstd_static.lib` : The static ZSTD library (LIB)
|
12
|
-
|
13
|
-
|
14
|
-
#### Usage of Command Line Interface
|
15
|
-
|
16
|
-
Command Line Interface (CLI) supports gzip-like arguments.
|
17
|
-
By default CLI takes an input file and compresses it to an output file:
|
18
|
-
```
|
19
|
-
Usage: zstd [arg] [input] [output]
|
20
|
-
```
|
21
|
-
The full list of commands for CLI can be obtained with `-h` or `-H`. The ratio can
|
22
|
-
be improved with commands from `-3` to `-16` but higher levels also have slower
|
23
|
-
compression. CLI includes in-memory compression benchmark module with compression
|
24
|
-
levels starting from `-b` and ending with `-e` with iteration time of `-i` seconds.
|
25
|
-
CLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined
|
26
|
-
into `-b1e18i1`.
|
27
|
-
|
28
|
-
|
29
|
-
#### The example of usage of static and dynamic ZSTD libraries with gcc/MinGW
|
30
|
-
|
31
|
-
Use `cd example` and `make` to build `fullbench-dll` and `fullbench-lib`.
|
32
|
-
`fullbench-dll` uses a dynamic ZSTD library from the `dll` directory.
|
33
|
-
`fullbench-lib` uses a static ZSTD library from the `lib` directory.
|
34
|
-
|
35
|
-
|
36
|
-
#### Using ZSTD DLL with gcc/MinGW
|
37
|
-
|
38
|
-
The header files from `include\` and the dynamic library `dll\libzstd.dll`
|
39
|
-
are required to compile a project using gcc/MinGW.
|
40
|
-
The dynamic library has to be added to linking options.
|
41
|
-
It means that if a project that uses ZSTD consists of a single `test-dll.c`
|
42
|
-
file it should be linked with `dll\libzstd.dll`. For example:
|
43
|
-
```
|
44
|
-
gcc $(CFLAGS) -Iinclude\ test-dll.c -o test-dll dll\libzstd.dll
|
45
|
-
```
|
46
|
-
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
47
|
-
|
48
|
-
|
49
|
-
#### The example of usage of static and dynamic ZSTD libraries with Visual C++
|
50
|
-
|
51
|
-
Open `example\fullbench-dll.sln` to compile `fullbench-dll` that uses a
|
52
|
-
dynamic ZSTD library from the `dll` directory. The solution works with Visual C++
|
53
|
-
2010 or newer. When one will open the solution with Visual C++ newer than 2010
|
54
|
-
then the solution will upgraded to the current version.
|
55
|
-
|
56
|
-
|
57
|
-
#### Using ZSTD DLL with Visual C++
|
58
|
-
|
59
|
-
The header files from `include\` and the import library `dll\libzstd.lib`
|
60
|
-
are required to compile a project using Visual C++.
|
61
|
-
|
62
|
-
1. The path to header files should be added to `Additional Include Directories` that can
|
63
|
-
be found in project properties `C/C++` then `General`.
|
64
|
-
2. The import library has to be added to `Additional Dependencies` that can
|
65
|
-
be found in project properties `Linker` then `Input`.
|
66
|
-
If one will provide only the name `libzstd.lib` without a full path to the library
|
67
|
-
the directory has to be added to `Linker\General\Additional Library Directories`.
|
68
|
-
|
69
|
-
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
|