extzstd 0.0.3.CONCEPT-x86-mingw32 → 0.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.ja +5 -0
- data/LICENSE +6 -6
- data/README.md +35 -22
- data/contrib/zstd/LICENSE +13 -9
- data/contrib/zstd/README.md +37 -44
- data/contrib/zstd/common/entropy_common.c +33 -39
- data/contrib/zstd/common/error_private.c +43 -0
- data/contrib/zstd/common/error_private.h +11 -60
- data/contrib/zstd/common/fse.h +11 -5
- data/contrib/zstd/common/fse_decompress.c +14 -16
- data/contrib/zstd/common/huf.h +1 -1
- data/contrib/zstd/common/mem.h +36 -43
- data/contrib/zstd/common/xxhash.c +31 -18
- data/contrib/zstd/common/xxhash.h +71 -35
- data/contrib/zstd/common/zbuff.h +29 -35
- data/contrib/zstd/common/zstd_common.c +24 -32
- data/contrib/zstd/common/zstd_errors.h +60 -0
- data/contrib/zstd/common/zstd_internal.h +109 -80
- data/contrib/zstd/compress/fse_compress.c +9 -6
- data/contrib/zstd/compress/huf_compress.c +30 -74
- data/contrib/zstd/compress/zbuff_compress.c +43 -51
- data/contrib/zstd/compress/zstd_compress.c +953 -763
- data/contrib/zstd/compress/zstd_opt.h +115 -261
- data/contrib/zstd/decompress/huf_decompress.c +29 -40
- data/contrib/zstd/decompress/zbuff_decompress.c +36 -78
- data/contrib/zstd/decompress/zstd_decompress.c +976 -496
- data/contrib/zstd/dictBuilder/divsufsort.h +5 -5
- data/contrib/zstd/dictBuilder/zdict.c +194 -229
- data/contrib/zstd/dictBuilder/zdict.h +66 -68
- data/contrib/zstd/legacy/zstd_legacy.h +168 -49
- data/contrib/zstd/legacy/zstd_v01.c +95 -178
- data/contrib/zstd/legacy/zstd_v01.h +12 -32
- data/contrib/zstd/legacy/zstd_v02.c +48 -274
- data/contrib/zstd/legacy/zstd_v02.h +12 -32
- data/contrib/zstd/legacy/zstd_v03.c +48 -274
- data/contrib/zstd/legacy/zstd_v03.h +12 -32
- data/contrib/zstd/legacy/zstd_v04.c +63 -320
- data/contrib/zstd/legacy/zstd_v04.h +13 -33
- data/contrib/zstd/legacy/zstd_v05.c +80 -345
- data/contrib/zstd/legacy/zstd_v05.h +9 -31
- data/contrib/zstd/legacy/zstd_v06.c +48 -458
- data/contrib/zstd/legacy/zstd_v06.h +41 -67
- data/contrib/zstd/legacy/zstd_v07.c +4544 -0
- data/contrib/zstd/legacy/zstd_v07.h +173 -0
- data/contrib/zstd/zstd.h +640 -0
- data/ext/extconf.rb +7 -3
- data/ext/extzstd.c +263 -106
- data/ext/extzstd.h +8 -6
- data/ext/extzstd_nogvls.h +0 -117
- data/ext/extzstd_stream.c +347 -0
- data/ext/zstd_common.c +8 -0
- data/ext/zstd_compress.c +6 -0
- data/ext/zstd_decompress.c +5 -0
- data/ext/zstd_dictbuilder.c +5 -0
- data/ext/zstd_legacy_v07.c +1 -0
- data/gemstub.rb +18 -16
- data/lib/2.1/extzstd.so +0 -0
- data/lib/2.2/extzstd.so +0 -0
- data/lib/2.3/extzstd.so +0 -0
- data/lib/extzstd/version.rb +1 -1
- data/lib/extzstd.rb +77 -43
- data/test/test_basic.rb +11 -6
- metadata +23 -11
- data/contrib/zstd/common/error_public.h +0 -77
- data/contrib/zstd/common/zstd.h +0 -475
- data/ext/extzstd_buffered.c +0 -265
- data/ext/zstd_amalgam.c +0 -18
- data/lib/2.0/extzstd.so +0 -0
@@ -1,89 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
met:
|
10
|
-
|
11
|
-
* Redistributions of source code must retain the above copyright
|
12
|
-
notice, this list of conditions and the following disclaimer.
|
13
|
-
* Redistributions in binary form must reproduce the above
|
14
|
-
copyright notice, this list of conditions and the following disclaimer
|
15
|
-
in the documentation and/or other materials provided with the
|
16
|
-
distribution.
|
17
|
-
|
18
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
-
|
30
|
-
You can contact the author at :
|
31
|
-
- Source repository : https://github.com/Cyan4973/FiniteStateEntropy
|
32
|
-
- Public forum : https://groups.google.com/forum/#!forum/lz4c
|
33
|
-
****************************************************************** */
|
34
|
-
#ifndef ERROR_H_MODULE
|
35
|
-
#define ERROR_H_MODULE
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
+
*/
|
36
9
|
|
37
|
-
#if defined (__cplusplus)
|
38
|
-
extern "C" {
|
39
|
-
#endif
|
40
10
|
|
41
11
|
#include <stddef.h> /* size_t, ptrdiff_t */
|
42
12
|
#include "zstd_v03.h"
|
43
|
-
|
44
|
-
/******************************************
|
45
|
-
* Compiler-specific
|
46
|
-
******************************************/
|
47
|
-
#if defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
48
|
-
# define ERR_STATIC static inline
|
49
|
-
#elif defined(_MSC_VER)
|
50
|
-
# define ERR_STATIC static __inline
|
51
|
-
#elif defined(__GNUC__)
|
52
|
-
# define ERR_STATIC static __attribute__((unused))
|
53
|
-
#else
|
54
|
-
# define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
55
|
-
#endif
|
13
|
+
#include "error_private.h"
|
56
14
|
|
57
15
|
|
58
16
|
/******************************************
|
59
|
-
*
|
17
|
+
* Compiler-specific
|
60
18
|
******************************************/
|
61
|
-
#
|
62
|
-
|
63
|
-
#
|
64
|
-
|
65
|
-
#define ERROR_LIST(ITEM) \
|
66
|
-
ITEM(PREFIX(No_Error)) ITEM(PREFIX(GENERIC)) \
|
67
|
-
ITEM(PREFIX(memory_allocation)) \
|
68
|
-
ITEM(PREFIX(dstSize_tooSmall)) ITEM(PREFIX(srcSize_wrong)) \
|
69
|
-
ITEM(PREFIX(prefix_unknown)) ITEM(PREFIX(corruption_detected)) \
|
70
|
-
ITEM(PREFIX(tableLog_tooLarge)) ITEM(PREFIX(maxSymbolValue_tooLarge)) ITEM(PREFIX(maxSymbolValue_tooSmall)) \
|
71
|
-
ITEM(PREFIX(maxCode))
|
72
|
-
|
73
|
-
#define ERROR_GENERATE_ENUM(ENUM) ENUM,
|
74
|
-
typedef enum { ERROR_LIST(ERROR_GENERATE_ENUM) } ERR_codes; /* enum is exposed, to detect & handle specific errors; compare function result to -enum value */
|
75
|
-
|
76
|
-
#define ERROR_CONVERTTOSTRING(STRING) #STRING,
|
77
|
-
#define ERROR_GENERATE_STRING(EXPR) ERROR_CONVERTTOSTRING(EXPR)
|
78
|
-
|
79
|
-
ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
|
80
|
-
|
81
|
-
|
82
|
-
#if defined (__cplusplus)
|
83
|
-
}
|
19
|
+
#if defined(_MSC_VER) /* Visual Studio */
|
20
|
+
# include <stdlib.h> /* _byteswap_ulong */
|
21
|
+
# include <intrin.h> /* _byteswap_* */
|
84
22
|
#endif
|
85
23
|
|
86
|
-
#endif /* ERROR_H_MODULE */
|
87
24
|
|
88
25
|
|
89
26
|
/* ******************************************************************
|
@@ -190,7 +127,7 @@ extern "C" {
|
|
190
127
|
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
191
128
|
# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
|
192
129
|
# define MEM_FORCE_MEMORY_ACCESS 2
|
193
|
-
# elif defined(__INTEL_COMPILER) || \
|
130
|
+
# elif (defined(__INTEL_COMPILER) && !defined(WIN32)) || \
|
194
131
|
(defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) ))
|
195
132
|
# define MEM_FORCE_MEMORY_ACCESS 1
|
196
133
|
# endif
|
@@ -214,8 +151,6 @@ MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
|
214
151
|
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
215
152
|
|
216
153
|
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
217
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
|
218
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
|
219
154
|
|
220
155
|
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
|
221
156
|
|
@@ -228,8 +163,6 @@ MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32;
|
|
228
163
|
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
229
164
|
|
230
165
|
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
231
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; }
|
232
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign*)memPtr)->u64 = value; }
|
233
166
|
|
234
167
|
#else
|
235
168
|
|
@@ -256,15 +189,6 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
|
|
256
189
|
memcpy(memPtr, &value, sizeof(value));
|
257
190
|
}
|
258
191
|
|
259
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value)
|
260
|
-
{
|
261
|
-
memcpy(memPtr, &value, sizeof(value));
|
262
|
-
}
|
263
|
-
|
264
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value)
|
265
|
-
{
|
266
|
-
memcpy(memPtr, &value, sizeof(value));
|
267
|
-
}
|
268
192
|
|
269
193
|
#endif // MEM_FORCE_MEMORY_ACCESS
|
270
194
|
|
@@ -305,22 +229,6 @@ MEM_STATIC U32 MEM_readLE32(const void* memPtr)
|
|
305
229
|
}
|
306
230
|
}
|
307
231
|
|
308
|
-
MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32)
|
309
|
-
{
|
310
|
-
if (MEM_isLittleEndian())
|
311
|
-
{
|
312
|
-
MEM_write32(memPtr, val32);
|
313
|
-
}
|
314
|
-
else
|
315
|
-
{
|
316
|
-
BYTE* p = (BYTE*)memPtr;
|
317
|
-
p[0] = (BYTE)val32;
|
318
|
-
p[1] = (BYTE)(val32>>8);
|
319
|
-
p[2] = (BYTE)(val32>>16);
|
320
|
-
p[3] = (BYTE)(val32>>24);
|
321
|
-
}
|
322
|
-
}
|
323
|
-
|
324
232
|
MEM_STATIC U64 MEM_readLE64(const void* memPtr)
|
325
233
|
{
|
326
234
|
if (MEM_isLittleEndian())
|
@@ -333,25 +241,6 @@ MEM_STATIC U64 MEM_readLE64(const void* memPtr)
|
|
333
241
|
}
|
334
242
|
}
|
335
243
|
|
336
|
-
MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64)
|
337
|
-
{
|
338
|
-
if (MEM_isLittleEndian())
|
339
|
-
{
|
340
|
-
MEM_write64(memPtr, val64);
|
341
|
-
}
|
342
|
-
else
|
343
|
-
{
|
344
|
-
BYTE* p = (BYTE*)memPtr;
|
345
|
-
p[0] = (BYTE)val64;
|
346
|
-
p[1] = (BYTE)(val64>>8);
|
347
|
-
p[2] = (BYTE)(val64>>16);
|
348
|
-
p[3] = (BYTE)(val64>>24);
|
349
|
-
p[4] = (BYTE)(val64>>32);
|
350
|
-
p[5] = (BYTE)(val64>>40);
|
351
|
-
p[6] = (BYTE)(val64>>48);
|
352
|
-
p[7] = (BYTE)(val64>>56);
|
353
|
-
}
|
354
|
-
}
|
355
244
|
|
356
245
|
MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
357
246
|
{
|
@@ -361,13 +250,6 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
361
250
|
return (size_t)MEM_readLE64(memPtr);
|
362
251
|
}
|
363
252
|
|
364
|
-
MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val)
|
365
|
-
{
|
366
|
-
if (MEM_32bits())
|
367
|
-
MEM_writeLE32(memPtr, (U32)val);
|
368
|
-
else
|
369
|
-
MEM_writeLE64(memPtr, (U64)val);
|
370
|
-
}
|
371
253
|
|
372
254
|
#if defined (__cplusplus)
|
373
255
|
}
|
@@ -1197,12 +1079,15 @@ typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
|
1197
1079
|
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
1198
1080
|
# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */
|
1199
1081
|
#else
|
1200
|
-
#
|
1201
|
-
#
|
1202
|
-
#
|
1082
|
+
# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
|
1083
|
+
# ifdef __GNUC__
|
1084
|
+
# define FORCE_INLINE static inline __attribute__((always_inline))
|
1085
|
+
# else
|
1086
|
+
# define FORCE_INLINE static inline
|
1087
|
+
# endif
|
1203
1088
|
# else
|
1204
|
-
# define FORCE_INLINE static
|
1205
|
-
# endif
|
1089
|
+
# define FORCE_INLINE static
|
1090
|
+
# endif /* __STDC_VERSION__ */
|
1206
1091
|
#endif
|
1207
1092
|
|
1208
1093
|
|
@@ -1663,25 +1548,13 @@ static size_t FSE_decompress(void* dst, size_t maxDstSize, const void* cSrc, siz
|
|
1663
1548
|
#if defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
1664
1549
|
/* inline is defined */
|
1665
1550
|
#elif defined(_MSC_VER)
|
1551
|
+
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
1666
1552
|
# define inline __inline
|
1667
1553
|
#else
|
1668
1554
|
# define inline /* disable inline */
|
1669
1555
|
#endif
|
1670
1556
|
|
1671
1557
|
|
1672
|
-
#ifdef _MSC_VER /* Visual Studio */
|
1673
|
-
# define FORCE_INLINE static __forceinline
|
1674
|
-
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
1675
|
-
#else
|
1676
|
-
# ifdef __GNUC__
|
1677
|
-
# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
1678
|
-
# define FORCE_INLINE static inline __attribute__((always_inline))
|
1679
|
-
# else
|
1680
|
-
# define FORCE_INLINE static inline
|
1681
|
-
# endif
|
1682
|
-
#endif
|
1683
|
-
|
1684
|
-
|
1685
1558
|
/****************************************************************
|
1686
1559
|
* Includes
|
1687
1560
|
****************************************************************/
|
@@ -1731,10 +1604,12 @@ static size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
|
1731
1604
|
U32 weightTotal;
|
1732
1605
|
U32 tableLog;
|
1733
1606
|
const BYTE* ip = (const BYTE*) src;
|
1734
|
-
size_t iSize
|
1607
|
+
size_t iSize;
|
1735
1608
|
size_t oSize;
|
1736
1609
|
U32 n;
|
1737
1610
|
|
1611
|
+
if (!srcSize) return ERROR(srcSize_wrong);
|
1612
|
+
iSize = ip[0];
|
1738
1613
|
//memset(huffWeight, 0, hwSize); /* is not necessary, even though some analyzer complain ... */
|
1739
1614
|
|
1740
1615
|
if (iSize >= 128) /* special header */
|
@@ -1776,6 +1651,7 @@ static size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
|
|
1776
1651
|
rankStats[huffWeight[n]]++;
|
1777
1652
|
weightTotal += (1 << huffWeight[n]) >> 1;
|
1778
1653
|
}
|
1654
|
+
if (weightTotal == 0) return ERROR(corruption_detected);
|
1779
1655
|
|
1780
1656
|
/* get last non-null symbol weight (implied, total must be 2^n) */
|
1781
1657
|
tableLog = BIT_highbit32(weightTotal) + 1;
|
@@ -2507,17 +2383,11 @@ static size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_
|
|
2507
2383
|
#endif
|
2508
2384
|
|
2509
2385
|
#ifdef _MSC_VER /* Visual Studio */
|
2510
|
-
# define FORCE_INLINE static __forceinline
|
2511
2386
|
# include <intrin.h> /* For Visual 2005 */
|
2512
2387
|
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
|
2513
2388
|
# pragma warning(disable : 4324) /* disable: C4324: padded structure */
|
2514
2389
|
#else
|
2515
2390
|
# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
2516
|
-
# ifdef __GNUC__
|
2517
|
-
# define FORCE_INLINE static inline __attribute__((always_inline))
|
2518
|
-
# else
|
2519
|
-
# define FORCE_INLINE static inline
|
2520
|
-
# endif
|
2521
2391
|
#endif
|
2522
2392
|
|
2523
2393
|
|
@@ -2624,98 +2494,6 @@ typedef struct {
|
|
2624
2494
|
static unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
|
2625
2495
|
|
2626
2496
|
|
2627
|
-
/* *************************************
|
2628
|
-
* Function body to include
|
2629
|
-
***************************************/
|
2630
|
-
static size_t ZSTD_read_ARCH(const void* p) { size_t r; memcpy(&r, p, sizeof(r)); return r; }
|
2631
|
-
|
2632
|
-
MEM_STATIC unsigned ZSTD_NbCommonBytes (register size_t val)
|
2633
|
-
{
|
2634
|
-
if (MEM_isLittleEndian())
|
2635
|
-
{
|
2636
|
-
if (MEM_64bits())
|
2637
|
-
{
|
2638
|
-
# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2639
|
-
unsigned long r = 0;
|
2640
|
-
_BitScanForward64( &r, (U64)val );
|
2641
|
-
return (int)(r>>3);
|
2642
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2643
|
-
return (__builtin_ctzll((U64)val) >> 3);
|
2644
|
-
# else
|
2645
|
-
static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
|
2646
|
-
return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
|
2647
|
-
# endif
|
2648
|
-
}
|
2649
|
-
else /* 32 bits */
|
2650
|
-
{
|
2651
|
-
# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2652
|
-
unsigned long r;
|
2653
|
-
_BitScanForward( &r, (U32)val );
|
2654
|
-
return (int)(r>>3);
|
2655
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2656
|
-
return (__builtin_ctz((U32)val) >> 3);
|
2657
|
-
# else
|
2658
|
-
static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
|
2659
|
-
return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
|
2660
|
-
# endif
|
2661
|
-
}
|
2662
|
-
}
|
2663
|
-
else /* Big Endian CPU */
|
2664
|
-
{
|
2665
|
-
if (MEM_32bits())
|
2666
|
-
{
|
2667
|
-
# if defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2668
|
-
unsigned long r = 0;
|
2669
|
-
_BitScanReverse64( &r, val );
|
2670
|
-
return (unsigned)(r>>3);
|
2671
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2672
|
-
return (__builtin_clzll(val) >> 3);
|
2673
|
-
# else
|
2674
|
-
unsigned r;
|
2675
|
-
const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
|
2676
|
-
if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
|
2677
|
-
if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
|
2678
|
-
r += (!val);
|
2679
|
-
return r;
|
2680
|
-
# endif
|
2681
|
-
}
|
2682
|
-
else /* 32 bits */
|
2683
|
-
{
|
2684
|
-
# if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2685
|
-
unsigned long r = 0;
|
2686
|
-
_BitScanReverse( &r, (unsigned long)val );
|
2687
|
-
return (unsigned)(r>>3);
|
2688
|
-
# elif defined(__GNUC__) && (__GNUC__ >= 3) && !defined(LZ4_FORCE_SW_BITCOUNT)
|
2689
|
-
return (__builtin_clz((U32)val) >> 3);
|
2690
|
-
# else
|
2691
|
-
unsigned r;
|
2692
|
-
if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
|
2693
|
-
r += (!val);
|
2694
|
-
return r;
|
2695
|
-
# endif
|
2696
|
-
}
|
2697
|
-
}
|
2698
|
-
}
|
2699
|
-
|
2700
|
-
|
2701
|
-
MEM_STATIC size_t ZSTD_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLimit)
|
2702
|
-
{
|
2703
|
-
const BYTE* const pStart = pIn;
|
2704
|
-
|
2705
|
-
while ((pIn<pInLimit-(sizeof(size_t)-1)))
|
2706
|
-
{
|
2707
|
-
size_t diff = ZSTD_read_ARCH(pMatch) ^ ZSTD_read_ARCH(pIn);
|
2708
|
-
if (!diff) { pIn+=sizeof(size_t); pMatch+=sizeof(size_t); continue; }
|
2709
|
-
pIn += ZSTD_NbCommonBytes(diff);
|
2710
|
-
return (size_t)(pIn - pStart);
|
2711
|
-
}
|
2712
|
-
|
2713
|
-
if (MEM_32bits()) if ((pIn<(pInLimit-3)) && (MEM_read32(pMatch) == MEM_read32(pIn))) { pIn+=4; pMatch+=4; }
|
2714
|
-
if ((pIn<(pInLimit-1)) && (MEM_read16(pMatch) == MEM_read16(pIn))) { pIn+=2; pMatch+=2; }
|
2715
|
-
if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
|
2716
|
-
return (size_t)(pIn - pStart);
|
2717
|
-
}
|
2718
|
-
|
2719
2497
|
|
2720
2498
|
/* *************************************************************
|
2721
2499
|
* Decompression section
|
@@ -2885,7 +2663,6 @@ static size_t ZSTD_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t* d
|
|
2885
2663
|
/* Build DTables */
|
2886
2664
|
switch(LLtype)
|
2887
2665
|
{
|
2888
|
-
U32 max;
|
2889
2666
|
case bt_rle :
|
2890
2667
|
LLlog = 0;
|
2891
2668
|
FSE_buildDTable_rle(DTableLL, *ip++); break;
|
@@ -2893,17 +2670,16 @@ static size_t ZSTD_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t* d
|
|
2893
2670
|
LLlog = LLbits;
|
2894
2671
|
FSE_buildDTable_raw(DTableLL, LLbits); break;
|
2895
2672
|
default :
|
2896
|
-
max = MaxLL;
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
}
|
2673
|
+
{ U32 max = MaxLL;
|
2674
|
+
headerSize = FSE_readNCount(norm, &max, &LLlog, ip, iend-ip);
|
2675
|
+
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
2676
|
+
if (LLlog > LLFSELog) return ERROR(corruption_detected);
|
2677
|
+
ip += headerSize;
|
2678
|
+
FSE_buildDTable(DTableLL, norm, max, LLlog);
|
2679
|
+
} }
|
2903
2680
|
|
2904
2681
|
switch(Offtype)
|
2905
2682
|
{
|
2906
|
-
U32 max;
|
2907
2683
|
case bt_rle :
|
2908
2684
|
Offlog = 0;
|
2909
2685
|
if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */
|
@@ -2913,17 +2689,16 @@ static size_t ZSTD_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t* d
|
|
2913
2689
|
Offlog = Offbits;
|
2914
2690
|
FSE_buildDTable_raw(DTableOffb, Offbits); break;
|
2915
2691
|
default :
|
2916
|
-
max = MaxOff;
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
}
|
2692
|
+
{ U32 max = MaxOff;
|
2693
|
+
headerSize = FSE_readNCount(norm, &max, &Offlog, ip, iend-ip);
|
2694
|
+
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
2695
|
+
if (Offlog > OffFSELog) return ERROR(corruption_detected);
|
2696
|
+
ip += headerSize;
|
2697
|
+
FSE_buildDTable(DTableOffb, norm, max, Offlog);
|
2698
|
+
} }
|
2923
2699
|
|
2924
2700
|
switch(MLtype)
|
2925
2701
|
{
|
2926
|
-
U32 max;
|
2927
2702
|
case bt_rle :
|
2928
2703
|
MLlog = 0;
|
2929
2704
|
if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */
|
@@ -2932,14 +2707,13 @@ static size_t ZSTD_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t* d
|
|
2932
2707
|
MLlog = MLbits;
|
2933
2708
|
FSE_buildDTable_raw(DTableML, MLbits); break;
|
2934
2709
|
default :
|
2935
|
-
max = MaxML;
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
}
|
2710
|
+
{ U32 max = MaxML;
|
2711
|
+
headerSize = FSE_readNCount(norm, &max, &MLlog, ip, iend-ip);
|
2712
|
+
if (FSE_isError(headerSize)) return ERROR(GENERIC);
|
2713
|
+
if (MLlog > MLFSELog) return ERROR(corruption_detected);
|
2714
|
+
ip += headerSize;
|
2715
|
+
FSE_buildDTable(DTableML, norm, max, MLlog);
|
2716
|
+
} } }
|
2943
2717
|
|
2944
2718
|
return ip-istart;
|
2945
2719
|
}
|
@@ -1,36 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
+
*/
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
met:
|
11
|
-
* Redistributions of source code must retain the above copyright
|
12
|
-
notice, this list of conditions and the following disclaimer.
|
13
|
-
* Redistributions in binary form must reproduce the above
|
14
|
-
copyright notice, this list of conditions and the following disclaimer
|
15
|
-
in the documentation and/or other materials provided with the
|
16
|
-
distribution.
|
17
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
18
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
19
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
20
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
21
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
24
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
25
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
-
|
29
|
-
You can contact the author at :
|
30
|
-
- zstd source repository : https://github.com/Cyan4973/zstd
|
31
|
-
- ztsd public forum : https://groups.google.com/forum/#!forum/lz4c
|
32
|
-
*/
|
33
|
-
#pragma once
|
10
|
+
#ifndef ZSTD_V03_H_298734209782
|
11
|
+
#define ZSTD_V03_H_298734209782
|
34
12
|
|
35
13
|
#if defined (__cplusplus)
|
36
14
|
extern "C" {
|
@@ -97,3 +75,5 @@ size_t ZSTDv03_decompressContinue(ZSTDv03_Dctx* dctx, void* dst, size_t maxDstSi
|
|
97
75
|
#if defined (__cplusplus)
|
98
76
|
}
|
99
77
|
#endif
|
78
|
+
|
79
|
+
#endif /* ZSTD_V03_H_298734209782 */
|