1355d67fcSMatthew Dillon /* zutil.h -- internal interface and configuration of the compression library 2355d67fcSMatthew Dillon * Copyright (C) 1995-2013 Jean-loup Gailly. 3355d67fcSMatthew Dillon * For conditions of distribution and use, see copyright notice in zlib.h 4355d67fcSMatthew Dillon */ 5355d67fcSMatthew Dillon 6355d67fcSMatthew Dillon /* WARNING: this file should *not* be used by applications. It is 7355d67fcSMatthew Dillon part of the implementation of the compression library and is 8355d67fcSMatthew Dillon subject to change. Applications should only use zlib.h. 9355d67fcSMatthew Dillon */ 10355d67fcSMatthew Dillon 11355d67fcSMatthew Dillon /* @(#) $Id$ */ 12355d67fcSMatthew Dillon 13355d67fcSMatthew Dillon #ifndef ZUTIL_H 14355d67fcSMatthew Dillon #define ZUTIL_H 15355d67fcSMatthew Dillon 16355d67fcSMatthew Dillon #ifdef HAVE_HIDDEN 17355d67fcSMatthew Dillon # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 18355d67fcSMatthew Dillon #else 19355d67fcSMatthew Dillon # define ZLIB_INTERNAL 20355d67fcSMatthew Dillon #endif 21355d67fcSMatthew Dillon 2289202d69Szrj #include <sys/param.h> /* for panic() */ 23355d67fcSMatthew Dillon #include "hammer2_zlib.h" 24355d67fcSMatthew Dillon 25355d67fcSMatthew Dillon #ifndef local 26355d67fcSMatthew Dillon # define local static 27355d67fcSMatthew Dillon #endif 28355d67fcSMatthew Dillon /* compile with -Dlocal if your debugger can't find static symbols */ 29355d67fcSMatthew Dillon 30355d67fcSMatthew Dillon typedef unsigned char uch; 31355d67fcSMatthew Dillon typedef uch FAR uchf; 32355d67fcSMatthew Dillon typedef unsigned short ush; 33355d67fcSMatthew Dillon typedef ush FAR ushf; 34355d67fcSMatthew Dillon typedef unsigned long ulg; 35355d67fcSMatthew Dillon 36355d67fcSMatthew Dillon extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 37355d67fcSMatthew Dillon /* (size given to avoid silly warnings with Visual C++) */ 38355d67fcSMatthew Dillon 39355d67fcSMatthew Dillon #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 40355d67fcSMatthew Dillon 41355d67fcSMatthew Dillon #define ERR_RETURN(strm,err) \ 42355d67fcSMatthew Dillon return (strm->msg = ERR_MSG(err), (err)) 43355d67fcSMatthew Dillon /* To be used only when the state is known to be valid */ 44355d67fcSMatthew Dillon 45355d67fcSMatthew Dillon /* common constants */ 46355d67fcSMatthew Dillon 47355d67fcSMatthew Dillon #ifndef DEF_WBITS 48355d67fcSMatthew Dillon # define DEF_WBITS MAX_WBITS 49355d67fcSMatthew Dillon #endif 50355d67fcSMatthew Dillon /* default windowBits for decompression. MAX_WBITS is for compression only */ 51355d67fcSMatthew Dillon 52355d67fcSMatthew Dillon #if MAX_MEM_LEVEL >= 8 53355d67fcSMatthew Dillon # define DEF_MEM_LEVEL 8 54355d67fcSMatthew Dillon #else 55355d67fcSMatthew Dillon # define DEF_MEM_LEVEL MAX_MEM_LEVEL 56355d67fcSMatthew Dillon #endif 57355d67fcSMatthew Dillon /* default memLevel */ 58355d67fcSMatthew Dillon 59355d67fcSMatthew Dillon #define STORED_BLOCK 0 60355d67fcSMatthew Dillon #define STATIC_TREES 1 61355d67fcSMatthew Dillon #define DYN_TREES 2 62355d67fcSMatthew Dillon /* The three kinds of block type */ 63355d67fcSMatthew Dillon 64355d67fcSMatthew Dillon #define MIN_MATCH 3 65355d67fcSMatthew Dillon #define MAX_MATCH 258 66355d67fcSMatthew Dillon /* The minimum and maximum match lengths */ 67355d67fcSMatthew Dillon 68355d67fcSMatthew Dillon #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 69355d67fcSMatthew Dillon 70355d67fcSMatthew Dillon /* target dependencies */ 71355d67fcSMatthew Dillon 72355d67fcSMatthew Dillon #if defined(__BORLANDC__) && !defined(MSDOS) 73355d67fcSMatthew Dillon #pragma warn -8004 74355d67fcSMatthew Dillon #pragma warn -8008 75355d67fcSMatthew Dillon #pragma warn -8066 76355d67fcSMatthew Dillon #endif 77355d67fcSMatthew Dillon 78355d67fcSMatthew Dillon /* provide prototypes for these when building zlib without LFS */ 79355d67fcSMatthew Dillon #if !defined(_WIN32) && \ 80355d67fcSMatthew Dillon (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) 81355d67fcSMatthew Dillon uLong adler32_combine64(uLong, uLong, z_off_t); 82355d67fcSMatthew Dillon #endif 83355d67fcSMatthew Dillon 84355d67fcSMatthew Dillon /* common defaults */ 85355d67fcSMatthew Dillon 86355d67fcSMatthew Dillon #ifndef OS_CODE 87355d67fcSMatthew Dillon # define OS_CODE 0x03 /* assume Unix */ 88355d67fcSMatthew Dillon #endif 89355d67fcSMatthew Dillon 90355d67fcSMatthew Dillon #ifndef F_OPEN 91355d67fcSMatthew Dillon # define F_OPEN(name, mode) fopen((name), (mode)) 92355d67fcSMatthew Dillon #endif 93355d67fcSMatthew Dillon 94355d67fcSMatthew Dillon /* functions */ 95355d67fcSMatthew Dillon 96355d67fcSMatthew Dillon #if defined(pyr) || defined(Z_SOLO) 97355d67fcSMatthew Dillon # define NO_MEMCPY 98355d67fcSMatthew Dillon #endif 99355d67fcSMatthew Dillon #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 100355d67fcSMatthew Dillon /* Use our own functions for small and medium model with MSC <= 5.0. 101355d67fcSMatthew Dillon * You may have to use the same strategy for Borland C (untested). 102355d67fcSMatthew Dillon * The __SC__ check is for Symantec. 103355d67fcSMatthew Dillon */ 104355d67fcSMatthew Dillon # define NO_MEMCPY 105355d67fcSMatthew Dillon #endif 106355d67fcSMatthew Dillon #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 107355d67fcSMatthew Dillon # define HAVE_MEMCPY 108355d67fcSMatthew Dillon #endif 109355d67fcSMatthew Dillon #ifdef HAVE_MEMCPY 110355d67fcSMatthew Dillon # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 111355d67fcSMatthew Dillon # define zmemcpy _fmemcpy 112355d67fcSMatthew Dillon # define zmemcmp _fmemcmp 113355d67fcSMatthew Dillon # define zmemzero(dest, len) _fmemset(dest, 0, len) 114355d67fcSMatthew Dillon # else 115355d67fcSMatthew Dillon # define zmemcpy memcpy 116355d67fcSMatthew Dillon # define zmemcmp memcmp 117355d67fcSMatthew Dillon # define zmemzero(dest, len) memset(dest, 0, len) 118355d67fcSMatthew Dillon # endif 119355d67fcSMatthew Dillon #else 120355d67fcSMatthew Dillon void ZLIB_INTERNAL zmemcpy((Bytef* dest, const Bytef* source, uInt len)); 121355d67fcSMatthew Dillon int ZLIB_INTERNAL zmemcmp((const Bytef* s1, const Bytef* s2, uInt len)); 122355d67fcSMatthew Dillon void ZLIB_INTERNAL zmemzero((Bytef* dest, uInt len)); 123355d67fcSMatthew Dillon #endif 124355d67fcSMatthew Dillon 125355d67fcSMatthew Dillon /* Diagnostic functions */ 126*a46112e5SSascha Wildner #ifdef H2_ZLIB_DEBUG 127355d67fcSMatthew Dillon # include <stdio.h> 128355d67fcSMatthew Dillon extern int ZLIB_INTERNAL z_verbose; 12989202d69Szrj extern void ZLIB_INTERNAL z_error(char *m); 130355d67fcSMatthew Dillon # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 131355d67fcSMatthew Dillon # define Trace(x) {if (z_verbose>=0) fprintf x ;} 132355d67fcSMatthew Dillon # define Tracev(x) {if (z_verbose>0) fprintf x ;} 133355d67fcSMatthew Dillon # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 134355d67fcSMatthew Dillon # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 135355d67fcSMatthew Dillon # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 136355d67fcSMatthew Dillon #else 137355d67fcSMatthew Dillon # define Assert(cond,msg) 138355d67fcSMatthew Dillon # define Trace(x) 139355d67fcSMatthew Dillon # define Tracev(x) 140355d67fcSMatthew Dillon # define Tracevv(x) 141355d67fcSMatthew Dillon # define Tracec(c,x) 142355d67fcSMatthew Dillon # define Tracecv(c,x) 143355d67fcSMatthew Dillon #endif 144355d67fcSMatthew Dillon 145355d67fcSMatthew Dillon /* Reverse the bytes in a 32-bit value */ 146355d67fcSMatthew Dillon #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ 147355d67fcSMatthew Dillon (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) 148355d67fcSMatthew Dillon 149355d67fcSMatthew Dillon #endif /* ZUTIL_H */ 150