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,299 @@
|
|
1
|
+
/* zutil.c -- target dependent utility functions for the compression library
|
2
|
+
* Copyright (C) 1995-2017 Jean-loup Gailly
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* @(#) $Id$ */
|
7
|
+
|
8
|
+
#include "zutil.h"
|
9
|
+
#ifndef Z_SOLO
|
10
|
+
# include "gzguts.h"
|
11
|
+
#endif
|
12
|
+
|
13
|
+
z_const char * const z_errmsg[10] = {
|
14
|
+
(z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
|
15
|
+
(z_const char *)"stream end", /* Z_STREAM_END 1 */
|
16
|
+
(z_const char *)"", /* Z_OK 0 */
|
17
|
+
(z_const char *)"file error", /* Z_ERRNO (-1) */
|
18
|
+
(z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */
|
19
|
+
(z_const char *)"data error", /* Z_DATA_ERROR (-3) */
|
20
|
+
(z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
|
21
|
+
(z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */
|
22
|
+
(z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
|
23
|
+
(z_const char *)""
|
24
|
+
};
|
25
|
+
|
26
|
+
|
27
|
+
const char * ZEXPORT zlibVersion(void) {
|
28
|
+
return ZLIB_VERSION;
|
29
|
+
}
|
30
|
+
|
31
|
+
uLong ZEXPORT zlibCompileFlags(void) {
|
32
|
+
uLong flags;
|
33
|
+
|
34
|
+
flags = 0;
|
35
|
+
switch ((int)(sizeof(uInt))) {
|
36
|
+
case 2: break;
|
37
|
+
case 4: flags += 1; break;
|
38
|
+
case 8: flags += 2; break;
|
39
|
+
default: flags += 3;
|
40
|
+
}
|
41
|
+
switch ((int)(sizeof(uLong))) {
|
42
|
+
case 2: break;
|
43
|
+
case 4: flags += 1 << 2; break;
|
44
|
+
case 8: flags += 2 << 2; break;
|
45
|
+
default: flags += 3 << 2;
|
46
|
+
}
|
47
|
+
switch ((int)(sizeof(voidpf))) {
|
48
|
+
case 2: break;
|
49
|
+
case 4: flags += 1 << 4; break;
|
50
|
+
case 8: flags += 2 << 4; break;
|
51
|
+
default: flags += 3 << 4;
|
52
|
+
}
|
53
|
+
switch ((int)(sizeof(z_off_t))) {
|
54
|
+
case 2: break;
|
55
|
+
case 4: flags += 1 << 6; break;
|
56
|
+
case 8: flags += 2 << 6; break;
|
57
|
+
default: flags += 3 << 6;
|
58
|
+
}
|
59
|
+
#ifdef ZLIB_DEBUG
|
60
|
+
flags += 1 << 8;
|
61
|
+
#endif
|
62
|
+
/*
|
63
|
+
#if defined(ASMV) || defined(ASMINF)
|
64
|
+
flags += 1 << 9;
|
65
|
+
#endif
|
66
|
+
*/
|
67
|
+
#ifdef ZLIB_WINAPI
|
68
|
+
flags += 1 << 10;
|
69
|
+
#endif
|
70
|
+
#ifdef BUILDFIXED
|
71
|
+
flags += 1 << 12;
|
72
|
+
#endif
|
73
|
+
#ifdef DYNAMIC_CRC_TABLE
|
74
|
+
flags += 1 << 13;
|
75
|
+
#endif
|
76
|
+
#ifdef NO_GZCOMPRESS
|
77
|
+
flags += 1L << 16;
|
78
|
+
#endif
|
79
|
+
#ifdef NO_GZIP
|
80
|
+
flags += 1L << 17;
|
81
|
+
#endif
|
82
|
+
#ifdef PKZIP_BUG_WORKAROUND
|
83
|
+
flags += 1L << 20;
|
84
|
+
#endif
|
85
|
+
#ifdef FASTEST
|
86
|
+
flags += 1L << 21;
|
87
|
+
#endif
|
88
|
+
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
89
|
+
# ifdef NO_vsnprintf
|
90
|
+
flags += 1L << 25;
|
91
|
+
# ifdef HAS_vsprintf_void
|
92
|
+
flags += 1L << 26;
|
93
|
+
# endif
|
94
|
+
# else
|
95
|
+
# ifdef HAS_vsnprintf_void
|
96
|
+
flags += 1L << 26;
|
97
|
+
# endif
|
98
|
+
# endif
|
99
|
+
#else
|
100
|
+
flags += 1L << 24;
|
101
|
+
# ifdef NO_snprintf
|
102
|
+
flags += 1L << 25;
|
103
|
+
# ifdef HAS_sprintf_void
|
104
|
+
flags += 1L << 26;
|
105
|
+
# endif
|
106
|
+
# else
|
107
|
+
# ifdef HAS_snprintf_void
|
108
|
+
flags += 1L << 26;
|
109
|
+
# endif
|
110
|
+
# endif
|
111
|
+
#endif
|
112
|
+
return flags;
|
113
|
+
}
|
114
|
+
|
115
|
+
#ifdef ZLIB_DEBUG
|
116
|
+
#include <stdlib.h>
|
117
|
+
# ifndef verbose
|
118
|
+
# define verbose 0
|
119
|
+
# endif
|
120
|
+
int ZLIB_INTERNAL z_verbose = verbose;
|
121
|
+
|
122
|
+
void ZLIB_INTERNAL z_error(char *m) {
|
123
|
+
fprintf(stderr, "%s\n", m);
|
124
|
+
exit(1);
|
125
|
+
}
|
126
|
+
#endif
|
127
|
+
|
128
|
+
/* exported to allow conversion of error code to string for compress() and
|
129
|
+
* uncompress()
|
130
|
+
*/
|
131
|
+
const char * ZEXPORT zError(int err) {
|
132
|
+
return ERR_MSG(err);
|
133
|
+
}
|
134
|
+
|
135
|
+
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
|
136
|
+
/* The older Microsoft C Run-Time Library for Windows CE doesn't have
|
137
|
+
* errno. We define it as a global variable to simplify porting.
|
138
|
+
* Its value is always 0 and should not be used.
|
139
|
+
*/
|
140
|
+
int errno = 0;
|
141
|
+
#endif
|
142
|
+
|
143
|
+
#ifndef HAVE_MEMCPY
|
144
|
+
|
145
|
+
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) {
|
146
|
+
if (len == 0) return;
|
147
|
+
do {
|
148
|
+
*dest++ = *source++; /* ??? to be unrolled */
|
149
|
+
} while (--len != 0);
|
150
|
+
}
|
151
|
+
|
152
|
+
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
|
153
|
+
uInt j;
|
154
|
+
|
155
|
+
for (j = 0; j < len; j++) {
|
156
|
+
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
|
157
|
+
}
|
158
|
+
return 0;
|
159
|
+
}
|
160
|
+
|
161
|
+
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
|
162
|
+
if (len == 0) return;
|
163
|
+
do {
|
164
|
+
*dest++ = 0; /* ??? to be unrolled */
|
165
|
+
} while (--len != 0);
|
166
|
+
}
|
167
|
+
#endif
|
168
|
+
|
169
|
+
#ifndef Z_SOLO
|
170
|
+
|
171
|
+
#ifdef SYS16BIT
|
172
|
+
|
173
|
+
#ifdef __TURBOC__
|
174
|
+
/* Turbo C in 16-bit mode */
|
175
|
+
|
176
|
+
# define MY_ZCALLOC
|
177
|
+
|
178
|
+
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
|
179
|
+
* and farmalloc(64K) returns a pointer with an offset of 8, so we
|
180
|
+
* must fix the pointer. Warning: the pointer must be put back to its
|
181
|
+
* original form in order to free it, use zcfree().
|
182
|
+
*/
|
183
|
+
|
184
|
+
#define MAX_PTR 10
|
185
|
+
/* 10*64K = 640K */
|
186
|
+
|
187
|
+
local int next_ptr = 0;
|
188
|
+
|
189
|
+
typedef struct ptr_table_s {
|
190
|
+
voidpf org_ptr;
|
191
|
+
voidpf new_ptr;
|
192
|
+
} ptr_table;
|
193
|
+
|
194
|
+
local ptr_table table[MAX_PTR];
|
195
|
+
/* This table is used to remember the original form of pointers
|
196
|
+
* to large buffers (64K). Such pointers are normalized with a zero offset.
|
197
|
+
* Since MSDOS is not a preemptive multitasking OS, this table is not
|
198
|
+
* protected from concurrent access. This hack doesn't work anyway on
|
199
|
+
* a protected system like OS/2. Use Microsoft C instead.
|
200
|
+
*/
|
201
|
+
|
202
|
+
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
203
|
+
voidpf buf;
|
204
|
+
ulg bsize = (ulg)items*size;
|
205
|
+
|
206
|
+
(void)opaque;
|
207
|
+
|
208
|
+
/* If we allocate less than 65520 bytes, we assume that farmalloc
|
209
|
+
* will return a usable pointer which doesn't have to be normalized.
|
210
|
+
*/
|
211
|
+
if (bsize < 65520L) {
|
212
|
+
buf = farmalloc(bsize);
|
213
|
+
if (*(ush*)&buf != 0) return buf;
|
214
|
+
} else {
|
215
|
+
buf = farmalloc(bsize + 16L);
|
216
|
+
}
|
217
|
+
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
|
218
|
+
table[next_ptr].org_ptr = buf;
|
219
|
+
|
220
|
+
/* Normalize the pointer to seg:0 */
|
221
|
+
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
|
222
|
+
*(ush*)&buf = 0;
|
223
|
+
table[next_ptr++].new_ptr = buf;
|
224
|
+
return buf;
|
225
|
+
}
|
226
|
+
|
227
|
+
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
228
|
+
int n;
|
229
|
+
|
230
|
+
(void)opaque;
|
231
|
+
|
232
|
+
if (*(ush*)&ptr != 0) { /* object < 64K */
|
233
|
+
farfree(ptr);
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
/* Find the original pointer */
|
237
|
+
for (n = 0; n < next_ptr; n++) {
|
238
|
+
if (ptr != table[n].new_ptr) continue;
|
239
|
+
|
240
|
+
farfree(table[n].org_ptr);
|
241
|
+
while (++n < next_ptr) {
|
242
|
+
table[n-1] = table[n];
|
243
|
+
}
|
244
|
+
next_ptr--;
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
Assert(0, "zcfree: ptr not found");
|
248
|
+
}
|
249
|
+
|
250
|
+
#endif /* __TURBOC__ */
|
251
|
+
|
252
|
+
|
253
|
+
#ifdef M_I86
|
254
|
+
/* Microsoft C in 16-bit mode */
|
255
|
+
|
256
|
+
# define MY_ZCALLOC
|
257
|
+
|
258
|
+
#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
|
259
|
+
# define _halloc halloc
|
260
|
+
# define _hfree hfree
|
261
|
+
#endif
|
262
|
+
|
263
|
+
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
|
264
|
+
(void)opaque;
|
265
|
+
return _halloc((long)items, size);
|
266
|
+
}
|
267
|
+
|
268
|
+
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
269
|
+
(void)opaque;
|
270
|
+
_hfree(ptr);
|
271
|
+
}
|
272
|
+
|
273
|
+
#endif /* M_I86 */
|
274
|
+
|
275
|
+
#endif /* SYS16BIT */
|
276
|
+
|
277
|
+
|
278
|
+
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
|
279
|
+
|
280
|
+
#ifndef STDC
|
281
|
+
extern voidp malloc(uInt size);
|
282
|
+
extern voidp calloc(uInt items, uInt size);
|
283
|
+
extern void free(voidpf ptr);
|
284
|
+
#endif
|
285
|
+
|
286
|
+
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
287
|
+
(void)opaque;
|
288
|
+
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
289
|
+
(voidpf)calloc(items, size);
|
290
|
+
}
|
291
|
+
|
292
|
+
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
|
293
|
+
(void)opaque;
|
294
|
+
free(ptr);
|
295
|
+
}
|
296
|
+
|
297
|
+
#endif /* MY_ZCALLOC */
|
298
|
+
|
299
|
+
#endif /* !Z_SOLO */
|
@@ -0,0 +1,254 @@
|
|
1
|
+
/* zutil.h -- internal interface and configuration of the compression library
|
2
|
+
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
|
+
*/
|
5
|
+
|
6
|
+
/* WARNING: this file should *not* be used by applications. It is
|
7
|
+
part of the implementation of the compression library and is
|
8
|
+
subject to change. Applications should only use zlib.h.
|
9
|
+
*/
|
10
|
+
|
11
|
+
/* @(#) $Id$ */
|
12
|
+
|
13
|
+
#ifndef ZUTIL_H
|
14
|
+
#define ZUTIL_H
|
15
|
+
|
16
|
+
#ifdef HAVE_HIDDEN
|
17
|
+
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
18
|
+
#else
|
19
|
+
# define ZLIB_INTERNAL
|
20
|
+
#endif
|
21
|
+
|
22
|
+
#include "zlib.h"
|
23
|
+
|
24
|
+
#if defined(STDC) && !defined(Z_SOLO)
|
25
|
+
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
26
|
+
# include <stddef.h>
|
27
|
+
# endif
|
28
|
+
# include <string.h>
|
29
|
+
# include <stdlib.h>
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#ifndef local
|
33
|
+
# define local static
|
34
|
+
#endif
|
35
|
+
/* since "static" is used to mean two completely different things in C, we
|
36
|
+
define "local" for the non-static meaning of "static", for readability
|
37
|
+
(compile with -Dlocal if your debugger can't find static symbols) */
|
38
|
+
|
39
|
+
typedef unsigned char uch;
|
40
|
+
typedef uch FAR uchf;
|
41
|
+
typedef unsigned short ush;
|
42
|
+
typedef ush FAR ushf;
|
43
|
+
typedef unsigned long ulg;
|
44
|
+
|
45
|
+
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
|
46
|
+
# include <limits.h>
|
47
|
+
# if (ULONG_MAX == 0xffffffffffffffff)
|
48
|
+
# define Z_U8 unsigned long
|
49
|
+
# elif (ULLONG_MAX == 0xffffffffffffffff)
|
50
|
+
# define Z_U8 unsigned long long
|
51
|
+
# elif (UINT_MAX == 0xffffffffffffffff)
|
52
|
+
# define Z_U8 unsigned
|
53
|
+
# endif
|
54
|
+
#endif
|
55
|
+
|
56
|
+
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
57
|
+
/* (size given to avoid silly warnings with Visual C++) */
|
58
|
+
|
59
|
+
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
|
60
|
+
|
61
|
+
#define ERR_RETURN(strm,err) \
|
62
|
+
return (strm->msg = ERR_MSG(err), (err))
|
63
|
+
/* To be used only when the state is known to be valid */
|
64
|
+
|
65
|
+
/* common constants */
|
66
|
+
|
67
|
+
#ifndef DEF_WBITS
|
68
|
+
# define DEF_WBITS MAX_WBITS
|
69
|
+
#endif
|
70
|
+
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
71
|
+
|
72
|
+
#if MAX_MEM_LEVEL >= 8
|
73
|
+
# define DEF_MEM_LEVEL 8
|
74
|
+
#else
|
75
|
+
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
76
|
+
#endif
|
77
|
+
/* default memLevel */
|
78
|
+
|
79
|
+
#define STORED_BLOCK 0
|
80
|
+
#define STATIC_TREES 1
|
81
|
+
#define DYN_TREES 2
|
82
|
+
/* The three kinds of block type */
|
83
|
+
|
84
|
+
#define MIN_MATCH 3
|
85
|
+
#define MAX_MATCH 258
|
86
|
+
/* The minimum and maximum match lengths */
|
87
|
+
|
88
|
+
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
89
|
+
|
90
|
+
/* target dependencies */
|
91
|
+
|
92
|
+
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
93
|
+
# define OS_CODE 0x00
|
94
|
+
# ifndef Z_SOLO
|
95
|
+
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
96
|
+
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
97
|
+
/* Allow compilation with ANSI keywords only enabled */
|
98
|
+
void _Cdecl farfree( void *block );
|
99
|
+
void *_Cdecl farmalloc( unsigned long nbytes );
|
100
|
+
# else
|
101
|
+
# include <alloc.h>
|
102
|
+
# endif
|
103
|
+
# else /* MSC or DJGPP */
|
104
|
+
# include <malloc.h>
|
105
|
+
# endif
|
106
|
+
# endif
|
107
|
+
#endif
|
108
|
+
|
109
|
+
#ifdef AMIGA
|
110
|
+
# define OS_CODE 1
|
111
|
+
#endif
|
112
|
+
|
113
|
+
#if defined(VAXC) || defined(VMS)
|
114
|
+
# define OS_CODE 2
|
115
|
+
# define F_OPEN(name, mode) \
|
116
|
+
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
117
|
+
#endif
|
118
|
+
|
119
|
+
#ifdef __370__
|
120
|
+
# if __TARGET_LIB__ < 0x20000000
|
121
|
+
# define OS_CODE 4
|
122
|
+
# elif __TARGET_LIB__ < 0x40000000
|
123
|
+
# define OS_CODE 11
|
124
|
+
# else
|
125
|
+
# define OS_CODE 8
|
126
|
+
# endif
|
127
|
+
#endif
|
128
|
+
|
129
|
+
#if defined(ATARI) || defined(atarist)
|
130
|
+
# define OS_CODE 5
|
131
|
+
#endif
|
132
|
+
|
133
|
+
#ifdef OS2
|
134
|
+
# define OS_CODE 6
|
135
|
+
# if defined(M_I86) && !defined(Z_SOLO)
|
136
|
+
# include <malloc.h>
|
137
|
+
# endif
|
138
|
+
#endif
|
139
|
+
|
140
|
+
#if defined(MACOS)
|
141
|
+
# define OS_CODE 7
|
142
|
+
#endif
|
143
|
+
|
144
|
+
#ifdef __acorn
|
145
|
+
# define OS_CODE 13
|
146
|
+
#endif
|
147
|
+
|
148
|
+
#if defined(WIN32) && !defined(__CYGWIN__)
|
149
|
+
# define OS_CODE 10
|
150
|
+
#endif
|
151
|
+
|
152
|
+
#ifdef _BEOS_
|
153
|
+
# define OS_CODE 16
|
154
|
+
#endif
|
155
|
+
|
156
|
+
#ifdef __TOS_OS400__
|
157
|
+
# define OS_CODE 18
|
158
|
+
#endif
|
159
|
+
|
160
|
+
#ifdef __APPLE__
|
161
|
+
# define OS_CODE 19
|
162
|
+
#endif
|
163
|
+
|
164
|
+
#if defined(__BORLANDC__) && !defined(MSDOS)
|
165
|
+
#pragma warn -8004
|
166
|
+
#pragma warn -8008
|
167
|
+
#pragma warn -8066
|
168
|
+
#endif
|
169
|
+
|
170
|
+
/* provide prototypes for these when building zlib without LFS */
|
171
|
+
#if !defined(_WIN32) && \
|
172
|
+
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
173
|
+
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
|
174
|
+
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
|
175
|
+
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
|
176
|
+
#endif
|
177
|
+
|
178
|
+
/* common defaults */
|
179
|
+
|
180
|
+
#ifndef OS_CODE
|
181
|
+
# define OS_CODE 3 /* assume Unix */
|
182
|
+
#endif
|
183
|
+
|
184
|
+
#ifndef F_OPEN
|
185
|
+
# define F_OPEN(name, mode) fopen((name), (mode))
|
186
|
+
#endif
|
187
|
+
|
188
|
+
/* functions */
|
189
|
+
|
190
|
+
#if defined(pyr) || defined(Z_SOLO)
|
191
|
+
# define NO_MEMCPY
|
192
|
+
#endif
|
193
|
+
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
194
|
+
/* Use our own functions for small and medium model with MSC <= 5.0.
|
195
|
+
* You may have to use the same strategy for Borland C (untested).
|
196
|
+
* The __SC__ check is for Symantec.
|
197
|
+
*/
|
198
|
+
# define NO_MEMCPY
|
199
|
+
#endif
|
200
|
+
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
201
|
+
# define HAVE_MEMCPY
|
202
|
+
#endif
|
203
|
+
#ifdef HAVE_MEMCPY
|
204
|
+
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
205
|
+
# define zmemcpy _fmemcpy
|
206
|
+
# define zmemcmp _fmemcmp
|
207
|
+
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
208
|
+
# else
|
209
|
+
# define zmemcpy memcpy
|
210
|
+
# define zmemcmp memcmp
|
211
|
+
# define zmemzero(dest, len) memset(dest, 0, len)
|
212
|
+
# endif
|
213
|
+
#else
|
214
|
+
void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
|
215
|
+
int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
|
216
|
+
void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
|
217
|
+
#endif
|
218
|
+
|
219
|
+
/* Diagnostic functions */
|
220
|
+
#ifdef ZLIB_DEBUG
|
221
|
+
# include <stdio.h>
|
222
|
+
extern int ZLIB_INTERNAL z_verbose;
|
223
|
+
extern void ZLIB_INTERNAL z_error(char *m);
|
224
|
+
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
225
|
+
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
226
|
+
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
227
|
+
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
228
|
+
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
229
|
+
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
230
|
+
#else
|
231
|
+
# define Assert(cond,msg)
|
232
|
+
# define Trace(x)
|
233
|
+
# define Tracev(x)
|
234
|
+
# define Tracevv(x)
|
235
|
+
# define Tracec(c,x)
|
236
|
+
# define Tracecv(c,x)
|
237
|
+
#endif
|
238
|
+
|
239
|
+
#ifndef Z_SOLO
|
240
|
+
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
|
241
|
+
unsigned size);
|
242
|
+
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
|
243
|
+
#endif
|
244
|
+
|
245
|
+
#define ZALLOC(strm, items, size) \
|
246
|
+
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
247
|
+
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
248
|
+
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
249
|
+
|
250
|
+
/* Reverse the bytes in a 32-bit value */
|
251
|
+
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
252
|
+
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
253
|
+
|
254
|
+
#endif /* ZUTIL_H */
|
@@ -0,0 +1,14 @@
|
|
1
|
+
VPATH := $(SRCDIR)
|
2
|
+
|
3
|
+
SRCS := $(foreach dir,$(VPATH),$(wildcard $(dir)/*.c))
|
4
|
+
OBJS := $(patsubst %.c,%.o,$(foreach file,$(SRCS),$(notdir $(file))))
|
5
|
+
|
6
|
+
CPPFLAGS += -I$(SRCDIR)
|
7
|
+
|
8
|
+
LIB = ../libz.a
|
9
|
+
|
10
|
+
$(LIB) : $(OBJS)
|
11
|
+
$(AR) cr $@ $^
|
12
|
+
|
13
|
+
clean :
|
14
|
+
$(RM) -f $(LIB) $(OBJS)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
VPATH := $(SRCDIR) $(SRCDIR)/../../zlibwrapper
|
2
|
+
|
3
|
+
SRCS := $(foreach dir,$(VPATH),$(wildcard $(dir)/*.c))
|
4
|
+
OBJS := $(patsubst %.c,%.o,$(foreach file,$(SRCS),$(notdir $(file))))
|
5
|
+
|
6
|
+
CPPFLAGS += -I$(SRCDIR)/../lib -I$(SRCDIR)/../lib/common
|
7
|
+
|
8
|
+
LIB = ../libzlibwrapper.a
|
9
|
+
|
10
|
+
$(LIB) : $(OBJS)
|
11
|
+
$(AR) cr $@ $^
|
12
|
+
|
13
|
+
clean :
|
14
|
+
$(RM) -f $(LIB) $(OBJS)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* This source code is licensed under both the BSD-style license (found in the
|
6
|
+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
+
* in the COPYING file in the root directory of this source tree).
|
8
|
+
* You may select, at your option, one of the above-listed licenses.
|
9
|
+
*/
|
10
|
+
|
11
|
+
/* This file provides custom allocation primitives
|
12
|
+
*/
|
13
|
+
|
14
|
+
#define ZSTD_DEPS_NEED_MALLOC
|
15
|
+
#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
|
16
|
+
|
17
|
+
#include "compiler.h" /* MEM_STATIC */
|
18
|
+
#define ZSTD_STATIC_LINKING_ONLY
|
19
|
+
#include "../zstd.h" /* ZSTD_customMem */
|
20
|
+
|
21
|
+
#ifndef ZSTD_ALLOCATIONS_H
|
22
|
+
#define ZSTD_ALLOCATIONS_H
|
23
|
+
|
24
|
+
/* custom memory allocation functions */
|
25
|
+
|
26
|
+
MEM_STATIC void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
|
27
|
+
{
|
28
|
+
if (customMem.customAlloc)
|
29
|
+
return customMem.customAlloc(customMem.opaque, size);
|
30
|
+
return ZSTD_malloc(size);
|
31
|
+
}
|
32
|
+
|
33
|
+
MEM_STATIC void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
|
34
|
+
{
|
35
|
+
if (customMem.customAlloc) {
|
36
|
+
/* calloc implemented as malloc+memset;
|
37
|
+
* not as efficient as calloc, but next best guess for custom malloc */
|
38
|
+
void* const ptr = customMem.customAlloc(customMem.opaque, size);
|
39
|
+
ZSTD_memset(ptr, 0, size);
|
40
|
+
return ptr;
|
41
|
+
}
|
42
|
+
return ZSTD_calloc(1, size);
|
43
|
+
}
|
44
|
+
|
45
|
+
MEM_STATIC void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
|
46
|
+
{
|
47
|
+
if (ptr!=NULL) {
|
48
|
+
if (customMem.customFree)
|
49
|
+
customMem.customFree(customMem.opaque, ptr);
|
50
|
+
else
|
51
|
+
ZSTD_free(ptr);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
#endif /* ZSTD_ALLOCATIONS_H */
|