1 #ifndef _COMPAT_ZUTIL_H
2 #define _COMPAT_ZUTIL_H
6 /* zutil.h -- internal interface and configuration of the compression library
7 * Copyright (C) 1995-2013 Jean-loup Gailly.
8 * For conditions of distribution and use, see copyright notice in zlib.h
11 /* WARNING: this file should *not* be used by applications. It is
12 part of the implementation of the compression library and is
13 subject to change. Applications should only use zlib.h.
22 # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
24 # define ZLIB_INTERNAL
27 #include <compat/zlib.h>
29 #if defined(STDC) && !defined(Z_SOLO)
30 # if !(defined(_WIN32_WCE) && defined(_MSC_VER))
38 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
44 /* compile with -Dlocal if your debugger can't find static symbols */
46 typedef unsigned char uch;
48 typedef unsigned short ush;
50 typedef unsigned long ulg;
52 extern char z_errmsg[10][21]; /* indexed by 2-zlib_error */
53 /* (array size given to avoid silly warnings with Visual C++) */
54 /* (array entry size given to avoid silly string cast warnings) */
56 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
58 #define ERR_RETURN(strm,err) \
59 return (strm->msg = ERR_MSG(err), (err))
60 /* To be used only when the state is known to be valid */
62 /* common constants */
65 # define DEF_WBITS MAX_WBITS
67 /* default windowBits for decompression. MAX_WBITS is for compression only */
69 #if MAX_MEM_LEVEL >= 8
70 # define DEF_MEM_LEVEL 8
72 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
74 /* default memLevel */
76 #define STORED_BLOCK 0
77 #define STATIC_TREES 1
79 /* The three kinds of block type */
83 /* The minimum and maximum match lengths */
85 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
87 /* target dependencies */
89 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
92 # if defined(__TURBOC__) || defined(__BORLANDC__)
93 # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
94 /* Allow compilation with ANSI keywords only enabled */
95 void _Cdecl farfree( void *block );
96 void *_Cdecl farmalloc( unsigned long nbytes );
100 # else /* MSC or DJGPP */
107 # define OS_CODE 0x01
110 #if defined(VAXC) || defined(VMS)
111 # define OS_CODE 0x02
112 # define F_OPEN(name, mode) \
113 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
116 #if defined(ATARI) || defined(atarist)
117 # define OS_CODE 0x05
121 # define OS_CODE 0x06
122 # if defined(M_I86) && !defined(Z_SOLO)
127 #if defined(MACOS) || defined(TARGET_OS_MAC)
128 # define OS_CODE 0x07
130 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
131 # include <unix.h> /* for fdopen */
134 # define fdopen(fd,mode) NULL /* No fdopen() */
141 # define OS_CODE 0x0a
145 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
146 # define OS_CODE 0x0b
150 #ifdef __50SERIES /* Prime/PRIMOS */
151 # define OS_CODE 0x0f
154 #if defined(_BEOS_) || defined(RISCOS)
155 # define fdopen(fd,mode) NULL /* No fdopen() */
158 #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
159 # if defined(_WIN32_WCE)
160 # define fdopen(fd,mode) NULL /* No fdopen() */
161 # ifndef _PTRDIFF_T_DEFINED
162 typedef int ptrdiff_t;
163 # define _PTRDIFF_T_DEFINED
166 # define fdopen(fd,type) _fdopen(fd,type)
170 #if defined(__BORLANDC__) && !defined(MSDOS)
176 /* provide prototypes for these when building zlib without LFS */
177 #if !defined(_WIN32) && \
178 (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
179 uLong adler32_combine64 (uLong, uLong, z_off_t);
180 uLong crc32_combine64 (uLong, uLong, z_off_t);
183 /* common defaults */
186 # define OS_CODE 0x03 /* assume Unix */
190 # define F_OPEN(name, mode) fopen((name), (mode))
195 #if defined(pyr) || defined(Z_SOLO)
198 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
199 /* Use our own functions for small and medium model with MSC <= 5.0.
200 * You may have to use the same strategy for Borland C (untested).
201 * The __SC__ check is for Symantec.
205 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
209 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */
210 # define zmemcpy _fmemcpy
211 # define zmemcmp _fmemcmp
212 # define zmemzero(dest, len) _fmemset(dest, 0, len)
214 # define zmemcpy memcpy
215 # define zmemcmp memcmp
216 # define zmemzero(dest, len) memset(dest, 0, len)
219 void ZLIB_INTERNAL zmemcpy (Bytef* dest, const Bytef* source, uInt len);
220 int ZLIB_INTERNAL zmemcmp (const Bytef* s1, const Bytef* s2, uInt len);
221 void ZLIB_INTERNAL zmemzero (Bytef* dest, uInt len);
224 /* Diagnostic functions */
225 # define Assert(cond,msg)
230 # define Tracecv(c,x)
233 voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items,
235 void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr);
238 #define ZALLOC(strm, items, size) \
239 (*((strm)->zalloc))((strm)->opaque, (items), (size))
240 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
241 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
243 /* Reverse the bytes in a 32-bit value */
244 #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
245 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))