annotate src/zlib-1.2.7/zutil.h @ 42:2cd0e3b3e1fd

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