diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-10-07 01:57:07 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-10-07 02:11:56 -0700 |
commit | f442c1e89e99ae5a0068a2d32e7284c2623f09fd (patch) | |
tree | 1bc659f486af707673c36916c4d75ef7f517dece /zutil.h | |
parent | 518ad0177ae2f1aaefc49285b3536a6bd8d9973c (diff) | |
download | zlib-f442c1e89e99ae5a0068a2d32e7284c2623f09fd.tar.gz zlib-f442c1e89e99ae5a0068a2d32e7284c2623f09fd.tar.bz2 zlib-f442c1e89e99ae5a0068a2d32e7284c2623f09fd.zip |
Add a ./config --solo option to make zlib subset with no libary use
A common request has been the ability to compile zlib to require no
other libraries. This --solo option provides that ability. The price
is that the gz*, compress*, and uncompress functions are eliminated,
and that the user must provide memory allocation and free routines to
deflate and inflate when initializing.
Diffstat (limited to 'zutil.h')
-rw-r--r-- | zutil.h | 51 |
1 files changed, 30 insertions, 21 deletions
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | #include "zlib.h" | 22 | #include "zlib.h" |
23 | 23 | ||
24 | #ifdef STDC | 24 | #if defined(STDC) && !defined(Z_SOLO) |
25 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) | 25 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) |
26 | # include <stddef.h> | 26 | # include <stddef.h> |
27 | # endif | 27 | # endif |
@@ -29,6 +29,10 @@ | |||
29 | # include <stdlib.h> | 29 | # include <stdlib.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #ifdef Z_SOLO | ||
33 | typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ | ||
34 | #endif | ||
35 | |||
32 | #ifndef local | 36 | #ifndef local |
33 | # define local static | 37 | # define local static |
34 | #endif | 38 | #endif |
@@ -78,16 +82,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
78 | 82 | ||
79 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) | 83 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
80 | # define OS_CODE 0x00 | 84 | # define OS_CODE 0x00 |
81 | # if defined(__TURBOC__) || defined(__BORLANDC__) | 85 | # ifndef Z_SOLO |
82 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) | 86 | # if defined(__TURBOC__) || defined(__BORLANDC__) |
83 | /* Allow compilation with ANSI keywords only enabled */ | 87 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) |
84 | void _Cdecl farfree( void *block ); | 88 | /* Allow compilation with ANSI keywords only enabled */ |
85 | void *_Cdecl farmalloc( unsigned long nbytes ); | 89 | void _Cdecl farfree( void *block ); |
86 | # else | 90 | void *_Cdecl farmalloc( unsigned long nbytes ); |
87 | # include <alloc.h> | 91 | # else |
92 | # include <alloc.h> | ||
93 | # endif | ||
94 | # else /* MSC or DJGPP */ | ||
95 | # include <malloc.h> | ||
88 | # endif | 96 | # endif |
89 | # else /* MSC or DJGPP */ | ||
90 | # include <malloc.h> | ||
91 | # endif | 97 | # endif |
92 | #endif | 98 | #endif |
93 | 99 | ||
@@ -107,18 +113,20 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
107 | 113 | ||
108 | #ifdef OS2 | 114 | #ifdef OS2 |
109 | # define OS_CODE 0x06 | 115 | # define OS_CODE 0x06 |
110 | # ifdef M_I86 | 116 | # if defined(M_I86) && !defined(Z_SOLO) |
111 | # include <malloc.h> | 117 | # include <malloc.h> |
112 | # endif | 118 | # endif |
113 | #endif | 119 | #endif |
114 | 120 | ||
115 | #if defined(MACOS) || defined(TARGET_OS_MAC) | 121 | #if defined(MACOS) || defined(TARGET_OS_MAC) |
116 | # define OS_CODE 0x07 | 122 | # define OS_CODE 0x07 |
117 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os | 123 | # ifndef Z_SOLO |
118 | # include <unix.h> /* for fdopen */ | 124 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os |
119 | # else | 125 | # include <unix.h> /* for fdopen */ |
120 | # ifndef fdopen | 126 | # else |
121 | # define fdopen(fd,mode) NULL /* No fdopen() */ | 127 | # ifndef fdopen |
128 | # define fdopen(fd,mode) NULL /* No fdopen() */ | ||
129 | # endif | ||
122 | # endif | 130 | # endif |
123 | # endif | 131 | # endif |
124 | #endif | 132 | #endif |
@@ -177,7 +185,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
177 | 185 | ||
178 | /* functions */ | 186 | /* functions */ |
179 | 187 | ||
180 | #if defined(pyr) | 188 | #if defined(pyr) || defined(Z_SOLO) |
181 | # define NO_MEMCPY | 189 | # define NO_MEMCPY |
182 | #endif | 190 | #endif |
183 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) | 191 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) |
@@ -226,10 +234,11 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
226 | # define Tracecv(c,x) | 234 | # define Tracecv(c,x) |
227 | #endif | 235 | #endif |
228 | 236 | ||
229 | 237 | #ifndef Z_SOLO | |
230 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, | 238 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, |
231 | unsigned size)); | 239 | unsigned size)); |
232 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); | 240 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); |
241 | #endif | ||
233 | 242 | ||
234 | #define ZALLOC(strm, items, size) \ | 243 | #define ZALLOC(strm, items, size) \ |
235 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) | 244 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |