]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Modules/zlib/zutil.h
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Modules / zlib / zutil.h
CommitLineData
4710c53d 1/* zutil.h -- internal interface and configuration of the compression library\r
2\r
3 Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
4 This program and the accompanying materials are licensed and made available under\r
5 the terms and conditions of the BSD License that accompanies this distribution.\r
6 The full text of the license may be found at\r
7 http://opensource.org/licenses/bsd-license.\r
8\r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12 * Copyright (C) 1995-2005 Jean-loup Gailly.\r
13 * For conditions of distribution and use, see copyright notice in zlib.h\r
14**/\r
15\r
16/* WARNING: this file should *not* be used by applications. It is\r
17 part of the implementation of the compression library and is\r
18 subject to change. Applications should only use zlib.h.\r
19 */\r
20\r
21#ifndef ZUTIL_H\r
22#define ZUTIL_H\r
23\r
24#define ZLIB_INTERNAL\r
25#include "zlib.h"\r
26\r
27#if defined(UEFI_C_SOURCE) || defined(STDC)\r
28# ifndef _WIN32_WCE\r
29# include <stddef.h>\r
30# endif\r
31# include <string.h>\r
32# include <stdlib.h>\r
33#endif\r
34#ifdef NO_ERRNO_H\r
35# ifdef _WIN32_WCE\r
36 /* The Microsoft C Run-Time Library for Windows CE doesn't have\r
37 * errno. We define it as a global variable to simplify porting.\r
38 * Its value is always 0 and should not be used. We rename it to\r
39 * avoid conflict with other libraries that use the same workaround.\r
40 */\r
41# define errno z_errno\r
42# endif\r
43 extern int errno;\r
44#else\r
45# ifndef _WIN32_WCE\r
46# include <errno.h>\r
47# endif\r
48#endif\r
49\r
50#ifndef local\r
51# define local static\r
52#endif\r
53/* compile with -Dlocal if your debugger can't find static symbols */\r
54\r
55typedef unsigned char uch;\r
56typedef uch FAR uchf;\r
57typedef unsigned short ush;\r
58typedef ush FAR ushf;\r
59typedef unsigned long ulg;\r
60\r
61extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */\r
62/* (size given to avoid silly warnings with Visual C++) */\r
63\r
64#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]\r
65\r
66#define ERR_RETURN(strm,err) \\r
67 return (strm->msg = (char*)ERR_MSG(err), (err))\r
68/* To be used only when the state is known to be valid */\r
69\r
70 /* common constants */\r
71\r
72#ifndef DEF_WBITS\r
73# define DEF_WBITS MAX_WBITS\r
74#endif\r
75/* default windowBits for decompression. MAX_WBITS is for compression only */\r
76\r
77#if MAX_MEM_LEVEL >= 8\r
78# define DEF_MEM_LEVEL 8\r
79#else\r
80# define DEF_MEM_LEVEL MAX_MEM_LEVEL\r
81#endif\r
82/* default memLevel */\r
83\r
84#define STORED_BLOCK 0\r
85#define STATIC_TREES 1\r
86#define DYN_TREES 2\r
87/* The three kinds of block type */\r
88\r
89#define MIN_MATCH 3\r
90#define MAX_MATCH 258\r
91/* The minimum and maximum match lengths */\r
92\r
93#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */\r
94\r
95 /* target dependencies */\r
96\r
97#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))\r
98# define OS_CODE 0x00\r
99# if defined(__TURBOC__) || defined(__BORLANDC__)\r
100# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))\r
101 /* Allow compilation with ANSI keywords only enabled */\r
102 void _Cdecl farfree( void *block );\r
103 void *_Cdecl farmalloc( unsigned long nbytes );\r
104# else\r
105# include <alloc.h>\r
106# endif\r
107# else /* MSC or DJGPP */\r
108# include <malloc.h>\r
109# endif\r
110#endif\r
111\r
112#ifdef AMIGA\r
113# define OS_CODE 0x01\r
114#endif\r
115\r
116#if defined(VAXC) || defined(VMS)\r
117# define OS_CODE 0x02\r
118# define F_OPEN(name, mode) \\r
119 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")\r
120#endif\r
121\r
122#if defined(ATARI) || defined(atarist)\r
123# define OS_CODE 0x05\r
124#endif\r
125\r
126#ifdef OS2\r
127# define OS_CODE 0x06\r
128# ifdef M_I86\r
129 #include <malloc.h>\r
130# endif\r
131#endif\r
132\r
133#if defined(MACOS) || defined(TARGET_OS_MAC)\r
134# define OS_CODE 0x07\r
135# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os\r
136# include <unix.h> /* for fdopen */\r
137# else\r
138# ifndef fdopen\r
139# define fdopen(fd,mode) NULL /* No fdopen() */\r
140# endif\r
141# endif\r
142#endif\r
143\r
144#ifdef TOPS20\r
145# define OS_CODE 0x0a\r
146#endif\r
147\r
148#ifdef WIN32\r
149# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */\r
150# define OS_CODE 0x0b\r
151# endif\r
152#endif\r
153\r
154#ifdef __50SERIES /* Prime/PRIMOS */\r
155# define OS_CODE 0x0f\r
156#endif\r
157\r
158#if defined(_BEOS_) || defined(RISCOS)\r
159# define fdopen(fd,mode) NULL /* No fdopen() */\r
160#endif\r
161\r
162#if !defined(UEFI_C_SOURCE) && (defined(_MSC_VER) && (_MSC_VER > 600))\r
163# if defined(_WIN32_WCE)\r
164# define fdopen(fd,mode) NULL /* No fdopen() */\r
165# ifndef _PTRDIFF_T_DEFINED\r
166 typedef int ptrdiff_t;\r
167# define _PTRDIFF_T_DEFINED\r
168# endif\r
169# else\r
170# define fdopen(fd,type) _fdopen(fd,type)\r
171# endif\r
172#endif\r
173\r
174 /* common defaults */\r
175\r
176#ifndef OS_CODE\r
177# define OS_CODE 0x03 /* assume Unix */\r
178#endif\r
179\r
180#ifndef F_OPEN\r
181# define F_OPEN(name, mode) fopen((name), (mode))\r
182#endif\r
183\r
184 /* functions */\r
185\r
186#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)\r
187# ifndef HAVE_VSNPRINTF\r
188# define HAVE_VSNPRINTF\r
189# endif\r
190#endif\r
191#if defined(__CYGWIN__)\r
192# ifndef HAVE_VSNPRINTF\r
193# define HAVE_VSNPRINTF\r
194# endif\r
195#endif\r
196#ifndef HAVE_VSNPRINTF\r
197# ifdef MSDOS\r
198 /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),\r
199 but for now we just assume it doesn't. */\r
200# define NO_vsnprintf\r
201# endif\r
202# ifdef __TURBOC__\r
203# define NO_vsnprintf\r
204# endif\r
205# ifdef WIN32\r
206 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */\r
207# if !defined(vsnprintf) && !defined(NO_vsnprintf)\r
208# define vsnprintf _vsnprintf\r
209# endif\r
210# endif\r
211# ifdef __SASC\r
212# define NO_vsnprintf\r
213# endif\r
214#endif\r
215#ifdef VMS\r
216# define NO_vsnprintf\r
217#endif\r
218\r
219#if defined(pyr)\r
220# define NO_MEMCPY\r
221#endif\r
222#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)\r
223 /* Use our own functions for small and medium model with MSC <= 5.0.\r
224 * You may have to use the same strategy for Borland C (untested).\r
225 * The __SC__ check is for Symantec.\r
226 */\r
227# define NO_MEMCPY\r
228#endif\r
229#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)\r
230# define HAVE_MEMCPY\r
231#endif\r
232#ifdef HAVE_MEMCPY\r
233# ifdef SMALL_MEDIUM /* MSDOS small or medium model */\r
234# define zmemcpy _fmemcpy\r
235# define zmemcmp _fmemcmp\r
236# define zmemzero(dest, len) _fmemset(dest, 0, len)\r
237# else\r
238# define zmemcpy memcpy\r
239# define zmemcmp memcmp\r
240# define zmemzero(dest, len) memset(dest, 0, len)\r
241# endif\r
242#else\r
243 extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));\r
244 extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));\r
245 extern void zmemzero OF((Bytef* dest, uInt len));\r
246#endif\r
247\r
248/* Diagnostic functions */\r
249#ifdef DEBUG\r
250# include <stdio.h>\r
251 extern int z_verbose;\r
252 extern void z_error OF((char *m));\r
253# define Assert(cond,msg) {if(!(cond)) z_error(msg);}\r
254# define Trace(x) {if (z_verbose>=0) fprintf x ;}\r
255# define Tracev(x) {if (z_verbose>0) fprintf x ;}\r
256# define Tracevv(x) {if (z_verbose>1) fprintf x ;}\r
257# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}\r
258# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}\r
259#else\r
260# define Assert(cond,msg)\r
261# define Trace(x)\r
262# define Tracev(x)\r
263# define Tracevv(x)\r
264# define Tracec(c,x)\r
265# define Tracecv(c,x)\r
266#endif\r
267\r
268\r
269voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));\r
270void zcfree OF((voidpf opaque, voidpf ptr));\r
271\r
272#define ZALLOC(strm, items, size) \\r
273 (*((strm)->zalloc))((strm)->opaque, (items), (size))\r
274#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))\r
275#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}\r
276\r
277#endif /* ZUTIL_H */\r