Mercurial > repos > blastem
comparison zlib/zutil.h @ 2690:9ef72ee5c0b0
Update vendored zlib to 1.3.1
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 15 Jun 2025 15:39:33 -0700 |
parents | 00d788dac91a |
children |
comparison
equal
deleted
inserted
replaced
2689:bd6e33de0972 | 2690:9ef72ee5c0b0 |
---|---|
1 /* zutil.h -- internal interface and configuration of the compression library | 1 /* zutil.h -- internal interface and configuration of the compression library |
2 * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler | 2 * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler |
3 * For conditions of distribution and use, see copyright notice in zlib.h | 3 * For conditions of distribution and use, see copyright notice in zlib.h |
4 */ | 4 */ |
5 | 5 |
6 /* WARNING: this file should *not* be used by applications. It is | 6 /* WARNING: this file should *not* be used by applications. It is |
7 part of the implementation of the compression library and is | 7 part of the implementation of the compression library and is |
25 # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) | 25 # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) |
26 # include <stddef.h> | 26 # include <stddef.h> |
27 # endif | 27 # endif |
28 # include <string.h> | 28 # include <string.h> |
29 # include <stdlib.h> | 29 # include <stdlib.h> |
30 #endif | |
31 | |
32 #ifdef Z_SOLO | |
33 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ | |
34 #endif | 30 #endif |
35 | 31 |
36 #ifndef local | 32 #ifndef local |
37 # define local static | 33 # define local static |
38 #endif | 34 #endif |
44 typedef uch FAR uchf; | 40 typedef uch FAR uchf; |
45 typedef unsigned short ush; | 41 typedef unsigned short ush; |
46 typedef ush FAR ushf; | 42 typedef ush FAR ushf; |
47 typedef unsigned long ulg; | 43 typedef unsigned long ulg; |
48 | 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 | |
49 extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | 56 extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ |
50 /* (size given to avoid silly warnings with Visual C++) */ | 57 /* (size given to avoid silly warnings with Visual C++) */ |
51 | 58 |
52 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] | 59 #define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)] |
53 | 60 |
54 #define ERR_RETURN(strm,err) \ | 61 #define ERR_RETURN(strm,err) \ |
55 return (strm->msg = ERR_MSG(err), (err)) | 62 return (strm->msg = ERR_MSG(err), (err)) |
56 /* To be used only when the state is known to be valid */ | 63 /* To be used only when the state is known to be valid */ |
57 | 64 |
128 # if defined(M_I86) && !defined(Z_SOLO) | 135 # if defined(M_I86) && !defined(Z_SOLO) |
129 # include <malloc.h> | 136 # include <malloc.h> |
130 # endif | 137 # endif |
131 #endif | 138 #endif |
132 | 139 |
133 #if defined(MACOS) || defined(TARGET_OS_MAC) | 140 #if defined(MACOS) |
134 # define OS_CODE 7 | 141 # define OS_CODE 7 |
135 # ifndef Z_SOLO | |
136 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os | |
137 # include <unix.h> /* for fdopen */ | |
138 # else | |
139 # ifndef fdopen | |
140 # define fdopen(fd,mode) NULL /* No fdopen() */ | |
141 # endif | |
142 # endif | |
143 # endif | |
144 #endif | 142 #endif |
145 | 143 |
146 #ifdef __acorn | 144 #ifdef __acorn |
147 # define OS_CODE 13 | 145 # define OS_CODE 13 |
148 #endif | 146 #endif |
159 # define OS_CODE 18 | 157 # define OS_CODE 18 |
160 #endif | 158 #endif |
161 | 159 |
162 #ifdef __APPLE__ | 160 #ifdef __APPLE__ |
163 # define OS_CODE 19 | 161 # define OS_CODE 19 |
164 #endif | |
165 | |
166 #if defined(_BEOS_) || defined(RISCOS) | |
167 # define fdopen(fd,mode) NULL /* No fdopen() */ | |
168 #endif | |
169 | |
170 #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX | |
171 # if defined(_WIN32_WCE) | |
172 # define fdopen(fd,mode) NULL /* No fdopen() */ | |
173 # ifndef _PTRDIFF_T_DEFINED | |
174 typedef int ptrdiff_t; | |
175 # define _PTRDIFF_T_DEFINED | |
176 # endif | |
177 # else | |
178 # define fdopen(fd,type) _fdopen(fd,type) | |
179 # endif | |
180 #endif | 162 #endif |
181 | 163 |
182 #if defined(__BORLANDC__) && !defined(MSDOS) | 164 #if defined(__BORLANDC__) && !defined(MSDOS) |
183 #pragma warn -8004 | 165 #pragma warn -8004 |
184 #pragma warn -8008 | 166 #pragma warn -8008 |
186 #endif | 168 #endif |
187 | 169 |
188 /* provide prototypes for these when building zlib without LFS */ | 170 /* provide prototypes for these when building zlib without LFS */ |
189 #if !defined(_WIN32) && \ | 171 #if !defined(_WIN32) && \ |
190 (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) | 172 (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
191 ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); | 173 ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); |
192 ZEXTERN uLong ZEXPORT crc32_combine64 OF((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); | |
193 #endif | 176 #endif |
194 | 177 |
195 /* common defaults */ | 178 /* common defaults */ |
196 | 179 |
197 #ifndef OS_CODE | 180 #ifndef OS_CODE |
226 # define zmemcpy memcpy | 209 # define zmemcpy memcpy |
227 # define zmemcmp memcmp | 210 # define zmemcmp memcmp |
228 # define zmemzero(dest, len) memset(dest, 0, len) | 211 # define zmemzero(dest, len) memset(dest, 0, len) |
229 # endif | 212 # endif |
230 #else | 213 #else |
231 void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); | 214 void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); |
232 int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); | 215 int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); |
233 void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); | 216 void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); |
234 #endif | 217 #endif |
235 | 218 |
236 /* Diagnostic functions */ | 219 /* Diagnostic functions */ |
237 #ifdef ZLIB_DEBUG | 220 #ifdef ZLIB_DEBUG |
238 # include <stdio.h> | 221 # include <stdio.h> |
239 extern int ZLIB_INTERNAL z_verbose; | 222 extern int ZLIB_INTERNAL z_verbose; |
240 extern void ZLIB_INTERNAL z_error OF((char *m)); | 223 extern void ZLIB_INTERNAL z_error(char *m); |
241 # define Assert(cond,msg) {if(!(cond)) z_error(msg);} | 224 # define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
242 # define Trace(x) {if (z_verbose>=0) fprintf x ;} | 225 # define Trace(x) {if (z_verbose>=0) fprintf x ;} |
243 # define Tracev(x) {if (z_verbose>0) fprintf x ;} | 226 # define Tracev(x) {if (z_verbose>0) fprintf x ;} |
244 # define Tracevv(x) {if (z_verbose>1) fprintf x ;} | 227 # define Tracevv(x) {if (z_verbose>1) fprintf x ;} |
245 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} | 228 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} |
252 # define Tracec(c,x) | 235 # define Tracec(c,x) |
253 # define Tracecv(c,x) | 236 # define Tracecv(c,x) |
254 #endif | 237 #endif |
255 | 238 |
256 #ifndef Z_SOLO | 239 #ifndef Z_SOLO |
257 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, | 240 voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, |
258 unsigned size)); | 241 unsigned size); |
259 void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); | 242 void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); |
260 #endif | 243 #endif |
261 | 244 |
262 #define ZALLOC(strm, items, size) \ | 245 #define ZALLOC(strm, items, size) \ |
263 (*((strm)->zalloc))((strm)->opaque, (items), (size)) | 246 (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
264 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) | 247 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |