zstdlib 0.11.0-x64-mingw32 → 0.12.0-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +9 -0
- data/ext/zstdlib_c/extconf.rb +8 -3
- data/ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c +5090 -0
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/adler32.c +5 -27
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/compress.c +5 -16
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/crc32.c +94 -161
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/deflate.c +362 -434
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/deflate.h +43 -12
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzclose.c +1 -3
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzguts.h +13 -18
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzlib.c +28 -85
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzread.c +23 -73
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/gzwrite.c +19 -65
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/infback.c +17 -30
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffast.c +1 -4
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffast.h +1 -1
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inflate.c +36 -102
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inftrees.c +6 -11
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inftrees.h +6 -6
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/trees.c +290 -355
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/uncompr.c +4 -12
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zconf.h +23 -14
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zlib.h +202 -199
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zutil.c +18 -44
- data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/zutil.h +13 -33
- 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
- metadata +32 -31
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/crc32.h +0 -0
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inffixed.h +0 -0
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/inflate.h +0 -0
- /data/ext/zstdlib_c/{zlib-1.2.12 → zlib-1.3.1}/trees.h +0 -0
@@ -7,8 +7,6 @@
|
|
7
7
|
|
8
8
|
#include "zutil.h"
|
9
9
|
|
10
|
-
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
11
|
-
|
12
10
|
#define BASE 65521U /* largest prime smaller than 65536 */
|
13
11
|
#define NMAX 5552
|
14
12
|
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
@@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
|
|
60
58
|
#endif
|
61
59
|
|
62
60
|
/* ========================================================================= */
|
63
|
-
uLong ZEXPORT adler32_z(adler, buf, len)
|
64
|
-
uLong adler;
|
65
|
-
const Bytef *buf;
|
66
|
-
z_size_t len;
|
67
|
-
{
|
61
|
+
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
68
62
|
unsigned long sum2;
|
69
63
|
unsigned n;
|
70
64
|
|
@@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len)
|
|
131
125
|
}
|
132
126
|
|
133
127
|
/* ========================================================================= */
|
134
|
-
uLong ZEXPORT adler32(adler, buf, len)
|
135
|
-
uLong adler;
|
136
|
-
const Bytef *buf;
|
137
|
-
uInt len;
|
138
|
-
{
|
128
|
+
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
139
129
|
return adler32_z(adler, buf, len);
|
140
130
|
}
|
141
131
|
|
142
132
|
/* ========================================================================= */
|
143
|
-
local uLong adler32_combine_(adler1, adler2, len2)
|
144
|
-
uLong adler1;
|
145
|
-
uLong adler2;
|
146
|
-
z_off64_t len2;
|
147
|
-
{
|
133
|
+
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
148
134
|
unsigned long sum1;
|
149
135
|
unsigned long sum2;
|
150
136
|
unsigned rem;
|
@@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2)
|
|
169
155
|
}
|
170
156
|
|
171
157
|
/* ========================================================================= */
|
172
|
-
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
173
|
-
uLong adler1;
|
174
|
-
uLong adler2;
|
175
|
-
z_off_t len2;
|
176
|
-
{
|
158
|
+
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
|
177
159
|
return adler32_combine_(adler1, adler2, len2);
|
178
160
|
}
|
179
161
|
|
180
|
-
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
|
181
|
-
uLong adler1;
|
182
|
-
uLong adler2;
|
183
|
-
z_off64_t len2;
|
184
|
-
{
|
162
|
+
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
|
185
163
|
return adler32_combine_(adler1, adler2, len2);
|
186
164
|
}
|
@@ -19,13 +19,8 @@
|
|
19
19
|
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
20
20
|
Z_STREAM_ERROR if the level parameter is invalid.
|
21
21
|
*/
|
22
|
-
int ZEXPORT compress2
|
23
|
-
|
24
|
-
uLongf *destLen;
|
25
|
-
const Bytef *source;
|
26
|
-
uLong sourceLen;
|
27
|
-
int level;
|
28
|
-
{
|
22
|
+
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
23
|
+
uLong sourceLen, int level) {
|
29
24
|
z_stream stream;
|
30
25
|
int err;
|
31
26
|
const uInt max = (uInt)-1;
|
@@ -65,12 +60,8 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
|
65
60
|
|
66
61
|
/* ===========================================================================
|
67
62
|
*/
|
68
|
-
int ZEXPORT compress
|
69
|
-
|
70
|
-
uLongf *destLen;
|
71
|
-
const Bytef *source;
|
72
|
-
uLong sourceLen;
|
73
|
-
{
|
63
|
+
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
64
|
+
uLong sourceLen) {
|
74
65
|
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
75
66
|
}
|
76
67
|
|
@@ -78,9 +69,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
|
|
78
69
|
If the default memLevel or windowBits for deflateInit() is changed, then
|
79
70
|
this function needs to be updated.
|
80
71
|
*/
|
81
|
-
uLong ZEXPORT compressBound
|
82
|
-
uLong sourceLen;
|
83
|
-
{
|
72
|
+
uLong ZEXPORT compressBound(uLong sourceLen) {
|
84
73
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
85
74
|
(sourceLen >> 25) + 13;
|
86
75
|
}
|
@@ -98,10 +98,6 @@
|
|
98
98
|
# endif
|
99
99
|
#endif
|
100
100
|
|
101
|
-
/* Local functions. */
|
102
|
-
local z_crc_t multmodp OF((z_crc_t a, z_crc_t b));
|
103
|
-
local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
|
104
|
-
|
105
101
|
/* If available, use the ARM processor CRC32 instruction. */
|
106
102
|
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8
|
107
103
|
# define ARMCRC32
|
@@ -114,9 +110,7 @@ local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
|
|
114
110
|
instruction, if one is available. This assumes that word_t is either 32 bits
|
115
111
|
or 64 bits.
|
116
112
|
*/
|
117
|
-
local z_word_t byte_swap(word)
|
118
|
-
z_word_t word;
|
119
|
-
{
|
113
|
+
local z_word_t byte_swap(z_word_t word) {
|
120
114
|
# if W == 8
|
121
115
|
return
|
122
116
|
(word & 0xff00000000000000) >> 56 |
|
@@ -137,24 +131,77 @@ local z_word_t byte_swap(word)
|
|
137
131
|
}
|
138
132
|
#endif
|
139
133
|
|
134
|
+
#ifdef DYNAMIC_CRC_TABLE
|
135
|
+
/* =========================================================================
|
136
|
+
* Table of powers of x for combining CRC-32s, filled in by make_crc_table()
|
137
|
+
* below.
|
138
|
+
*/
|
139
|
+
local z_crc_t FAR x2n_table[32];
|
140
|
+
#else
|
141
|
+
/* =========================================================================
|
142
|
+
* Tables for byte-wise and braided CRC-32 calculations, and a table of powers
|
143
|
+
* of x for combining CRC-32s, all made by make_crc_table().
|
144
|
+
*/
|
145
|
+
# include "crc32.h"
|
146
|
+
#endif
|
147
|
+
|
140
148
|
/* CRC polynomial. */
|
141
149
|
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
|
142
150
|
|
143
|
-
|
151
|
+
/*
|
152
|
+
Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
|
153
|
+
reflected. For speed, this requires that a not be zero.
|
154
|
+
*/
|
155
|
+
local z_crc_t multmodp(z_crc_t a, z_crc_t b) {
|
156
|
+
z_crc_t m, p;
|
157
|
+
|
158
|
+
m = (z_crc_t)1 << 31;
|
159
|
+
p = 0;
|
160
|
+
for (;;) {
|
161
|
+
if (a & m) {
|
162
|
+
p ^= b;
|
163
|
+
if ((a & (m - 1)) == 0)
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
m >>= 1;
|
167
|
+
b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
|
168
|
+
}
|
169
|
+
return p;
|
170
|
+
}
|
171
|
+
|
172
|
+
/*
|
173
|
+
Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
|
174
|
+
initialized.
|
175
|
+
*/
|
176
|
+
local z_crc_t x2nmodp(z_off64_t n, unsigned k) {
|
177
|
+
z_crc_t p;
|
178
|
+
|
179
|
+
p = (z_crc_t)1 << 31; /* x^0 == 1 */
|
180
|
+
while (n) {
|
181
|
+
if (n & 1)
|
182
|
+
p = multmodp(x2n_table[k & 31], p);
|
183
|
+
n >>= 1;
|
184
|
+
k++;
|
185
|
+
}
|
186
|
+
return p;
|
187
|
+
}
|
144
188
|
|
189
|
+
#ifdef DYNAMIC_CRC_TABLE
|
190
|
+
/* =========================================================================
|
191
|
+
* Build the tables for byte-wise and braided CRC-32 calculations, and a table
|
192
|
+
* of powers of x for combining CRC-32s.
|
193
|
+
*/
|
145
194
|
local z_crc_t FAR crc_table[256];
|
146
|
-
local z_crc_t FAR x2n_table[32];
|
147
|
-
local void make_crc_table OF((void));
|
148
195
|
#ifdef W
|
149
196
|
local z_word_t FAR crc_big_table[256];
|
150
197
|
local z_crc_t FAR crc_braid_table[W][256];
|
151
198
|
local z_word_t FAR crc_braid_big_table[W][256];
|
152
|
-
local void braid
|
199
|
+
local void braid(z_crc_t [][256], z_word_t [][256], int, int);
|
153
200
|
#endif
|
154
201
|
#ifdef MAKECRCH
|
155
|
-
local void write_table
|
156
|
-
local void write_table32hi
|
157
|
-
local void write_table64
|
202
|
+
local void write_table(FILE *, const z_crc_t FAR *, int);
|
203
|
+
local void write_table32hi(FILE *, const z_word_t FAR *, int);
|
204
|
+
local void write_table64(FILE *, const z_word_t FAR *, int);
|
158
205
|
#endif /* MAKECRCH */
|
159
206
|
|
160
207
|
/*
|
@@ -167,7 +214,6 @@ local void make_crc_table OF((void));
|
|
167
214
|
|
168
215
|
/* Definition of once functionality. */
|
169
216
|
typedef struct once_s once_t;
|
170
|
-
local void once OF((once_t *, void (*)(void)));
|
171
217
|
|
172
218
|
/* Check for the availability of atomics. */
|
173
219
|
#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \
|
@@ -187,10 +233,7 @@ struct once_s {
|
|
187
233
|
invoke once() at the same time. The state must be a once_t initialized with
|
188
234
|
ONCE_INIT.
|
189
235
|
*/
|
190
|
-
local void once(state, init)
|
191
|
-
once_t *state;
|
192
|
-
void (*init)(void);
|
193
|
-
{
|
236
|
+
local void once(once_t *state, void (*init)(void)) {
|
194
237
|
if (!atomic_load(&state->done)) {
|
195
238
|
if (atomic_flag_test_and_set(&state->begun))
|
196
239
|
while (!atomic_load(&state->done))
|
@@ -213,10 +256,7 @@ struct once_s {
|
|
213
256
|
|
214
257
|
/* Test and set. Alas, not atomic, but tries to minimize the period of
|
215
258
|
vulnerability. */
|
216
|
-
local int test_and_set
|
217
|
-
local int test_and_set(flag)
|
218
|
-
int volatile *flag;
|
219
|
-
{
|
259
|
+
local int test_and_set(int volatile *flag) {
|
220
260
|
int was;
|
221
261
|
|
222
262
|
was = *flag;
|
@@ -225,10 +265,7 @@ local int test_and_set(flag)
|
|
225
265
|
}
|
226
266
|
|
227
267
|
/* Run the provided init() function once. This is not thread-safe. */
|
228
|
-
local void once(state, init)
|
229
|
-
once_t *state;
|
230
|
-
void (*init)(void);
|
231
|
-
{
|
268
|
+
local void once(once_t *state, void (*init)(void)) {
|
232
269
|
if (!state->done) {
|
233
270
|
if (test_and_set(&state->begun))
|
234
271
|
while (!state->done)
|
@@ -270,8 +307,7 @@ local once_t made = ONCE_INIT;
|
|
270
307
|
combinations of CRC register values and incoming bytes.
|
271
308
|
*/
|
272
309
|
|
273
|
-
local void make_crc_table()
|
274
|
-
{
|
310
|
+
local void make_crc_table(void) {
|
275
311
|
unsigned i, j, n;
|
276
312
|
z_crc_t p;
|
277
313
|
|
@@ -438,11 +474,7 @@ local void make_crc_table()
|
|
438
474
|
Write the 32-bit values in table[0..k-1] to out, five per line in
|
439
475
|
hexadecimal separated by commas.
|
440
476
|
*/
|
441
|
-
local void write_table(out, table, k)
|
442
|
-
FILE *out;
|
443
|
-
const z_crc_t FAR *table;
|
444
|
-
int k;
|
445
|
-
{
|
477
|
+
local void write_table(FILE *out, const z_crc_t FAR *table, int k) {
|
446
478
|
int n;
|
447
479
|
|
448
480
|
for (n = 0; n < k; n++)
|
@@ -455,11 +487,7 @@ local void write_table(out, table, k)
|
|
455
487
|
Write the high 32-bits of each value in table[0..k-1] to out, five per line
|
456
488
|
in hexadecimal separated by commas.
|
457
489
|
*/
|
458
|
-
local void write_table32hi(out, table, k)
|
459
|
-
FILE *out;
|
460
|
-
const z_word_t FAR *table;
|
461
|
-
int k;
|
462
|
-
{
|
490
|
+
local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) {
|
463
491
|
int n;
|
464
492
|
|
465
493
|
for (n = 0; n < k; n++)
|
@@ -475,11 +503,7 @@ int k;
|
|
475
503
|
bits. If not, then the type cast and format string can be adjusted
|
476
504
|
accordingly.
|
477
505
|
*/
|
478
|
-
local void write_table64(out, table, k)
|
479
|
-
FILE *out;
|
480
|
-
const z_word_t FAR *table;
|
481
|
-
int k;
|
482
|
-
{
|
506
|
+
local void write_table64(FILE *out, const z_word_t FAR *table, int k) {
|
483
507
|
int n;
|
484
508
|
|
485
509
|
for (n = 0; n < k; n++)
|
@@ -489,8 +513,7 @@ local void write_table64(out, table, k)
|
|
489
513
|
}
|
490
514
|
|
491
515
|
/* Actually do the deed. */
|
492
|
-
int main()
|
493
|
-
{
|
516
|
+
int main(void) {
|
494
517
|
make_crc_table();
|
495
518
|
return 0;
|
496
519
|
}
|
@@ -502,12 +525,7 @@ int main()
|
|
502
525
|
Generate the little and big-endian braid tables for the given n and z_word_t
|
503
526
|
size w. Each array must have room for w blocks of 256 elements.
|
504
527
|
*/
|
505
|
-
local void braid(ltl, big, n, w)
|
506
|
-
z_crc_t ltl[][256];
|
507
|
-
z_word_t big[][256];
|
508
|
-
int n;
|
509
|
-
int w;
|
510
|
-
{
|
528
|
+
local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
|
511
529
|
int k;
|
512
530
|
z_crc_t i, p, q;
|
513
531
|
for (k = 0; k < w; k++) {
|
@@ -522,69 +540,13 @@ local void braid(ltl, big, n, w)
|
|
522
540
|
}
|
523
541
|
#endif
|
524
542
|
|
525
|
-
#else /* !DYNAMIC_CRC_TABLE */
|
526
|
-
/* ========================================================================
|
527
|
-
* Tables for byte-wise and braided CRC-32 calculations, and a table of powers
|
528
|
-
* of x for combining CRC-32s, all made by make_crc_table().
|
529
|
-
*/
|
530
|
-
#include "crc32.h"
|
531
543
|
#endif /* DYNAMIC_CRC_TABLE */
|
532
544
|
|
533
|
-
/* ========================================================================
|
534
|
-
* Routines used for CRC calculation. Some are also required for the table
|
535
|
-
* generation above.
|
536
|
-
*/
|
537
|
-
|
538
|
-
/*
|
539
|
-
Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
|
540
|
-
reflected. For speed, this requires that a not be zero.
|
541
|
-
*/
|
542
|
-
local z_crc_t multmodp(a, b)
|
543
|
-
z_crc_t a;
|
544
|
-
z_crc_t b;
|
545
|
-
{
|
546
|
-
z_crc_t m, p;
|
547
|
-
|
548
|
-
m = (z_crc_t)1 << 31;
|
549
|
-
p = 0;
|
550
|
-
for (;;) {
|
551
|
-
if (a & m) {
|
552
|
-
p ^= b;
|
553
|
-
if ((a & (m - 1)) == 0)
|
554
|
-
break;
|
555
|
-
}
|
556
|
-
m >>= 1;
|
557
|
-
b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
|
558
|
-
}
|
559
|
-
return p;
|
560
|
-
}
|
561
|
-
|
562
|
-
/*
|
563
|
-
Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
|
564
|
-
initialized.
|
565
|
-
*/
|
566
|
-
local z_crc_t x2nmodp(n, k)
|
567
|
-
z_off64_t n;
|
568
|
-
unsigned k;
|
569
|
-
{
|
570
|
-
z_crc_t p;
|
571
|
-
|
572
|
-
p = (z_crc_t)1 << 31; /* x^0 == 1 */
|
573
|
-
while (n) {
|
574
|
-
if (n & 1)
|
575
|
-
p = multmodp(x2n_table[k & 31], p);
|
576
|
-
n >>= 1;
|
577
|
-
k++;
|
578
|
-
}
|
579
|
-
return p;
|
580
|
-
}
|
581
|
-
|
582
545
|
/* =========================================================================
|
583
546
|
* This function can be used by asm versions of crc32(), and to force the
|
584
547
|
* generation of the CRC tables in a threaded application.
|
585
548
|
*/
|
586
|
-
const z_crc_t FAR * ZEXPORT get_crc_table()
|
587
|
-
{
|
549
|
+
const z_crc_t FAR * ZEXPORT get_crc_table(void) {
|
588
550
|
#ifdef DYNAMIC_CRC_TABLE
|
589
551
|
once(&made, make_crc_table);
|
590
552
|
#endif /* DYNAMIC_CRC_TABLE */
|
@@ -610,11 +572,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
|
|
610
572
|
#define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */
|
611
573
|
#define Z_BATCH_MIN 800 /* fewest words in a final batch */
|
612
574
|
|
613
|
-
unsigned long ZEXPORT crc32_z(crc, buf,
|
614
|
-
|
615
|
-
const unsigned char FAR *buf;
|
616
|
-
z_size_t len;
|
617
|
-
{
|
575
|
+
unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
|
576
|
+
z_size_t len) {
|
618
577
|
z_crc_t val;
|
619
578
|
z_word_t crc1, crc2;
|
620
579
|
const z_word_t *word;
|
@@ -630,7 +589,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
|
|
630
589
|
#endif /* DYNAMIC_CRC_TABLE */
|
631
590
|
|
632
591
|
/* Pre-condition the CRC */
|
633
|
-
crc
|
592
|
+
crc = (~crc) & 0xffffffff;
|
634
593
|
|
635
594
|
/* Compute the CRC up to a word boundary. */
|
636
595
|
while (len && ((z_size_t)buf & 7) != 0) {
|
@@ -645,8 +604,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
|
|
645
604
|
len &= 7;
|
646
605
|
|
647
606
|
/* Do three interleaved CRCs to realize the throughput of one crc32x
|
648
|
-
instruction per cycle. Each CRC is
|
649
|
-
CRCs are combined into a single CRC after each set of batches. */
|
607
|
+
instruction per cycle. Each CRC is calculated on Z_BATCH words. The
|
608
|
+
three CRCs are combined into a single CRC after each set of batches. */
|
650
609
|
while (num >= 3 * Z_BATCH) {
|
651
610
|
crc1 = 0;
|
652
611
|
crc2 = 0;
|
@@ -714,18 +673,14 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
|
|
714
673
|
least-significant byte of the word as the first byte of data, without any pre
|
715
674
|
or post conditioning. This is used to combine the CRCs of each braid.
|
716
675
|
*/
|
717
|
-
local z_crc_t crc_word(data)
|
718
|
-
z_word_t data;
|
719
|
-
{
|
676
|
+
local z_crc_t crc_word(z_word_t data) {
|
720
677
|
int k;
|
721
678
|
for (k = 0; k < W; k++)
|
722
679
|
data = (data >> 8) ^ crc_table[data & 0xff];
|
723
680
|
return (z_crc_t)data;
|
724
681
|
}
|
725
682
|
|
726
|
-
local z_word_t crc_word_big(data)
|
727
|
-
z_word_t data;
|
728
|
-
{
|
683
|
+
local z_word_t crc_word_big(z_word_t data) {
|
729
684
|
int k;
|
730
685
|
for (k = 0; k < W; k++)
|
731
686
|
data = (data << 8) ^
|
@@ -736,11 +691,8 @@ local z_word_t crc_word_big(data)
|
|
736
691
|
#endif
|
737
692
|
|
738
693
|
/* ========================================================================= */
|
739
|
-
unsigned long ZEXPORT crc32_z(crc, buf,
|
740
|
-
|
741
|
-
const unsigned char FAR *buf;
|
742
|
-
z_size_t len;
|
743
|
-
{
|
694
|
+
unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
|
695
|
+
z_size_t len) {
|
744
696
|
/* Return initial CRC, if requested. */
|
745
697
|
if (buf == Z_NULL) return 0;
|
746
698
|
|
@@ -749,7 +701,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
|
|
749
701
|
#endif /* DYNAMIC_CRC_TABLE */
|
750
702
|
|
751
703
|
/* Pre-condition the CRC */
|
752
|
-
crc
|
704
|
+
crc = (~crc) & 0xffffffff;
|
753
705
|
|
754
706
|
#ifdef W
|
755
707
|
|
@@ -772,8 +724,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
|
|
772
724
|
words = (z_word_t const *)buf;
|
773
725
|
|
774
726
|
/* Do endian check at execution time instead of compile time, since ARM
|
775
|
-
processors can change the
|
776
|
-
compiler knows what the
|
727
|
+
processors can change the endianness at execution time. If the
|
728
|
+
compiler knows what the endianness will be, it can optimize out the
|
777
729
|
check and the unused branch. */
|
778
730
|
endian = 1;
|
779
731
|
if (*(unsigned char *)&endian) {
|
@@ -1060,39 +1012,26 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
|
|
1060
1012
|
#endif
|
1061
1013
|
|
1062
1014
|
/* ========================================================================= */
|
1063
|
-
unsigned long ZEXPORT crc32(crc, buf,
|
1064
|
-
|
1065
|
-
const unsigned char FAR *buf;
|
1066
|
-
uInt len;
|
1067
|
-
{
|
1015
|
+
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf,
|
1016
|
+
uInt len) {
|
1068
1017
|
return crc32_z(crc, buf, len);
|
1069
1018
|
}
|
1070
1019
|
|
1071
1020
|
/* ========================================================================= */
|
1072
|
-
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
|
1073
|
-
uLong crc1;
|
1074
|
-
uLong crc2;
|
1075
|
-
z_off64_t len2;
|
1076
|
-
{
|
1021
|
+
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) {
|
1077
1022
|
#ifdef DYNAMIC_CRC_TABLE
|
1078
1023
|
once(&made, make_crc_table);
|
1079
1024
|
#endif /* DYNAMIC_CRC_TABLE */
|
1080
|
-
return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
|
1025
|
+
return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff);
|
1081
1026
|
}
|
1082
1027
|
|
1083
1028
|
/* ========================================================================= */
|
1084
|
-
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
1085
|
-
|
1086
|
-
uLong crc2;
|
1087
|
-
z_off_t len2;
|
1088
|
-
{
|
1089
|
-
return crc32_combine64(crc1, crc2, len2);
|
1029
|
+
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) {
|
1030
|
+
return crc32_combine64(crc1, crc2, (z_off64_t)len2);
|
1090
1031
|
}
|
1091
1032
|
|
1092
1033
|
/* ========================================================================= */
|
1093
|
-
uLong ZEXPORT crc32_combine_gen64(len2)
|
1094
|
-
z_off64_t len2;
|
1095
|
-
{
|
1034
|
+
uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) {
|
1096
1035
|
#ifdef DYNAMIC_CRC_TABLE
|
1097
1036
|
once(&made, make_crc_table);
|
1098
1037
|
#endif /* DYNAMIC_CRC_TABLE */
|
@@ -1100,17 +1039,11 @@ uLong ZEXPORT crc32_combine_gen64(len2)
|
|
1100
1039
|
}
|
1101
1040
|
|
1102
1041
|
/* ========================================================================= */
|
1103
|
-
uLong ZEXPORT crc32_combine_gen(len2)
|
1104
|
-
|
1105
|
-
{
|
1106
|
-
return crc32_combine_gen64(len2);
|
1042
|
+
uLong ZEXPORT crc32_combine_gen(z_off_t len2) {
|
1043
|
+
return crc32_combine_gen64((z_off64_t)len2);
|
1107
1044
|
}
|
1108
1045
|
|
1109
1046
|
/* ========================================================================= */
|
1110
|
-
uLong crc32_combine_op(crc1, crc2, op)
|
1111
|
-
|
1112
|
-
uLong crc2;
|
1113
|
-
uLong op;
|
1114
|
-
{
|
1115
|
-
return multmodp(op, crc1) ^ crc2;
|
1047
|
+
uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) {
|
1048
|
+
return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
|
1116
1049
|
}
|