zstdlib 0.13.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +6 -0
- data/CHANGES.md +107 -0
- data/Gemfile +3 -0
- data/README.md +107 -0
- data/Rakefile +59 -0
- data/ext/zstdlib_c/extconf.rb +59 -0
- data/ext/zstdlib_c/ruby/zlib-2.2/zstdlib.c +4675 -0
- data/ext/zstdlib_c/ruby/zlib-2.3/zstdlib.c +4702 -0
- data/ext/zstdlib_c/ruby/zlib-2.4/zstdlib.c +4859 -0
- data/ext/zstdlib_c/ruby/zlib-2.5/zstdlib.c +4864 -0
- data/ext/zstdlib_c/ruby/zlib-2.6/zstdlib.c +4906 -0
- data/ext/zstdlib_c/ruby/zlib-2.7/zstdlib.c +4895 -0
- data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/zstdlib_c/ruby/zlib-3.2/zstdlib.c +5090 -0
- data/ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c +5090 -0
- data/ext/zstdlib_c/zlib-1.3.1/adler32.c +164 -0
- data/ext/zstdlib_c/zlib-1.3.1/compress.c +75 -0
- data/ext/zstdlib_c/zlib-1.3.1/crc32.c +1049 -0
- data/ext/zstdlib_c/zlib-1.3.1/crc32.h +9446 -0
- data/ext/zstdlib_c/zlib-1.3.1/deflate.c +2139 -0
- data/ext/zstdlib_c/zlib-1.3.1/deflate.h +377 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzclose.c +23 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzguts.h +214 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzlib.c +582 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzread.c +602 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzwrite.c +631 -0
- data/ext/zstdlib_c/zlib-1.3.1/infback.c +628 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffast.c +320 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffast.h +11 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffixed.h +94 -0
- data/ext/zstdlib_c/zlib-1.3.1/inflate.c +1526 -0
- data/ext/zstdlib_c/zlib-1.3.1/inflate.h +126 -0
- data/ext/zstdlib_c/zlib-1.3.1/inftrees.c +299 -0
- data/ext/zstdlib_c/zlib-1.3.1/inftrees.h +62 -0
- data/ext/zstdlib_c/zlib-1.3.1/trees.c +1117 -0
- data/ext/zstdlib_c/zlib-1.3.1/trees.h +128 -0
- data/ext/zstdlib_c/zlib-1.3.1/uncompr.c +85 -0
- data/ext/zstdlib_c/zlib-1.3.1/zconf.h +543 -0
- data/ext/zstdlib_c/zlib-1.3.1/zlib.h +1938 -0
- data/ext/zstdlib_c/zlib-1.3.1/zutil.c +299 -0
- data/ext/zstdlib_c/zlib-1.3.1/zutil.h +254 -0
- data/ext/zstdlib_c/zlib.mk +14 -0
- data/ext/zstdlib_c/zlibwrapper/zlibwrapper.c +10 -0
- data/ext/zstdlib_c/zlibwrapper.mk +14 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/allocations.h +55 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/bits.h +200 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/bitstream.h +457 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/compiler.h +450 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/cpu.h +249 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/debug.c +30 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/debug.h +116 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/entropy_common.c +340 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/error_private.c +63 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/error_private.h +168 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/fse.h +640 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/fse_decompress.c +313 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/huf.h +286 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/mem.h +426 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/pool.c +371 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/pool.h +90 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/portability_macros.h +158 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/threading.c +182 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/threading.h +150 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/xxhash.c +18 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/xxhash.h +7020 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_common.c +48 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_deps.h +111 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_internal.h +392 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/clevels.h +134 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/fse_compress.c +625 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/hist.c +181 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/hist.h +75 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/huf_compress.c +1464 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress.c +7153 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_internal.h +1534 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_literals.c +235 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_literals.h +39 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_sequences.c +442 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_sequences.h +54 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_superblock.c +688 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_cwksp.h +748 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_double_fast.c +770 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_double_fast.h +50 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_fast.c +968 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_fast.h +38 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_lazy.c +2199 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_lazy.h +202 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm.c +730 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm.h +117 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_opt.c +1576 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_opt.h +80 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstdmt_compress.c +1882 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstdmt_compress.h +113 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/huf_decompress.c +1944 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/huf_decompress_amd64.S +595 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_ddict.c +244 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_ddict.h +44 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress.c +2407 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_block.c +2215 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_block.h +73 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_internal.h +240 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zdict.h +474 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zstd.h +3089 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zstd_errors.h +114 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzclose.c +26 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzcompatibility.h +68 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzguts.h +229 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzlib.c +587 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzread.c +637 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzwrite.c +631 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/zstd_zlibwrapper.c +1200 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/zstd_zlibwrapper.h +91 -0
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/2.4/zstdlib_c.so +0 -0
- data/lib/2.5/zstdlib_c.so +0 -0
- data/lib/2.6/zstdlib_c.so +0 -0
- data/lib/2.7/zstdlib_c.so +0 -0
- data/lib/3.0/zstdlib_c.so +0 -0
- data/lib/3.1/zstdlib_c.so +0 -0
- data/lib/3.2/zstdlib_c.so +0 -0
- data/lib/3.3/zstdlib_c.so +0 -0
- data/lib/zstdlib.rb +6 -0
- data/test/zstdlib_test.rb +21 -0
- metadata +243 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
2
|
+
* Copyright (C) 1995-2011, 2016 Mark Adler
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* @(#) $Id$ */
|
7
|
+
|
8
|
+
#include "zutil.h"
|
9
|
+
|
10
|
+
#define BASE 65521U /* largest prime smaller than 65536 */
|
11
|
+
#define NMAX 5552
|
12
|
+
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
13
|
+
|
14
|
+
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
15
|
+
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
16
|
+
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
17
|
+
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
18
|
+
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
19
|
+
|
20
|
+
/* use NO_DIVIDE if your processor does not do division in hardware --
|
21
|
+
try it both ways to see which is faster */
|
22
|
+
#ifdef NO_DIVIDE
|
23
|
+
/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
|
24
|
+
(thank you to John Reiser for pointing this out) */
|
25
|
+
# define CHOP(a) \
|
26
|
+
do { \
|
27
|
+
unsigned long tmp = a >> 16; \
|
28
|
+
a &= 0xffffUL; \
|
29
|
+
a += (tmp << 4) - tmp; \
|
30
|
+
} while (0)
|
31
|
+
# define MOD28(a) \
|
32
|
+
do { \
|
33
|
+
CHOP(a); \
|
34
|
+
if (a >= BASE) a -= BASE; \
|
35
|
+
} while (0)
|
36
|
+
# define MOD(a) \
|
37
|
+
do { \
|
38
|
+
CHOP(a); \
|
39
|
+
MOD28(a); \
|
40
|
+
} while (0)
|
41
|
+
# define MOD63(a) \
|
42
|
+
do { /* this assumes a is not negative */ \
|
43
|
+
z_off64_t tmp = a >> 32; \
|
44
|
+
a &= 0xffffffffL; \
|
45
|
+
a += (tmp << 8) - (tmp << 5) + tmp; \
|
46
|
+
tmp = a >> 16; \
|
47
|
+
a &= 0xffffL; \
|
48
|
+
a += (tmp << 4) - tmp; \
|
49
|
+
tmp = a >> 16; \
|
50
|
+
a &= 0xffffL; \
|
51
|
+
a += (tmp << 4) - tmp; \
|
52
|
+
if (a >= BASE) a -= BASE; \
|
53
|
+
} while (0)
|
54
|
+
#else
|
55
|
+
# define MOD(a) a %= BASE
|
56
|
+
# define MOD28(a) a %= BASE
|
57
|
+
# define MOD63(a) a %= BASE
|
58
|
+
#endif
|
59
|
+
|
60
|
+
/* ========================================================================= */
|
61
|
+
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
62
|
+
unsigned long sum2;
|
63
|
+
unsigned n;
|
64
|
+
|
65
|
+
/* split Adler-32 into component sums */
|
66
|
+
sum2 = (adler >> 16) & 0xffff;
|
67
|
+
adler &= 0xffff;
|
68
|
+
|
69
|
+
/* in case user likes doing a byte at a time, keep it fast */
|
70
|
+
if (len == 1) {
|
71
|
+
adler += buf[0];
|
72
|
+
if (adler >= BASE)
|
73
|
+
adler -= BASE;
|
74
|
+
sum2 += adler;
|
75
|
+
if (sum2 >= BASE)
|
76
|
+
sum2 -= BASE;
|
77
|
+
return adler | (sum2 << 16);
|
78
|
+
}
|
79
|
+
|
80
|
+
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
81
|
+
if (buf == Z_NULL)
|
82
|
+
return 1L;
|
83
|
+
|
84
|
+
/* in case short lengths are provided, keep it somewhat fast */
|
85
|
+
if (len < 16) {
|
86
|
+
while (len--) {
|
87
|
+
adler += *buf++;
|
88
|
+
sum2 += adler;
|
89
|
+
}
|
90
|
+
if (adler >= BASE)
|
91
|
+
adler -= BASE;
|
92
|
+
MOD28(sum2); /* only added so many BASE's */
|
93
|
+
return adler | (sum2 << 16);
|
94
|
+
}
|
95
|
+
|
96
|
+
/* do length NMAX blocks -- requires just one modulo operation */
|
97
|
+
while (len >= NMAX) {
|
98
|
+
len -= NMAX;
|
99
|
+
n = NMAX / 16; /* NMAX is divisible by 16 */
|
100
|
+
do {
|
101
|
+
DO16(buf); /* 16 sums unrolled */
|
102
|
+
buf += 16;
|
103
|
+
} while (--n);
|
104
|
+
MOD(adler);
|
105
|
+
MOD(sum2);
|
106
|
+
}
|
107
|
+
|
108
|
+
/* do remaining bytes (less than NMAX, still just one modulo) */
|
109
|
+
if (len) { /* avoid modulos if none remaining */
|
110
|
+
while (len >= 16) {
|
111
|
+
len -= 16;
|
112
|
+
DO16(buf);
|
113
|
+
buf += 16;
|
114
|
+
}
|
115
|
+
while (len--) {
|
116
|
+
adler += *buf++;
|
117
|
+
sum2 += adler;
|
118
|
+
}
|
119
|
+
MOD(adler);
|
120
|
+
MOD(sum2);
|
121
|
+
}
|
122
|
+
|
123
|
+
/* return recombined sums */
|
124
|
+
return adler | (sum2 << 16);
|
125
|
+
}
|
126
|
+
|
127
|
+
/* ========================================================================= */
|
128
|
+
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
129
|
+
return adler32_z(adler, buf, len);
|
130
|
+
}
|
131
|
+
|
132
|
+
/* ========================================================================= */
|
133
|
+
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
134
|
+
unsigned long sum1;
|
135
|
+
unsigned long sum2;
|
136
|
+
unsigned rem;
|
137
|
+
|
138
|
+
/* for negative len, return invalid adler32 as a clue for debugging */
|
139
|
+
if (len2 < 0)
|
140
|
+
return 0xffffffffUL;
|
141
|
+
|
142
|
+
/* the derivation of this formula is left as an exercise for the reader */
|
143
|
+
MOD63(len2); /* assumes len2 >= 0 */
|
144
|
+
rem = (unsigned)len2;
|
145
|
+
sum1 = adler1 & 0xffff;
|
146
|
+
sum2 = rem * sum1;
|
147
|
+
MOD(sum2);
|
148
|
+
sum1 += (adler2 & 0xffff) + BASE - 1;
|
149
|
+
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
150
|
+
if (sum1 >= BASE) sum1 -= BASE;
|
151
|
+
if (sum1 >= BASE) sum1 -= BASE;
|
152
|
+
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
|
153
|
+
if (sum2 >= BASE) sum2 -= BASE;
|
154
|
+
return sum1 | (sum2 << 16);
|
155
|
+
}
|
156
|
+
|
157
|
+
/* ========================================================================= */
|
158
|
+
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
|
159
|
+
return adler32_combine_(adler1, adler2, len2);
|
160
|
+
}
|
161
|
+
|
162
|
+
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
|
163
|
+
return adler32_combine_(adler1, adler2, len2);
|
164
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/* compress.c -- compress a memory buffer
|
2
|
+
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* @(#) $Id$ */
|
7
|
+
|
8
|
+
#define ZLIB_INTERNAL
|
9
|
+
#include "zlib.h"
|
10
|
+
|
11
|
+
/* ===========================================================================
|
12
|
+
Compresses the source buffer into the destination buffer. The level
|
13
|
+
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
14
|
+
length of the source buffer. Upon entry, destLen is the total size of the
|
15
|
+
destination buffer, which must be at least 0.1% larger than sourceLen plus
|
16
|
+
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
17
|
+
|
18
|
+
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
19
|
+
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
20
|
+
Z_STREAM_ERROR if the level parameter is invalid.
|
21
|
+
*/
|
22
|
+
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
23
|
+
uLong sourceLen, int level) {
|
24
|
+
z_stream stream;
|
25
|
+
int err;
|
26
|
+
const uInt max = (uInt)-1;
|
27
|
+
uLong left;
|
28
|
+
|
29
|
+
left = *destLen;
|
30
|
+
*destLen = 0;
|
31
|
+
|
32
|
+
stream.zalloc = (alloc_func)0;
|
33
|
+
stream.zfree = (free_func)0;
|
34
|
+
stream.opaque = (voidpf)0;
|
35
|
+
|
36
|
+
err = deflateInit(&stream, level);
|
37
|
+
if (err != Z_OK) return err;
|
38
|
+
|
39
|
+
stream.next_out = dest;
|
40
|
+
stream.avail_out = 0;
|
41
|
+
stream.next_in = (z_const Bytef *)source;
|
42
|
+
stream.avail_in = 0;
|
43
|
+
|
44
|
+
do {
|
45
|
+
if (stream.avail_out == 0) {
|
46
|
+
stream.avail_out = left > (uLong)max ? max : (uInt)left;
|
47
|
+
left -= stream.avail_out;
|
48
|
+
}
|
49
|
+
if (stream.avail_in == 0) {
|
50
|
+
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
|
51
|
+
sourceLen -= stream.avail_in;
|
52
|
+
}
|
53
|
+
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
|
54
|
+
} while (err == Z_OK);
|
55
|
+
|
56
|
+
*destLen = stream.total_out;
|
57
|
+
deflateEnd(&stream);
|
58
|
+
return err == Z_STREAM_END ? Z_OK : err;
|
59
|
+
}
|
60
|
+
|
61
|
+
/* ===========================================================================
|
62
|
+
*/
|
63
|
+
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
64
|
+
uLong sourceLen) {
|
65
|
+
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
66
|
+
}
|
67
|
+
|
68
|
+
/* ===========================================================================
|
69
|
+
If the default memLevel or windowBits for deflateInit() is changed, then
|
70
|
+
this function needs to be updated.
|
71
|
+
*/
|
72
|
+
uLong ZEXPORT compressBound(uLong sourceLen) {
|
73
|
+
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
74
|
+
(sourceLen >> 25) + 13;
|
75
|
+
}
|