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