Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
zutil.h
00001 /* zutil.h -- internal interface and configuration of the compression library 00002 * Copyright (C) 1995-2012 Jean-loup Gailly. 00003 * For conditions of distribution and use, see copyright notice in zlib.h 00004 */ 00005 00006 /* WARNING: this file should *not* be used by applications. It is 00007 part of the implementation of the compression library and is 00008 subject to change. Applications should only use zlib.h. 00009 */ 00010 00011 /* @(#) $Id$ */ 00012 00013 #ifndef ZUTIL_H 00014 #define ZUTIL_H 00015 00016 #ifdef HAVE_HIDDEN 00017 # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 00018 #else 00019 # define ZLIB_INTERNAL 00020 #endif 00021 00022 #include "zlib.h" 00023 00024 #if defined(STDC) && !defined(Z_SOLO) 00025 # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 00026 # include <stddef.h> 00027 # endif 00028 # include <string.h> 00029 # include <stdlib.h> 00030 #endif 00031 00032 #ifdef Z_SOLO 00033 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ 00034 #endif 00035 00036 #ifndef local 00037 # define local static 00038 #endif 00039 /* compile with -Dlocal if your debugger can't find static symbols */ 00040 00041 typedef unsigned char uch; 00042 typedef uch FAR uchf; 00043 typedef unsigned short ush; 00044 typedef ush FAR ushf; 00045 typedef unsigned long ulg; 00046 00047 extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 00048 /* (size given to avoid silly warnings with Visual C++) */ 00049 00050 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 00051 00052 #define ERR_RETURN(strm,err) \ 00053 return (strm->msg = (char*)ERR_MSG(err), (err)) 00054 /* To be used only when the state is known to be valid */ 00055 00056 /* common constants */ 00057 00058 #ifndef DEF_WBITS 00059 # define DEF_WBITS MAX_WBITS 00060 #endif 00061 /* default windowBits for decompression. MAX_WBITS is for compression only */ 00062 00063 #if MAX_MEM_LEVEL >= 8 00064 # define DEF_MEM_LEVEL 8 00065 #else 00066 # define DEF_MEM_LEVEL MAX_MEM_LEVEL 00067 #endif 00068 /* default memLevel */ 00069 00070 #define STORED_BLOCK 0 00071 #define STATIC_TREES 1 00072 #define DYN_TREES 2 00073 /* The three kinds of block type */ 00074 00075 #define MIN_MATCH 3 00076 #define MAX_MATCH 258 00077 /* The minimum and maximum match lengths */ 00078 00079 #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 00080 00081 /* target dependencies */ 00082 00083 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 00084 # define OS_CODE 0x00 00085 # ifndef Z_SOLO 00086 # if defined(__TURBOC__) || defined(__BORLANDC__) 00087 # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 00088 /* Allow compilation with ANSI keywords only enabled */ 00089 void _Cdecl farfree( void *block ); 00090 void *_Cdecl farmalloc( unsigned long nbytes ); 00091 # else 00092 # include <alloc.h> 00093 # endif 00094 # else /* MSC or DJGPP */ 00095 # include <malloc.h> 00096 # endif 00097 # endif 00098 #endif 00099 00100 #ifdef AMIGA 00101 # define OS_CODE 0x01 00102 #endif 00103 00104 #if defined(VAXC) || defined(VMS) 00105 # define OS_CODE 0x02 00106 # define F_OPEN(name, mode) \ 00107 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 00108 #endif 00109 00110 #if defined(ATARI) || defined(atarist) 00111 # define OS_CODE 0x05 00112 #endif 00113 00114 #ifdef OS2 00115 # define OS_CODE 0x06 00116 # if defined(M_I86) && !defined(Z_SOLO) 00117 # include <malloc.h> 00118 # endif 00119 #endif 00120 00121 #if defined(MACOS) || defined(TARGET_OS_MAC) 00122 # define OS_CODE 0x07 00123 # ifndef Z_SOLO 00124 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 00125 # include <unix.h> /* for fdopen */ 00126 # else 00127 # ifndef fdopen 00128 # define fdopen(fd,mode) NULL /* No fdopen() */ 00129 # endif 00130 # endif 00131 # endif 00132 #endif 00133 00134 #ifdef TOPS20 00135 # define OS_CODE 0x0a 00136 #endif 00137 00138 #ifdef WIN32 00139 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 00140 # define OS_CODE 0x0b 00141 # endif 00142 #endif 00143 00144 #ifdef __50SERIES /* Prime/PRIMOS */ 00145 # define OS_CODE 0x0f 00146 #endif 00147 00148 #if defined(_BEOS_) || defined(RISCOS) 00149 # define fdopen(fd,mode) NULL /* No fdopen() */ 00150 #endif 00151 00152 #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 00153 # if defined(_WIN32_WCE) 00154 # define fdopen(fd,mode) NULL /* No fdopen() */ 00155 # ifndef _PTRDIFF_T_DEFINED 00156 typedef int ptrdiff_t; 00157 # define _PTRDIFF_T_DEFINED 00158 # endif 00159 # else 00160 # define fdopen(fd,type) _fdopen(fd,type) 00161 # endif 00162 #endif 00163 00164 #if defined(__BORLANDC__) && !defined(MSDOS) 00165 #pragma warn -8004 00166 #pragma warn -8008 00167 #pragma warn -8066 00168 #endif 00169 00170 /* provide prototypes for these when building zlib without LFS */ 00171 #if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) 00172 ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 00173 ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 00174 #endif 00175 00176 /* common defaults */ 00177 00178 #ifndef OS_CODE 00179 # define OS_CODE 0x03 /* assume Unix */ 00180 #endif 00181 00182 #ifndef F_OPEN 00183 # define F_OPEN(name, mode) fopen((name), (mode)) 00184 #endif 00185 00186 /* functions */ 00187 00188 #if defined(pyr) || defined(Z_SOLO) 00189 # define NO_MEMCPY 00190 #endif 00191 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 00192 /* Use our own functions for small and medium model with MSC <= 5.0. 00193 * You may have to use the same strategy for Borland C (untested). 00194 * The __SC__ check is for Symantec. 00195 */ 00196 # define NO_MEMCPY 00197 #endif 00198 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 00199 # define HAVE_MEMCPY 00200 #endif 00201 #ifdef HAVE_MEMCPY 00202 # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 00203 # define zmemcpy _fmemcpy 00204 # define zmemcmp _fmemcmp 00205 # define zmemzero(dest, len) _fmemset(dest, 0, len) 00206 # else 00207 # define zmemcpy memcpy 00208 # define zmemcmp memcmp 00209 # define zmemzero(dest, len) memset(dest, 0, len) 00210 # endif 00211 #else 00212 void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 00213 int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 00214 void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 00215 #endif 00216 00217 /* Diagnostic functions */ 00218 #ifdef DEBUG 00219 # include <stdio.h> 00220 extern int ZLIB_INTERNAL z_verbose; 00221 extern void ZLIB_INTERNAL z_error OF((char *m)); 00222 # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 00223 # define Trace(x) {if (z_verbose>=0) fprintf x ;} 00224 # define Tracev(x) {if (z_verbose>0) fprintf x ;} 00225 # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 00226 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 00227 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 00228 #else 00229 # define Assert(cond,msg) 00230 # define Trace(x) 00231 # define Tracev(x) 00232 # define Tracevv(x) 00233 # define Tracec(c,x) 00234 # define Tracecv(c,x) 00235 #endif 00236 00237 #ifndef Z_SOLO 00238 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 00239 unsigned size)); 00240 void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 00241 #endif 00242 00243 #define ZALLOC(strm, items, size) \ 00244 (*((strm)->zalloc))((strm)->opaque, (items), (size)) 00245 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 00246 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 00247 00248 /* Reverse the bytes in a 32-bit value */ 00249 #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ 00250 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) 00251 00252 #endif /* ZUTIL_H */
Generated on Wed Jul 13 2022 09:05:31 by
1.7.2