ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
zutil.h
Go to the documentation of this file.
1/* zutil.h -- internal interface and configuration of the compression library
2 * Copyright (C) 1995-2010 Jean-loup Gailly.
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#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
17# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
18#else
19# define ZLIB_INTERNAL
20#endif
21
22#include "zlib.h"
23
24#ifdef STDC
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
33
34#ifndef local
35# define local static
36#endif
37/* compile with -Dlocal if your debugger can't find static symbols */
38
39typedef unsigned char uch;
40typedef uch FAR uchf;
41typedef unsigned short ush;
42typedef ush FAR ushf;
43typedef unsigned long ulg;
44
45extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
46/* (size given to avoid silly warnings with Visual C++) */
47
48#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
49
50#define ERR_RETURN(strm,err) \
51 return (strm->msg = (char*)ERR_MSG(err), (err))
52/* To be used only when the state is known to be valid */
53
54 /* common constants */
55
56#ifndef DEF_WBITS
57# define DEF_WBITS MAX_WBITS
58#endif
59/* default windowBits for decompression. MAX_WBITS is for compression only */
60
61#if MAX_MEM_LEVEL >= 8
62# define DEF_MEM_LEVEL 8
63#else
64# define DEF_MEM_LEVEL MAX_MEM_LEVEL
65#endif
66/* default memLevel */
67
68#define STORED_BLOCK 0
69#define STATIC_TREES 1
70#define DYN_TREES 2
71/* The three kinds of block type */
72
73#define MIN_MATCH 3
74#define MAX_MATCH 258
75/* The minimum and maximum match lengths */
76
77#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
78
79 /* target dependencies */
80
81#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
82# define OS_CODE 0x00
83# if defined(__TURBOC__) || defined(__BORLANDC__)
84# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
85 /* Allow compilation with ANSI keywords only enabled */
86 void _Cdecl farfree( void *block );
87 void *_Cdecl farmalloc( unsigned long nbytes );
88# else
90# include <alloc.h>
92# endif
93# else /* MSC or DJGPP */
95# include <malloc.h>
97# endif
98#endif
99
100#ifdef AMIGA
101# define OS_CODE 0x01
102#endif
103
104#if defined(VAXC) || defined(VMS)
105# define OS_CODE 0x02
106# define F_OPEN(name, mode) \
107 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
108#endif
109
110#if defined(ATARI) || defined(atarist)
111# define OS_CODE 0x05
112#endif
113
114#ifdef OS2
115# define OS_CODE 0x06
116# ifdef M_I86
118# include <malloc.h>
120# endif
121#endif
122
123#if defined(MACOS) || defined(TARGET_OS_MAC)
124# define OS_CODE 0x07
125# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
127# include <unix.h> /* for fdopen */
129# else
130# ifndef fdopen
131# define fdopen(fd,mode) NULL /* No fdopen() */
132# endif
133# endif
134#endif
135
136#ifdef TOPS20
137# define OS_CODE 0x0a
138#endif
139
140#ifdef WIN32
141# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
142# define OS_CODE 0x0b
143# endif
144#endif
145
146#ifdef __50SERIES /* Prime/PRIMOS */
147# define OS_CODE 0x0f
148#endif
149
150#if defined(_BEOS_) || defined(RISCOS)
151# define fdopen(fd,mode) NULL /* No fdopen() */
152#endif
153
154#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
155# if defined(_WIN32_WCE)
156# define fdopen(fd,mode) NULL /* No fdopen() */
157# ifndef _PTRDIFF_T_DEFINED
158 typedef int ptrdiff_t;
159# define _PTRDIFF_T_DEFINED
160# endif
161# else
162# define fdopen(fd,type) _fdopen(fd,type)
163# endif
164#endif
165
166#if defined(__BORLANDC__)
167 #pragma warn -8004
168 #pragma warn -8008
169 #pragma warn -8066
170#endif
171
172/* provide prototypes for these when building zlib without LFS */
173#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
176#endif
177
178 /* common defaults */
179
180#ifndef OS_CODE
181# define OS_CODE 0x03 /* 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(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
191# ifndef HAVE_VSNPRINTF
192# define HAVE_VSNPRINTF
193# endif
194#endif
195#if defined(__CYGWIN__)
196# ifndef HAVE_VSNPRINTF
197# define HAVE_VSNPRINTF
198# endif
199#endif
200#ifndef HAVE_VSNPRINTF
201# ifdef MSDOS
202 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
203 but for now we just assume it doesn't. */
204# define NO_vsnprintf
205# endif
206# ifdef __TURBOC__
207# define NO_vsnprintf
208# endif
209# ifdef WIN32
210 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
211# if !defined(vsnprintf) && !defined(NO_vsnprintf)
212# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
213# define vsnprintf _vsnprintf
214# endif
215# endif
216# endif
217# ifdef __SASC
218# define NO_vsnprintf
219# endif
220#endif
221#ifdef VMS
222# define NO_vsnprintf
223#endif
224
225#if defined(pyr)
226# define NO_MEMCPY
227#endif
228#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
229 /* Use our own functions for small and medium model with MSC <= 5.0.
230 * You may have to use the same strategy for Borland C (untested).
231 * The __SC__ check is for Symantec.
232 */
233# define NO_MEMCPY
234#endif
235#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
236# define HAVE_MEMCPY
237#endif
238#ifdef HAVE_MEMCPY
239# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
240# define zmemcpy _fmemcpy
241# define zmemcmp _fmemcmp
242# define zmemzero(dest, len) _fmemset(dest, 0, (size_t)len)
243# else
244# define zmemcpy memcpy
245# define zmemcmp memcmp
246# define zmemzero(dest, len) memset(dest, 0, (size_t)len)
247# endif
248#else
249 void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
250 int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
251 void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
252#endif
253
254/* Diagnostic functions */
255#ifdef DEBUG
257# include <stdio.h>
259 extern int ZLIB_INTERNAL z_verbose;
260 extern void ZLIB_INTERNAL z_error OF((char *m));
261# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
262# define Trace(x) {if (z_verbose>=0) fprintf x ;}
263# define Tracev(x) {if (z_verbose>0) fprintf x ;}
264# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
265# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
266# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
267#else
268# define Assert(cond,msg)
269# define Trace(x)
270# define Tracev(x)
271# define Tracevv(x)
272# define Tracec(c,x)
273# define Tracecv(c,x)
274#endif
275
276
277voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
278 unsigned size));
279void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
280
281#define ZALLOC(strm, items, size) \
282 (*((strm)->zalloc))((strm)->opaque, (items), (size))
283#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
284#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
285
287
288#endif /* ZUTIL_H */
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2)
Definition adler32.c:161
#define ZLIB_INTERNAL
Definition compress_.c:8
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2)
Definition crc32.c:426
Byte FAR * voidpf
Definition zconf.h:355
#define ZEXPORT
Definition zconf.h:322
#define ZEXTERN
Definition zconf.h:319
unsigned int uInt
Definition zconf.h:335
#define z_off_t
Definition zconf.h:396
#define OF(args)
Definition zconf.h:242
unsigned long uLong
Definition zconf.h:336
Byte FAR Bytef
Definition zconf.h:342
#define FAR
Definition zconf.h:329
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
Definition zutil.c:307
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
Definition zutil.c:300
void ZLIB_INTERNAL zmemzero(Bytef *dest, uInt len)
Definition zutil.c:175
int ZLIB_INTERNAL zmemcmp(const Bytef *s1, const Bytef *s2, uInt len)
Definition zutil.c:165
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition zutil.c:157
const char *const z_errmsg[10]
Definition zutil.c:23
unsigned short ush
Definition zutil.h:41
uch FAR uchf
Definition zutil.h:40
ush FAR ushf
Definition zutil.h:42
unsigned long ulg
Definition zutil.h:43
unsigned char uch
Definition zutil.h:39