1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/modules/zlib/src/zutil.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,258 @@ 1.4 +/* zutil.h -- internal interface and configuration of the compression library 1.5 + * Copyright (C) 1995-2013 Jean-loup Gailly. 1.6 + * For conditions of distribution and use, see copyright notice in zlib.h 1.7 + */ 1.8 + 1.9 +/* WARNING: this file should *not* be used by applications. It is 1.10 + part of the implementation of the compression library and is 1.11 + subject to change. Applications should only use zlib.h. 1.12 + */ 1.13 + 1.14 +/* @(#) $Id$ */ 1.15 + 1.16 +#ifndef ZUTIL_H 1.17 +#define ZUTIL_H 1.18 + 1.19 +#ifdef HAVE_HIDDEN 1.20 +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 1.21 +#else 1.22 +# define ZLIB_INTERNAL 1.23 +#endif 1.24 + 1.25 +#include "zlib.h" 1.26 + 1.27 +#if defined(STDC) && !defined(Z_SOLO) 1.28 +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 1.29 +# include <stddef.h> 1.30 +# endif 1.31 +# include <string.h> 1.32 +# include <stdlib.h> 1.33 +#endif 1.34 + 1.35 +#ifdef Z_SOLO 1.36 + typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ 1.37 +#endif 1.38 + 1.39 +#ifndef local 1.40 +# define local static 1.41 +#endif 1.42 +/* compile with -Dlocal if your debugger can't find static symbols */ 1.43 + 1.44 +typedef unsigned char uch; 1.45 +typedef uch FAR uchf; 1.46 +typedef unsigned short ush; 1.47 +typedef ush FAR ushf; 1.48 +typedef unsigned long ulg; 1.49 + 1.50 +extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 1.51 +/* (size given to avoid silly warnings with Visual C++) */ 1.52 + 1.53 +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 1.54 + 1.55 +#define ERR_RETURN(strm,err) \ 1.56 + return (strm->msg = ERR_MSG(err), (err)) 1.57 +/* To be used only when the state is known to be valid */ 1.58 + 1.59 + /* common constants */ 1.60 + 1.61 +#ifndef DEF_WBITS 1.62 +# define DEF_WBITS MAX_WBITS 1.63 +#endif 1.64 +/* default windowBits for decompression. MAX_WBITS is for compression only */ 1.65 + 1.66 +#if MAX_MEM_LEVEL >= 8 1.67 +# define DEF_MEM_LEVEL 8 1.68 +#else 1.69 +# define DEF_MEM_LEVEL MAX_MEM_LEVEL 1.70 +#endif 1.71 +/* default memLevel */ 1.72 + 1.73 +#define STORED_BLOCK 0 1.74 +#define STATIC_TREES 1 1.75 +#define DYN_TREES 2 1.76 +/* The three kinds of block type */ 1.77 + 1.78 +#define MIN_MATCH 3 1.79 +#define MAX_MATCH 258 1.80 +/* The minimum and maximum match lengths */ 1.81 + 1.82 +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 1.83 + 1.84 + /* target dependencies */ 1.85 + 1.86 +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 1.87 +# define OS_CODE 0x00 1.88 +# ifndef Z_SOLO 1.89 +# if defined(__TURBOC__) || defined(__BORLANDC__) 1.90 +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 1.91 + /* Allow compilation with ANSI keywords only enabled */ 1.92 + void _Cdecl farfree( void *block ); 1.93 + void *_Cdecl farmalloc( unsigned long nbytes ); 1.94 +# else 1.95 +# include <alloc.h> 1.96 +# endif 1.97 +# else /* MSC or DJGPP */ 1.98 +# include <malloc.h> 1.99 +# endif 1.100 +# endif 1.101 +#endif 1.102 + 1.103 +#ifdef AMIGA 1.104 +# define OS_CODE 0x01 1.105 +#endif 1.106 + 1.107 +#if defined(VAXC) || defined(VMS) 1.108 +# define OS_CODE 0x02 1.109 +# define F_OPEN(name, mode) \ 1.110 + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 1.111 +#endif 1.112 + 1.113 +#if defined(ATARI) || defined(atarist) 1.114 +# define OS_CODE 0x05 1.115 +#endif 1.116 + 1.117 +#ifdef OS2 1.118 +# define OS_CODE 0x06 1.119 +# if defined(M_I86) && !defined(Z_SOLO) 1.120 +# include <malloc.h> 1.121 +# endif 1.122 +#endif 1.123 + 1.124 +#if defined(MACOS) || defined(TARGET_OS_MAC) 1.125 +# define OS_CODE 0x07 1.126 +# ifndef Z_SOLO 1.127 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 1.128 +# include <unix.h> /* for fdopen */ 1.129 +# else 1.130 +# ifndef fdopen 1.131 +# define fdopen(fd,mode) NULL /* No fdopen() */ 1.132 +# endif 1.133 +# endif 1.134 +# endif 1.135 +#endif 1.136 + 1.137 +#ifdef TOPS20 1.138 +# define OS_CODE 0x0a 1.139 +#endif 1.140 + 1.141 +#ifdef WIN32 1.142 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 1.143 +# define OS_CODE 0x0b 1.144 +# endif 1.145 +#endif 1.146 + 1.147 +#ifdef __50SERIES /* Prime/PRIMOS */ 1.148 +# define OS_CODE 0x0f 1.149 +#endif 1.150 + 1.151 +#if defined(_BEOS_) || defined(RISCOS) 1.152 +# define fdopen(fd,mode) NULL /* No fdopen() */ 1.153 +#endif 1.154 + 1.155 +#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 1.156 +# if defined(_WIN32_WCE) 1.157 +# define fdopen(fd,mode) NULL /* No fdopen() */ 1.158 +# ifndef _PTRDIFF_T_DEFINED 1.159 + typedef int ptrdiff_t; 1.160 +# define _PTRDIFF_T_DEFINED 1.161 +# endif 1.162 +# else 1.163 +# define fdopen(fd,type) _fdopen(fd,type) 1.164 +# endif 1.165 +#endif 1.166 + 1.167 +#if defined(__BORLANDC__) && !defined(MSDOS) 1.168 + #pragma warn -8004 1.169 + #pragma warn -8008 1.170 + #pragma warn -8066 1.171 +#endif 1.172 + 1.173 +/* provide prototypes for these when building zlib without LFS */ 1.174 +#if !defined(_WIN32) && \ 1.175 + (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) 1.176 + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 1.177 + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 1.178 +#endif 1.179 + 1.180 + /* common defaults */ 1.181 + 1.182 +#ifndef OS_CODE 1.183 +# define OS_CODE 0x03 /* assume Unix */ 1.184 +#endif 1.185 + 1.186 +#ifndef F_OPEN 1.187 +# define F_OPEN(name, mode) fopen((name), (mode)) 1.188 +#endif 1.189 + 1.190 + /* functions */ 1.191 + 1.192 +#if defined(pyr) || defined(Z_SOLO) 1.193 +# define NO_MEMCPY 1.194 +#endif 1.195 +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 1.196 + /* Use our own functions for small and medium model with MSC <= 5.0. 1.197 + * You may have to use the same strategy for Borland C (untested). 1.198 + * The __SC__ check is for Symantec. 1.199 + */ 1.200 +# define NO_MEMCPY 1.201 +#endif 1.202 +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 1.203 +# define HAVE_MEMCPY 1.204 +#endif 1.205 +#ifdef HAVE_MEMCPY 1.206 +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 1.207 +# define zmemcpy _fmemcpy 1.208 +# define zmemcmp _fmemcmp 1.209 +# define zmemzero(dest, len) _fmemset(dest, 0, len) 1.210 +# else 1.211 +# define zmemcpy memcpy 1.212 +# define zmemcmp memcmp 1.213 +# define zmemzero(dest, len) memset(dest, 0, len) 1.214 +# endif 1.215 +#else 1.216 + void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 1.217 + int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 1.218 + void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 1.219 +#endif 1.220 + 1.221 +/* Ignore the Mozilla build env's DEBUG unless ZLIB_DEBUG is also set. */ 1.222 +#ifndef ZLIB_DEBUG 1.223 +#undef DEBUG 1.224 +#endif 1.225 + 1.226 +/* Diagnostic functions */ 1.227 +#ifdef DEBUG 1.228 +# include <stdio.h> 1.229 + extern int ZLIB_INTERNAL z_verbose; 1.230 + extern void ZLIB_INTERNAL z_error OF((char *m)); 1.231 +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} 1.232 +# define Trace(x) {if (z_verbose>=0) fprintf x ;} 1.233 +# define Tracev(x) {if (z_verbose>0) fprintf x ;} 1.234 +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} 1.235 +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 1.236 +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 1.237 +#else 1.238 +# define Assert(cond,msg) 1.239 +# define Trace(x) 1.240 +# define Tracev(x) 1.241 +# define Tracevv(x) 1.242 +# define Tracec(c,x) 1.243 +# define Tracecv(c,x) 1.244 +#endif 1.245 + 1.246 +#ifndef Z_SOLO 1.247 + voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 1.248 + unsigned size)); 1.249 + void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 1.250 +#endif 1.251 + 1.252 +#define ZALLOC(strm, items, size) \ 1.253 + (*((strm)->zalloc))((strm)->opaque, (items), (size)) 1.254 +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 1.255 +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 1.256 + 1.257 +/* Reverse the bytes in a 32-bit value */ 1.258 +#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ 1.259 + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) 1.260 + 1.261 +#endif /* ZUTIL_H */