Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
zutil.h
Go to the documentation of this file.
1/* zutil.h -- internal interface and configuration of the compression library
2 * Copyright (C) 1995-2016 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
12#ifndef ZUTIL_H
13#define ZUTIL_H
14
15#ifdef HAVE_HIDDEN
16# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
17#else
18# define ZLIB_INTERNAL
19#endif
20
21#include "zlib.h"
22
23#if defined(STDC) && !defined(Z_SOLO)
24# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
25# include <stddef.h>
26# endif
27# include <string.h>
28# include <stdlib.h>
29#endif
30
31#ifdef Z_SOLO
32 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
33#endif
34
35#ifndef local
36# define local static
37#endif
38/* since "static" is used to mean two completely different things in C, we
39 define "local" for the non-static meaning of "static", for readability
40 (compile with -Dlocal if your debugger can't find static symbols) */
41
42typedef unsigned char uch;
43typedef uch FAR uchf;
44typedef unsigned short ush;
45typedef ush FAR ushf;
46typedef unsigned long ulg;
47
48extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
49/* (size given to avoid silly warnings with Visual C++) */
50
51#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
52
53#define ERR_RETURN(strm,err) \
54 return (strm->msg = ERR_MSG(err), (err))
55/* To be used only when the state is known to be valid */
56
57 /* common constants */
58
59#ifndef DEF_WBITS
60# define DEF_WBITS MAX_WBITS
61#endif
62/* default windowBits for decompression. MAX_WBITS is for compression only */
63
64#if MAX_MEM_LEVEL >= 8
65# define DEF_MEM_LEVEL 8
66#else
67# define DEF_MEM_LEVEL MAX_MEM_LEVEL
68#endif
69/* default memLevel */
70
71#define STORED_BLOCK 0
72#define STATIC_TREES 1
73#define DYN_TREES 2
74/* The three kinds of block type */
75
76#define MIN_MATCH 3
77#define MAX_MATCH 258
78/* The minimum and maximum match lengths */
79
80#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
81
82 /* target dependencies */
83
84#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
85# define OS_CODE 0x00
86# ifndef Z_SOLO
87# if defined(__TURBOC__) || defined(__BORLANDC__)
88# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
89 /* Allow compilation with ANSI keywords only enabled */
90 void _Cdecl farfree( void *block );
91 void *_Cdecl farmalloc( unsigned long nbytes );
92# else
93# include <alloc.h>
94# endif
95# else /* MSC or DJGPP */
96# include <malloc.h>
97# endif
98# endif
99#endif
100
101#ifdef AMIGA
102# define OS_CODE 1
103#endif
104
105#if defined(VAXC) || defined(VMS)
106# define OS_CODE 2
107# define F_OPEN(name, mode) \
108 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
109#endif
110
111#ifdef __370__
112# if __TARGET_LIB__ < 0x20000000
113# define OS_CODE 4
114# elif __TARGET_LIB__ < 0x40000000
115# define OS_CODE 11
116# else
117# define OS_CODE 8
118# endif
119#endif
120
121#if defined(ATARI) || defined(atarist)
122# define OS_CODE 5
123#endif
124
125#ifdef OS2
126# define OS_CODE 6
127# if defined(M_I86) && !defined(Z_SOLO)
128# include <malloc.h>
129# endif
130#endif
131
132#if defined(MACOS) || defined(TARGET_OS_MAC)
133# define OS_CODE 7
134# ifndef Z_SOLO
135# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
136# include <unix.h> /* for fdopen */
137# else
138# ifndef fdopen
139# define fdopen(fd,mode) NULL /* No fdopen() */
140# endif
141# endif
142# endif
143#endif
144
145#ifdef __acorn
146# define OS_CODE 13
147#endif
148
149#if defined(WIN32) && !defined(__CYGWIN__)
150# define OS_CODE 10
151#endif
152
153#ifdef _BEOS_
154# define OS_CODE 16
155#endif
156
157#ifdef __TOS_OS400__
158# define OS_CODE 18
159#endif
160
161#ifdef __APPLE__
162# define OS_CODE 19
163#endif
164
165#if defined(_BEOS_) || defined(RISCOS)
166# define fdopen(fd,mode) NULL /* No fdopen() */
167#endif
168
169#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
170# if defined(_WIN32_WCE)
171# define fdopen(fd,mode) NULL /* No fdopen() */
172# ifndef _PTRDIFF_T_DEFINED
173 typedef int ptrdiff_t;
174# define _PTRDIFF_T_DEFINED
175# endif
176# else
177# define fdopen(fd,type) _fdopen(fd,type)
178# endif
179#endif
180
181#if defined(__BORLANDC__) && !defined(MSDOS)
182 #pragma warn -8004
183 #pragma warn -8008
184 #pragma warn -8066
185#endif
186
187/* provide prototypes for these when building zlib without LFS */
188#if !defined(_WIN32) && \
189 (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
190 ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
191 ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
192#endif
193
194 /* common defaults */
195
196#ifndef OS_CODE
197# define OS_CODE 3 /* assume Unix */
198#endif
199
200#ifndef F_OPEN
201# define F_OPEN(name, mode) fopen((name), (mode))
202#endif
203
204 /* functions */
205
206#if defined(pyr) || defined(Z_SOLO)
207# define NO_MEMCPY
208#endif
209#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
210 /* Use our own functions for small and medium model with MSC <= 5.0.
211 * You may have to use the same strategy for Borland C (untested).
212 * The __SC__ check is for Symantec.
213 */
214# define NO_MEMCPY
215#endif
216#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
217# define HAVE_MEMCPY
218#endif
219#ifdef HAVE_MEMCPY
220# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
221# define zmemcpy _fmemcpy
222# define zmemcmp _fmemcmp
223# define zmemzero(dest, len) _fmemset(dest, 0, len)
224# else
225# define zmemcpy memcpy
226# define zmemcmp memcmp
227# define zmemzero(dest, len) memset(dest, 0, len)
228# endif
229#else
230 void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
231 int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
232 void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
233#endif
234
235/* Diagnostic functions */
236#ifdef ZLIB_DEBUG
237# include <stdio.h>
238 extern int ZLIB_INTERNAL z_verbose;
239 extern void ZLIB_INTERNAL z_error OF((char *m));
240# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
241# define Trace(x) {if (z_verbose>=0) fprintf x ;}
242# define Tracev(x) {if (z_verbose>0) fprintf x ;}
243# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
244# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
245# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
246#else
247# define Assert(cond,msg)
248# define Trace(x)
249# define Tracev(x)
250# define Tracevv(x)
251# define Tracec(c,x)
252# define Tracecv(c,x)
253#endif
254
255#ifndef Z_SOLO
256 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
257 unsigned size));
258 void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
259#endif
260
261#define ZALLOC(strm, items, size) \
262 (*((strm)->zalloc))((strm)->opaque, (items), (size))
263#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
264#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
265
266/* Reverse the bytes in a 32-bit value */
267#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
268 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
269
270#endif /* ZUTIL_H */
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2)
Definition: adler32.c:179
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2)
Definition: crc32.c:435
unsigned short ush
Definition: csz_inflate.cc:210
unsigned char uch
Definition: csz_inflate.cc:209
voidpf alloc_func OF((voidpf opaque, uInt items, uInt size))
Definition: zlib.h:81
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
Definition: zutil.c:314
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
Definition: zutil.c:304
void ZLIB_INTERNAL zmemzero(Bytef *dest, uInt len)
Definition: zutil.c:172
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:148
int ZLIB_INTERNAL zmemcmp(Bytef *s1, const Bytef *s2, uInt len) const
Definition: zutil.c:159
unsigned short ush
Definition: zutil.h:44
#define ZLIB_INTERNAL
Definition: zutil.h:18
z_const char *const z_errmsg[10]
Definition: zutil.c:12
uch FAR uchf
Definition: zutil.h:43
ush FAR ushf
Definition: zutil.h:45
unsigned long ulg
Definition: zutil.h:46
unsigned char uch
Definition: zutil.h:42