xref: /OK3568_Linux_fs/u-boot/lib/zlib/zutil.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* zutil.h -- internal interface and configuration of the compression library
2*4882a593Smuzhiyun  * Copyright (C) 1995-2005 Jean-loup Gailly.
3*4882a593Smuzhiyun  * For conditions of distribution and use, see copyright notice in zlib.h
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun /* WARNING: this file should *not* be used by applications. It is
7*4882a593Smuzhiyun    part of the implementation of the compression library and is
8*4882a593Smuzhiyun    subject to change. Applications should only use zlib.h.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /* @(#) $Id$ */
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #ifndef ZUTIL_H
14*4882a593Smuzhiyun #define ZUTIL_H
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #define ZLIB_INTERNAL
17*4882a593Smuzhiyun #include "zlib.h"
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #ifdef STDC
20*4882a593Smuzhiyun #  ifndef _WIN32_WCE
21*4882a593Smuzhiyun #    include <stddef.h>
22*4882a593Smuzhiyun #  endif
23*4882a593Smuzhiyun #  include <string.h>
24*4882a593Smuzhiyun #  include <stdlib.h>
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun #ifdef NO_ERRNO_H
27*4882a593Smuzhiyun #   ifdef _WIN32_WCE
28*4882a593Smuzhiyun       /* The Microsoft C Run-Time Library for Windows CE doesn't have
29*4882a593Smuzhiyun        * errno.  We define it as a global variable to simplify porting.
30*4882a593Smuzhiyun        * Its value is always 0 and should not be used.  We rename it to
31*4882a593Smuzhiyun        * avoid conflict with other libraries that use the same workaround.
32*4882a593Smuzhiyun        */
33*4882a593Smuzhiyun #     define errno z_errno
34*4882a593Smuzhiyun #   endif
35*4882a593Smuzhiyun     extern int errno;
36*4882a593Smuzhiyun #else
37*4882a593Smuzhiyun #  ifndef _WIN32_WCE
38*4882a593Smuzhiyun #    include <errno.h>
39*4882a593Smuzhiyun #  endif
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #ifndef local
43*4882a593Smuzhiyun #  define local static
44*4882a593Smuzhiyun #endif
45*4882a593Smuzhiyun /* compile with -Dlocal if your debugger can't find static symbols */
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun typedef unsigned char  uch;
48*4882a593Smuzhiyun typedef uch FAR uchf;
49*4882a593Smuzhiyun typedef unsigned short ush;
50*4882a593Smuzhiyun typedef ush FAR ushf;
51*4882a593Smuzhiyun typedef unsigned long  ulg;
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
54*4882a593Smuzhiyun /* (size given to avoid silly warnings with Visual C++) */
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun #define ERR_RETURN(strm,err) \
59*4882a593Smuzhiyun   return (strm->msg = (char*)ERR_MSG(err), (err))
60*4882a593Smuzhiyun /* To be used only when the state is known to be valid */
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun         /* common constants */
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun #ifndef DEF_WBITS
65*4882a593Smuzhiyun #  define DEF_WBITS MAX_WBITS
66*4882a593Smuzhiyun #endif
67*4882a593Smuzhiyun /* default windowBits for decompression. MAX_WBITS is for compression only */
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #if MAX_MEM_LEVEL >= 8
70*4882a593Smuzhiyun #  define DEF_MEM_LEVEL 8
71*4882a593Smuzhiyun #else
72*4882a593Smuzhiyun #  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
73*4882a593Smuzhiyun #endif
74*4882a593Smuzhiyun /* default memLevel */
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun #define STORED_BLOCK 0
77*4882a593Smuzhiyun #define STATIC_TREES 1
78*4882a593Smuzhiyun #define DYN_TREES    2
79*4882a593Smuzhiyun /* The three kinds of block type */
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun #define MIN_MATCH  3
82*4882a593Smuzhiyun #define MAX_MATCH  258
83*4882a593Smuzhiyun /* The minimum and maximum match lengths */
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun 	 /* functions */
86*4882a593Smuzhiyun #ifdef CONFIG_GZIP_COMPRESSED
87*4882a593Smuzhiyun #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
88*4882a593Smuzhiyun #  define OS_CODE  0x03  /* assume Unix */
89*4882a593Smuzhiyun #endif
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun #include <linux/string.h>
92*4882a593Smuzhiyun #define zmemcpy memcpy
93*4882a593Smuzhiyun #define zmemcmp memcmp
94*4882a593Smuzhiyun #define zmemzero(dest, len) memset(dest, 0, len)
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun /* Diagnostic functions */
97*4882a593Smuzhiyun #ifdef DEBUG
98*4882a593Smuzhiyun /* Not valid for U-Boot
99*4882a593Smuzhiyun #  include <stdio.h> */
100*4882a593Smuzhiyun    extern int z_verbose;
101*4882a593Smuzhiyun    extern void z_error    OF((char *m));
102*4882a593Smuzhiyun #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
103*4882a593Smuzhiyun #  define Trace(x) {if (z_verbose>=0) fprintf x ;}
104*4882a593Smuzhiyun #  define Tracev(x) {if (z_verbose>0) fprintf x ;}
105*4882a593Smuzhiyun #  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
106*4882a593Smuzhiyun #  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
107*4882a593Smuzhiyun #  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
108*4882a593Smuzhiyun #else
109*4882a593Smuzhiyun #  define Assert(cond,msg)
110*4882a593Smuzhiyun #  define Trace(x)
111*4882a593Smuzhiyun #  define Tracev(x)
112*4882a593Smuzhiyun #  define Tracevv(x)
113*4882a593Smuzhiyun #  define Tracec(c,x)
114*4882a593Smuzhiyun #  define Tracecv(c,x)
115*4882a593Smuzhiyun #endif
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
119*4882a593Smuzhiyun void   zcfree  OF((voidpf opaque, voidpf ptr, unsigned size));
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun #define ZALLOC(strm, items, size) \
122*4882a593Smuzhiyun            (*((strm)->zalloc))((strm)->opaque, (items), (size))
123*4882a593Smuzhiyun #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr), 0)
124*4882a593Smuzhiyun #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun #endif /* ZUTIL_H */
127