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