ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

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