extzstd 0.3.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/contrib/zstd/CHANGELOG +39 -2
- data/contrib/zstd/CONTRIBUTING.md +3 -3
- data/contrib/zstd/Makefile +34 -20
- data/contrib/zstd/README.md +6 -2
- data/contrib/zstd/SECURITY.md +15 -0
- data/contrib/zstd/lib/Makefile +40 -28
- data/contrib/zstd/lib/README.md +14 -1
- data/contrib/zstd/lib/common/allocations.h +1 -1
- data/contrib/zstd/lib/common/bitstream.h +49 -29
- data/contrib/zstd/lib/common/compiler.h +114 -22
- data/contrib/zstd/lib/common/cpu.h +36 -0
- data/contrib/zstd/lib/common/debug.c +6 -0
- data/contrib/zstd/lib/common/debug.h +20 -11
- data/contrib/zstd/lib/common/error_private.h +45 -36
- data/contrib/zstd/lib/common/fse.h +3 -2
- data/contrib/zstd/lib/common/fse_decompress.c +19 -17
- data/contrib/zstd/lib/common/huf.h +14 -1
- data/contrib/zstd/lib/common/mem.h +0 -9
- data/contrib/zstd/lib/common/pool.c +1 -1
- data/contrib/zstd/lib/common/pool.h +1 -1
- data/contrib/zstd/lib/common/portability_macros.h +2 -0
- data/contrib/zstd/lib/common/threading.c +8 -2
- data/contrib/zstd/lib/common/xxhash.c +5 -11
- data/contrib/zstd/lib/common/xxhash.h +2341 -1007
- data/contrib/zstd/lib/common/zstd_internal.h +5 -5
- data/contrib/zstd/lib/compress/fse_compress.c +8 -7
- data/contrib/zstd/lib/compress/huf_compress.c +54 -25
- data/contrib/zstd/lib/compress/zstd_compress.c +282 -161
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +29 -27
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +224 -113
- data/contrib/zstd/lib/compress/zstd_cwksp.h +19 -13
- data/contrib/zstd/lib/compress/zstd_double_fast.c +17 -5
- data/contrib/zstd/lib/compress/zstd_double_fast.h +11 -0
- data/contrib/zstd/lib/compress/zstd_fast.c +14 -6
- data/contrib/zstd/lib/compress/zstd_lazy.c +129 -87
- data/contrib/zstd/lib/compress/zstd_lazy.h +103 -28
- data/contrib/zstd/lib/compress/zstd_ldm.c +8 -2
- data/contrib/zstd/lib/compress/zstd_opt.c +216 -112
- data/contrib/zstd/lib/compress/zstd_opt.h +31 -7
- data/contrib/zstd/lib/compress/zstdmt_compress.c +94 -79
- data/contrib/zstd/lib/decompress/huf_decompress.c +188 -126
- data/contrib/zstd/lib/decompress/huf_decompress_amd64.S +38 -19
- data/contrib/zstd/lib/decompress/zstd_decompress.c +84 -32
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +231 -208
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +1 -1
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +2 -0
- data/contrib/zstd/lib/dictBuilder/cover.c +16 -12
- data/contrib/zstd/lib/dictBuilder/cover.h +2 -8
- data/contrib/zstd/lib/dictBuilder/fastcover.c +2 -2
- data/contrib/zstd/lib/dictBuilder/zdict.c +12 -6
- data/contrib/zstd/lib/legacy/zstd_legacy.h +30 -0
- data/contrib/zstd/lib/legacy/zstd_v01.c +2 -0
- data/contrib/zstd/lib/legacy/zstd_v02.c +4 -16
- data/contrib/zstd/lib/legacy/zstd_v03.c +4 -16
- data/contrib/zstd/lib/legacy/zstd_v04.c +4 -11
- data/contrib/zstd/lib/legacy/zstd_v05.c +1 -0
- data/contrib/zstd/lib/legacy/zstd_v06.c +2 -9
- data/contrib/zstd/lib/legacy/zstd_v07.c +2 -10
- data/contrib/zstd/lib/libzstd.mk +34 -11
- data/contrib/zstd/lib/zstd.h +129 -60
- data/ext/extconf.rb +19 -1
- data/ext/extzstd.c +38 -14
- data/ext/extzstd.h +33 -6
- data/ext/extzstd_stream.c +74 -31
- metadata +4 -5
- data/contrib/zstd/appveyor.yml +0 -205
- data/ext/depend +0 -2
@@ -47,7 +47,7 @@ typedef enum {
|
|
47
47
|
*/
|
48
48
|
size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
|
49
49
|
void* dst, size_t dstCapacity,
|
50
|
-
const void* src, size_t srcSize, const
|
50
|
+
const void* src, size_t srcSize, const streaming_operation streaming);
|
51
51
|
|
52
52
|
/* ZSTD_buildFSETable() :
|
53
53
|
* generate FSE decoding table for one symbol (ll, ml or off)
|
@@ -153,6 +153,7 @@ struct ZSTD_DCtx_s
|
|
153
153
|
size_t litSize;
|
154
154
|
size_t rleSize;
|
155
155
|
size_t staticSize;
|
156
|
+
int isFrameDecompression;
|
156
157
|
#if DYNAMIC_BMI2 != 0
|
157
158
|
int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
|
158
159
|
#endif
|
@@ -166,6 +167,7 @@ struct ZSTD_DCtx_s
|
|
166
167
|
ZSTD_DDictHashSet* ddictSet; /* Hash set for multiple ddicts */
|
167
168
|
ZSTD_refMultipleDDicts_e refMultipleDDicts; /* User specified: if == 1, will allow references to multiple DDicts. Default == 0 (disabled) */
|
168
169
|
int disableHufAsm;
|
170
|
+
int maxBlockSizeParam;
|
169
171
|
|
170
172
|
/* streaming */
|
171
173
|
ZSTD_dStreamStage streamStage;
|
@@ -31,8 +31,8 @@
|
|
31
31
|
#endif
|
32
32
|
|
33
33
|
#include "../common/mem.h" /* read */
|
34
|
-
#include "../common/pool.h"
|
35
|
-
#include "../common/threading.h"
|
34
|
+
#include "../common/pool.h" /* POOL_ctx */
|
35
|
+
#include "../common/threading.h" /* ZSTD_pthread_mutex_t */
|
36
36
|
#include "../common/zstd_internal.h" /* includes zstd.h */
|
37
37
|
#include "../common/bits.h" /* ZSTD_highbit32 */
|
38
38
|
#include "../zdict.h"
|
@@ -78,7 +78,7 @@ static clock_t g_time = 0;
|
|
78
78
|
#undef LOCALDISPLAYUPDATE
|
79
79
|
#define LOCALDISPLAYUPDATE(displayLevel, l, ...) \
|
80
80
|
if (displayLevel >= l) { \
|
81
|
-
if ((clock() - g_time > g_refreshRate) || (displayLevel >= 4)) {
|
81
|
+
if ((clock() - g_time > g_refreshRate) || (displayLevel >= 4)) { \
|
82
82
|
g_time = clock(); \
|
83
83
|
DISPLAY(__VA_ARGS__); \
|
84
84
|
} \
|
@@ -301,9 +301,10 @@ static int WIN_CDECL COVER_strict_cmp8(const void *lp, const void *rp) {
|
|
301
301
|
* Returns the first pointer in [first, last) whose element does not compare
|
302
302
|
* less than value. If no such element exists it returns last.
|
303
303
|
*/
|
304
|
-
static const size_t *COVER_lower_bound(const size_t
|
304
|
+
static const size_t *COVER_lower_bound(const size_t* first, const size_t* last,
|
305
305
|
size_t value) {
|
306
|
-
size_t count = last - first;
|
306
|
+
size_t count = (size_t)(last - first);
|
307
|
+
assert(last >= first);
|
307
308
|
while (count != 0) {
|
308
309
|
size_t step = count / 2;
|
309
310
|
const size_t *ptr = first;
|
@@ -549,7 +550,8 @@ static void COVER_ctx_destroy(COVER_ctx_t *ctx) {
|
|
549
550
|
*/
|
550
551
|
static size_t COVER_ctx_init(COVER_ctx_t *ctx, const void *samplesBuffer,
|
551
552
|
const size_t *samplesSizes, unsigned nbSamples,
|
552
|
-
unsigned d, double splitPoint)
|
553
|
+
unsigned d, double splitPoint)
|
554
|
+
{
|
553
555
|
const BYTE *const samples = (const BYTE *)samplesBuffer;
|
554
556
|
const size_t totalSamplesSize = COVER_sum(samplesSizes, nbSamples);
|
555
557
|
/* Split samples into testing and training sets */
|
@@ -733,7 +735,7 @@ static size_t COVER_buildDictionary(const COVER_ctx_t *ctx, U32 *freqs,
|
|
733
735
|
return tail;
|
734
736
|
}
|
735
737
|
|
736
|
-
|
738
|
+
ZDICTLIB_STATIC_API size_t ZDICT_trainFromBuffer_cover(
|
737
739
|
void *dictBuffer, size_t dictBufferCapacity,
|
738
740
|
const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
|
739
741
|
ZDICT_cover_params_t parameters)
|
@@ -907,8 +909,10 @@ void COVER_best_start(COVER_best_t *best) {
|
|
907
909
|
* Decrements liveJobs and signals any waiting threads if liveJobs == 0.
|
908
910
|
* If this dictionary is the best so far save it and its parameters.
|
909
911
|
*/
|
910
|
-
void COVER_best_finish(COVER_best_t
|
911
|
-
|
912
|
+
void COVER_best_finish(COVER_best_t* best,
|
913
|
+
ZDICT_cover_params_t parameters,
|
914
|
+
COVER_dictSelection_t selection)
|
915
|
+
{
|
912
916
|
void* dict = selection.dictContent;
|
913
917
|
size_t compressedSize = selection.totalCompressedSize;
|
914
918
|
size_t dictSize = selection.dictSize;
|
@@ -980,8 +984,8 @@ COVER_dictSelection_t COVER_selectDict(BYTE* customDictContent, size_t dictBuffe
|
|
980
984
|
size_t largestCompressed = 0;
|
981
985
|
BYTE* customDictContentEnd = customDictContent + dictContentSize;
|
982
986
|
|
983
|
-
BYTE
|
984
|
-
BYTE
|
987
|
+
BYTE* largestDictbuffer = (BYTE*)malloc(dictBufferCapacity);
|
988
|
+
BYTE* candidateDictBuffer = (BYTE*)malloc(dictBufferCapacity);
|
985
989
|
double regressionTolerance = ((double)params.shrinkDictMaxRegression / 100.0) + 1.00;
|
986
990
|
|
987
991
|
if (!largestDictbuffer || !candidateDictBuffer) {
|
@@ -1119,7 +1123,7 @@ _cleanup:
|
|
1119
1123
|
free(freqs);
|
1120
1124
|
}
|
1121
1125
|
|
1122
|
-
|
1126
|
+
ZDICTLIB_STATIC_API size_t ZDICT_optimizeTrainFromBuffer_cover(
|
1123
1127
|
void* dictBuffer, size_t dictBufferCapacity, const void* samplesBuffer,
|
1124
1128
|
const size_t* samplesSizes, unsigned nbSamples,
|
1125
1129
|
ZDICT_cover_params_t* parameters)
|
@@ -12,14 +12,8 @@
|
|
12
12
|
# define ZDICT_STATIC_LINKING_ONLY
|
13
13
|
#endif
|
14
14
|
|
15
|
-
#include
|
16
|
-
#include
|
17
|
-
#include <string.h> /* memset */
|
18
|
-
#include <time.h> /* clock */
|
19
|
-
#include "../common/mem.h" /* read */
|
20
|
-
#include "../common/pool.h"
|
21
|
-
#include "../common/threading.h"
|
22
|
-
#include "../common/zstd_internal.h" /* includes zstd.h */
|
15
|
+
#include "../common/threading.h" /* ZSTD_pthread_mutex_t */
|
16
|
+
#include "../common/mem.h" /* U32, BYTE */
|
23
17
|
#include "../zdict.h"
|
24
18
|
|
25
19
|
/**
|
@@ -545,7 +545,7 @@ FASTCOVER_convertToFastCoverParams(ZDICT_cover_params_t coverParams,
|
|
545
545
|
}
|
546
546
|
|
547
547
|
|
548
|
-
|
548
|
+
ZDICTLIB_STATIC_API size_t
|
549
549
|
ZDICT_trainFromBuffer_fastCover(void* dictBuffer, size_t dictBufferCapacity,
|
550
550
|
const void* samplesBuffer,
|
551
551
|
const size_t* samplesSizes, unsigned nbSamples,
|
@@ -614,7 +614,7 @@ ZDICT_trainFromBuffer_fastCover(void* dictBuffer, size_t dictBufferCapacity,
|
|
614
614
|
}
|
615
615
|
|
616
616
|
|
617
|
-
|
617
|
+
ZDICTLIB_STATIC_API size_t
|
618
618
|
ZDICT_optimizeTrainFromBuffer_fastCover(
|
619
619
|
void* dictBuffer, size_t dictBufferCapacity,
|
620
620
|
const void* samplesBuffer,
|
@@ -74,9 +74,9 @@ static const U32 g_selectivity_default = 9;
|
|
74
74
|
* Console display
|
75
75
|
***************************************/
|
76
76
|
#undef DISPLAY
|
77
|
-
#define DISPLAY(...) { fprintf(stderr, __VA_ARGS__); fflush( stderr ); }
|
77
|
+
#define DISPLAY(...) do { fprintf(stderr, __VA_ARGS__); fflush( stderr ); } while (0)
|
78
78
|
#undef DISPLAYLEVEL
|
79
|
-
#define DISPLAYLEVEL(l, ...) if (notificationLevel>=l) { DISPLAY(__VA_ARGS__); } /* 0 : no display; 1: errors; 2: default; 3: details; 4: debug */
|
79
|
+
#define DISPLAYLEVEL(l, ...) do { if (notificationLevel>=l) { DISPLAY(__VA_ARGS__); } } while (0) /* 0 : no display; 1: errors; 2: default; 3: details; 4: debug */
|
80
80
|
|
81
81
|
static clock_t ZDICT_clockSpan(clock_t nPrevious) { return clock() - nPrevious; }
|
82
82
|
|
@@ -477,10 +477,16 @@ static size_t ZDICT_trainBuffer_legacy(dictItem* dictList, U32 dictListSize,
|
|
477
477
|
clock_t const refreshRate = CLOCKS_PER_SEC * 3 / 10;
|
478
478
|
|
479
479
|
# undef DISPLAYUPDATE
|
480
|
-
# define DISPLAYUPDATE(l, ...)
|
481
|
-
|
482
|
-
|
483
|
-
|
480
|
+
# define DISPLAYUPDATE(l, ...) \
|
481
|
+
do { \
|
482
|
+
if (notificationLevel>=l) { \
|
483
|
+
if (ZDICT_clockSpan(displayClock) > refreshRate) { \
|
484
|
+
displayClock = clock(); \
|
485
|
+
DISPLAY(__VA_ARGS__); \
|
486
|
+
} \
|
487
|
+
if (notificationLevel>=4) fflush(stderr); \
|
488
|
+
} \
|
489
|
+
} while (0)
|
484
490
|
|
485
491
|
/* init */
|
486
492
|
DISPLAYLEVEL(2, "\r%70s\r", ""); /* clean display line */
|
@@ -124,6 +124,20 @@ MEM_STATIC size_t ZSTD_decompressLegacy(
|
|
124
124
|
const void* dict,size_t dictSize)
|
125
125
|
{
|
126
126
|
U32 const version = ZSTD_isLegacy(src, compressedSize);
|
127
|
+
char x;
|
128
|
+
/* Avoid passing NULL to legacy decoding. */
|
129
|
+
if (dst == NULL) {
|
130
|
+
assert(dstCapacity == 0);
|
131
|
+
dst = &x;
|
132
|
+
}
|
133
|
+
if (src == NULL) {
|
134
|
+
assert(compressedSize == 0);
|
135
|
+
src = &x;
|
136
|
+
}
|
137
|
+
if (dict == NULL) {
|
138
|
+
assert(dictSize == 0);
|
139
|
+
dict = &x;
|
140
|
+
}
|
127
141
|
(void)dst; (void)dstCapacity; (void)dict; (void)dictSize; /* unused when ZSTD_LEGACY_SUPPORT >= 8 */
|
128
142
|
switch(version)
|
129
143
|
{
|
@@ -287,6 +301,12 @@ MEM_STATIC size_t ZSTD_freeLegacyStreamContext(void* legacyContext, U32 version)
|
|
287
301
|
MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U32 newVersion,
|
288
302
|
const void* dict, size_t dictSize)
|
289
303
|
{
|
304
|
+
char x;
|
305
|
+
/* Avoid passing NULL to legacy decoding. */
|
306
|
+
if (dict == NULL) {
|
307
|
+
assert(dictSize == 0);
|
308
|
+
dict = &x;
|
309
|
+
}
|
290
310
|
DEBUGLOG(5, "ZSTD_initLegacyStream for v0.%u", newVersion);
|
291
311
|
if (prevVersion != newVersion) ZSTD_freeLegacyStreamContext(*legacyContext, prevVersion);
|
292
312
|
switch(newVersion)
|
@@ -346,6 +366,16 @@ MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U
|
|
346
366
|
MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version,
|
347
367
|
ZSTD_outBuffer* output, ZSTD_inBuffer* input)
|
348
368
|
{
|
369
|
+
static char x;
|
370
|
+
/* Avoid passing NULL to legacy decoding. */
|
371
|
+
if (output->dst == NULL) {
|
372
|
+
assert(output->size == 0);
|
373
|
+
output->dst = &x;
|
374
|
+
}
|
375
|
+
if (input->src == NULL) {
|
376
|
+
assert(input->size == 0);
|
377
|
+
input->src = &x;
|
378
|
+
}
|
349
379
|
DEBUGLOG(5, "ZSTD_decompressLegacyStream for v0.%u", version);
|
350
380
|
switch(version)
|
351
381
|
{
|
@@ -14,6 +14,7 @@
|
|
14
14
|
******************************************/
|
15
15
|
#include <stddef.h> /* size_t, ptrdiff_t */
|
16
16
|
#include "zstd_v01.h"
|
17
|
+
#include "../common/compiler.h"
|
17
18
|
#include "../common/error_private.h"
|
18
19
|
|
19
20
|
|
@@ -2118,6 +2119,7 @@ size_t ZSTDv01_decompressContinue(ZSTDv01_Dctx* dctx, void* dst, size_t maxDstSi
|
|
2118
2119
|
}
|
2119
2120
|
ctx->phase = 1;
|
2120
2121
|
ctx->expected = ZSTD_blockHeaderSize;
|
2122
|
+
if (ZSTDv01_isError(rSize)) return rSize;
|
2121
2123
|
ctx->previousDstEnd = (void*)( ((char*)dst) + rSize);
|
2122
2124
|
return rSize;
|
2123
2125
|
}
|
@@ -11,6 +11,7 @@
|
|
11
11
|
|
12
12
|
#include <stddef.h> /* size_t, ptrdiff_t */
|
13
13
|
#include "zstd_v02.h"
|
14
|
+
#include "../common/compiler.h"
|
14
15
|
#include "../common/error_private.h"
|
15
16
|
|
16
17
|
|
@@ -71,20 +72,6 @@ extern "C" {
|
|
71
72
|
#include <string.h> /* memcpy */
|
72
73
|
|
73
74
|
|
74
|
-
/******************************************
|
75
|
-
* Compiler-specific
|
76
|
-
******************************************/
|
77
|
-
#if defined(__GNUC__)
|
78
|
-
# define MEM_STATIC static __attribute__((unused))
|
79
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
80
|
-
# define MEM_STATIC static inline
|
81
|
-
#elif defined(_MSC_VER)
|
82
|
-
# define MEM_STATIC static __inline
|
83
|
-
#else
|
84
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
85
|
-
#endif
|
86
|
-
|
87
|
-
|
88
75
|
/****************************************************************
|
89
76
|
* Basic Types
|
90
77
|
*****************************************************************/
|
@@ -875,7 +862,7 @@ extern "C" {
|
|
875
862
|
* Streaming functions
|
876
863
|
***************************************/
|
877
864
|
|
878
|
-
typedef struct
|
865
|
+
typedef struct ZSTDv02_Dctx_s ZSTD_DCtx;
|
879
866
|
|
880
867
|
/*
|
881
868
|
Use above functions alternatively.
|
@@ -2750,7 +2737,7 @@ static unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
|
|
2750
2737
|
/* *************************************************************
|
2751
2738
|
* Decompression section
|
2752
2739
|
***************************************************************/
|
2753
|
-
struct
|
2740
|
+
struct ZSTDv02_Dctx_s
|
2754
2741
|
{
|
2755
2742
|
U32 LLTable[FSE_DTABLE_SIZE_U32(LLFSELog)];
|
2756
2743
|
U32 OffTable[FSE_DTABLE_SIZE_U32(OffFSELog)];
|
@@ -3431,6 +3418,7 @@ static size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSi
|
|
3431
3418
|
}
|
3432
3419
|
ctx->phase = 1;
|
3433
3420
|
ctx->expected = ZSTD_blockHeaderSize;
|
3421
|
+
if (ZSTD_isError(rSize)) return rSize;
|
3434
3422
|
ctx->previousDstEnd = (void*)( ((char*)dst) + rSize);
|
3435
3423
|
return rSize;
|
3436
3424
|
}
|
@@ -11,6 +11,7 @@
|
|
11
11
|
|
12
12
|
#include <stddef.h> /* size_t, ptrdiff_t */
|
13
13
|
#include "zstd_v03.h"
|
14
|
+
#include "../common/compiler.h"
|
14
15
|
#include "../common/error_private.h"
|
15
16
|
|
16
17
|
|
@@ -72,20 +73,6 @@ extern "C" {
|
|
72
73
|
#include <string.h> /* memcpy */
|
73
74
|
|
74
75
|
|
75
|
-
/******************************************
|
76
|
-
* Compiler-specific
|
77
|
-
******************************************/
|
78
|
-
#if defined(__GNUC__)
|
79
|
-
# define MEM_STATIC static __attribute__((unused))
|
80
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
81
|
-
# define MEM_STATIC static inline
|
82
|
-
#elif defined(_MSC_VER)
|
83
|
-
# define MEM_STATIC static __inline
|
84
|
-
#else
|
85
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
86
|
-
#endif
|
87
|
-
|
88
|
-
|
89
76
|
/****************************************************************
|
90
77
|
* Basic Types
|
91
78
|
*****************************************************************/
|
@@ -875,7 +862,7 @@ extern "C" {
|
|
875
862
|
* Streaming functions
|
876
863
|
***************************************/
|
877
864
|
|
878
|
-
typedef struct
|
865
|
+
typedef struct ZSTDv03_Dctx_s ZSTD_DCtx;
|
879
866
|
|
880
867
|
/*
|
881
868
|
Use above functions alternatively.
|
@@ -2390,7 +2377,7 @@ static unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
|
|
2390
2377
|
/* *************************************************************
|
2391
2378
|
* Decompression section
|
2392
2379
|
***************************************************************/
|
2393
|
-
struct
|
2380
|
+
struct ZSTDv03_Dctx_s
|
2394
2381
|
{
|
2395
2382
|
U32 LLTable[FSE_DTABLE_SIZE_U32(LLFSELog)];
|
2396
2383
|
U32 OffTable[FSE_DTABLE_SIZE_U32(OffFSELog)];
|
@@ -3071,6 +3058,7 @@ static size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSi
|
|
3071
3058
|
}
|
3072
3059
|
ctx->phase = 1;
|
3073
3060
|
ctx->expected = ZSTD_blockHeaderSize;
|
3061
|
+
if (ZSTD_isError(rSize)) return rSize;
|
3074
3062
|
ctx->previousDstEnd = (void*)( ((char*)dst) + rSize);
|
3075
3063
|
return rSize;
|
3076
3064
|
}
|
@@ -16,6 +16,7 @@
|
|
16
16
|
#include <string.h> /* memcpy */
|
17
17
|
|
18
18
|
#include "zstd_v04.h"
|
19
|
+
#include "../common/compiler.h"
|
19
20
|
#include "../common/error_private.h"
|
20
21
|
|
21
22
|
|
@@ -37,15 +38,6 @@ extern "C" {
|
|
37
38
|
# include <stdlib.h> /* _byteswap_ulong */
|
38
39
|
# include <intrin.h> /* _byteswap_* */
|
39
40
|
#endif
|
40
|
-
#if defined(__GNUC__)
|
41
|
-
# define MEM_STATIC static __attribute__((unused))
|
42
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
43
|
-
# define MEM_STATIC static inline
|
44
|
-
#elif defined(_MSC_VER)
|
45
|
-
# define MEM_STATIC static __inline
|
46
|
-
#else
|
47
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
48
|
-
#endif
|
49
41
|
|
50
42
|
|
51
43
|
/****************************************************************
|
@@ -3218,6 +3210,7 @@ static size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSi
|
|
3218
3210
|
}
|
3219
3211
|
ctx->stage = ZSTDds_decodeBlockHeader;
|
3220
3212
|
ctx->expected = ZSTD_blockHeaderSize;
|
3213
|
+
if (ZSTD_isError(rSize)) return rSize;
|
3221
3214
|
ctx->previousDstEnd = (char*)dst + rSize;
|
3222
3215
|
return rSize;
|
3223
3216
|
}
|
@@ -3545,8 +3538,8 @@ static size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbc, void* dst, size_t* maxDs
|
|
3545
3538
|
unsigned ZBUFFv04_isError(size_t errorCode) { return ERR_isError(errorCode); }
|
3546
3539
|
const char* ZBUFFv04_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
|
3547
3540
|
|
3548
|
-
size_t ZBUFFv04_recommendedDInSize() { return BLOCKSIZE + 3; }
|
3549
|
-
size_t ZBUFFv04_recommendedDOutSize() { return BLOCKSIZE; }
|
3541
|
+
size_t ZBUFFv04_recommendedDInSize(void) { return BLOCKSIZE + 3; }
|
3542
|
+
size_t ZBUFFv04_recommendedDOutSize(void) { return BLOCKSIZE; }
|
3550
3543
|
|
3551
3544
|
|
3552
3545
|
|
@@ -3600,6 +3600,7 @@ size_t ZSTDv05_decompressContinue(ZSTDv05_DCtx* dctx, void* dst, size_t maxDstSi
|
|
3600
3600
|
}
|
3601
3601
|
dctx->stage = ZSTDv05ds_decodeBlockHeader;
|
3602
3602
|
dctx->expected = ZSTDv05_blockHeaderSize;
|
3603
|
+
if (ZSTDv05_isError(rSize)) return rSize;
|
3603
3604
|
dctx->previousDstEnd = (char*)dst + rSize;
|
3604
3605
|
return rSize;
|
3605
3606
|
}
|
@@ -14,6 +14,7 @@
|
|
14
14
|
#include <stddef.h> /* size_t, ptrdiff_t */
|
15
15
|
#include <string.h> /* memcpy */
|
16
16
|
#include <stdlib.h> /* malloc, free, qsort */
|
17
|
+
#include "../common/compiler.h"
|
17
18
|
#include "../common/error_private.h"
|
18
19
|
|
19
20
|
|
@@ -67,15 +68,6 @@ extern "C" {
|
|
67
68
|
# include <stdlib.h> /* _byteswap_ulong */
|
68
69
|
# include <intrin.h> /* _byteswap_* */
|
69
70
|
#endif
|
70
|
-
#if defined(__GNUC__)
|
71
|
-
# define MEM_STATIC static __attribute__((unused))
|
72
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
73
|
-
# define MEM_STATIC static inline
|
74
|
-
#elif defined(_MSC_VER)
|
75
|
-
# define MEM_STATIC static __inline
|
76
|
-
#else
|
77
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
78
|
-
#endif
|
79
71
|
|
80
72
|
|
81
73
|
/*-**************************************************************
|
@@ -3745,6 +3737,7 @@ size_t ZSTDv06_decompressContinue(ZSTDv06_DCtx* dctx, void* dst, size_t dstCapac
|
|
3745
3737
|
}
|
3746
3738
|
dctx->stage = ZSTDds_decodeBlockHeader;
|
3747
3739
|
dctx->expected = ZSTDv06_blockHeaderSize;
|
3740
|
+
if (ZSTDv06_isError(rSize)) return rSize;
|
3748
3741
|
dctx->previousDstEnd = (char*)dst + rSize;
|
3749
3742
|
return rSize;
|
3750
3743
|
}
|
@@ -24,6 +24,7 @@
|
|
24
24
|
#define HUFv07_STATIC_LINKING_ONLY /* HUFv07_TABLELOG_ABSOLUTEMAX */
|
25
25
|
#define ZSTDv07_STATIC_LINKING_ONLY
|
26
26
|
|
27
|
+
#include "../common/compiler.h"
|
27
28
|
#include "../common/error_private.h"
|
28
29
|
|
29
30
|
|
@@ -227,15 +228,6 @@ extern "C" {
|
|
227
228
|
# include <stdlib.h> /* _byteswap_ulong */
|
228
229
|
# include <intrin.h> /* _byteswap_* */
|
229
230
|
#endif
|
230
|
-
#if defined(__GNUC__)
|
231
|
-
# define MEM_STATIC static __attribute__((unused))
|
232
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
233
|
-
# define MEM_STATIC static inline
|
234
|
-
#elif defined(_MSC_VER)
|
235
|
-
# define MEM_STATIC static __inline
|
236
|
-
#else
|
237
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
238
|
-
#endif
|
239
231
|
|
240
232
|
|
241
233
|
/*-**************************************************************
|
@@ -4015,8 +4007,8 @@ size_t ZSTDv07_decompressContinue(ZSTDv07_DCtx* dctx, void* dst, size_t dstCapac
|
|
4015
4007
|
}
|
4016
4008
|
dctx->stage = ZSTDds_decodeBlockHeader;
|
4017
4009
|
dctx->expected = ZSTDv07_blockHeaderSize;
|
4018
|
-
dctx->previousDstEnd = (char*)dst + rSize;
|
4019
4010
|
if (ZSTDv07_isError(rSize)) return rSize;
|
4011
|
+
dctx->previousDstEnd = (char*)dst + rSize;
|
4020
4012
|
if (dctx->fParams.checksumFlag) XXH64_update(&dctx->xxhState, dst, rSize);
|
4021
4013
|
return rSize;
|
4022
4014
|
}
|
data/contrib/zstd/lib/libzstd.mk
CHANGED
@@ -8,12 +8,21 @@
|
|
8
8
|
# You may select, at your option, one of the above-listed licenses.
|
9
9
|
# ################################################################
|
10
10
|
|
11
|
+
# This included Makefile provides the following variables :
|
12
|
+
# LIB_SRCDIR, LIB_BINDIR
|
13
|
+
|
14
|
+
# Ensure the file is not included twice
|
15
|
+
# Note : must be included after setting the default target
|
16
|
+
ifndef LIBZSTD_MK_INCLUDED
|
17
|
+
LIBZSTD_MK_INCLUDED := 1
|
18
|
+
|
11
19
|
##################################################################
|
12
20
|
# Input Variables
|
13
21
|
##################################################################
|
14
22
|
|
15
|
-
#
|
16
|
-
|
23
|
+
# By default, library's directory is same as this included makefile
|
24
|
+
LIB_SRCDIR ?= $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
25
|
+
LIB_BINDIR ?= $(LIBSRC_DIR)
|
17
26
|
|
18
27
|
# ZSTD_LIB_MINIFY is a helper variable that
|
19
28
|
# configures a bunch of other variables to space-optimized defaults.
|
@@ -47,6 +56,9 @@ endif
|
|
47
56
|
# Assembly support
|
48
57
|
ZSTD_NO_ASM ?= 0
|
49
58
|
|
59
|
+
ZSTD_LIB_EXCLUDE_COMPRESSORS_DFAST_AND_UP ?= 0
|
60
|
+
ZSTD_LIB_EXCLUDE_COMPRESSORS_GREEDY_AND_UP ?= 0
|
61
|
+
|
50
62
|
##################################################################
|
51
63
|
# libzstd helpers
|
52
64
|
##################################################################
|
@@ -57,6 +69,7 @@ VOID ?= /dev/null
|
|
57
69
|
NUM_SYMBOL := \#
|
58
70
|
|
59
71
|
# define silent mode as default (verbose mode with V=1 or VERBOSE=1)
|
72
|
+
# Note : must be defined _after_ the default target
|
60
73
|
$(V)$(VERBOSE).SILENT:
|
61
74
|
|
62
75
|
# When cross-compiling from linux to windows,
|
@@ -66,7 +79,7 @@ $(V)$(VERBOSE).SILENT:
|
|
66
79
|
TARGET_SYSTEM ?= $(OS)
|
67
80
|
|
68
81
|
# Version numbers
|
69
|
-
LIBVER_SRC := $(
|
82
|
+
LIBVER_SRC := $(LIB_SRCDIR)/zstd.h
|
70
83
|
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
71
84
|
LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
72
85
|
LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
@@ -133,14 +146,14 @@ ifeq ($(HAVE_COLORNEVER), 1)
|
|
133
146
|
endif
|
134
147
|
GREP = grep $(GREP_OPTIONS)
|
135
148
|
|
136
|
-
ZSTD_COMMON_FILES := $(sort $(wildcard $(
|
137
|
-
ZSTD_COMPRESS_FILES := $(sort $(wildcard $(
|
138
|
-
ZSTD_DECOMPRESS_FILES := $(sort $(wildcard $(
|
139
|
-
ZSTD_DICTBUILDER_FILES := $(sort $(wildcard $(
|
140
|
-
ZSTD_DEPRECATED_FILES := $(sort $(wildcard $(
|
149
|
+
ZSTD_COMMON_FILES := $(sort $(wildcard $(LIB_SRCDIR)/common/*.c))
|
150
|
+
ZSTD_COMPRESS_FILES := $(sort $(wildcard $(LIB_SRCDIR)/compress/*.c))
|
151
|
+
ZSTD_DECOMPRESS_FILES := $(sort $(wildcard $(LIB_SRCDIR)/decompress/*.c))
|
152
|
+
ZSTD_DICTBUILDER_FILES := $(sort $(wildcard $(LIB_SRCDIR)/dictBuilder/*.c))
|
153
|
+
ZSTD_DEPRECATED_FILES := $(sort $(wildcard $(LIB_SRCDIR)/deprecated/*.c))
|
141
154
|
ZSTD_LEGACY_FILES :=
|
142
155
|
|
143
|
-
ZSTD_DECOMPRESS_AMD64_ASM_FILES := $(sort $(wildcard $(
|
156
|
+
ZSTD_DECOMPRESS_AMD64_ASM_FILES := $(sort $(wildcard $(LIB_SRCDIR)/decompress/*_amd64.S))
|
144
157
|
|
145
158
|
ifneq ($(ZSTD_NO_ASM), 0)
|
146
159
|
CPPFLAGS += -DZSTD_DISABLE_ASM
|
@@ -178,9 +191,17 @@ ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
|
|
178
191
|
CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
|
179
192
|
endif
|
180
193
|
|
194
|
+
ifneq ($(ZSTD_LIB_EXCLUDE_COMPRESSORS_DFAST_AND_UP), 0)
|
195
|
+
CFLAGS += -DZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR
|
196
|
+
else
|
197
|
+
ifneq ($(ZSTD_LIB_EXCLUDE_COMPRESSORS_GREEDY_AND_UP), 0)
|
198
|
+
CFLAGS += -DZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR -DZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR
|
199
|
+
endif
|
200
|
+
endif
|
201
|
+
|
181
202
|
ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
|
182
203
|
ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
|
183
|
-
ZSTD_LEGACY_FILES += $(shell ls $(
|
204
|
+
ZSTD_LEGACY_FILES += $(shell ls $(LIB_SRCDIR)/legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
|
184
205
|
endif
|
185
206
|
endif
|
186
207
|
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
@@ -209,6 +230,8 @@ ifeq ($(HAVE_HASH),0)
|
|
209
230
|
endif
|
210
231
|
endif # BUILD_DIR
|
211
232
|
|
212
|
-
ZSTD_SUBDIR := $(
|
233
|
+
ZSTD_SUBDIR := $(LIB_SRCDIR)/common $(LIB_SRCDIR)/compress $(LIB_SRCDIR)/decompress $(LIB_SRCDIR)/dictBuilder $(LIB_SRCDIR)/legacy $(LIB_SRCDIR)/deprecated
|
213
234
|
vpath %.c $(ZSTD_SUBDIR)
|
214
235
|
vpath %.S $(ZSTD_SUBDIR)
|
236
|
+
|
237
|
+
endif # LIBZSTD_MK_INCLUDED
|