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