xref: /illumos-gate/usr/src/contrib/zlib/zconf.h (revision 17a5fa85fe0c34b1146222e40a80b42f2aae8500)
1 /* zconf.h -- configuration of the zlib compression library
2  * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
3  * For conditions of distribution and use, see copyright notice in zlib.h
4  */
5 
6 #ifndef ZCONF_H
7 #define ZCONF_H
8 
9 #ifdef _KERNEL
10 #include <sys/param.h>
11 #include <sys/systm.h>
12 #include <sys/types.h>
13 #endif
14 
15 /*
16  * We don't want to turn on zlib's debugging.
17  */
18 #undef DEBUG
19 
20 #ifdef _KERNEL
21 /*
22  * We define our own memory allocation and deallocation routines that use kmem.
23  */
24 #define	MY_ZCALLOC
25 #endif
26 #define	HAVE_MEMCPY
27 #define	ZLIB_CONST
28 #define	Z_PREFIX
29 
30 /*
31  * If you *really* need a unique prefix for all types and library functions,
32  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
33  * Even better than compiling with -DZ_PREFIX would be to use configure to set
34  * this permanently in zconf.h using "./configure --zprefix".
35  */
36 #ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
37 #  define Z_PREFIX_SET
38 
39 /* all linked symbols and init macros */
40 #  define _dist_code            z__dist_code
41 #  define _length_code          z__length_code
42 #  define _tr_align             z__tr_align
43 #  define _tr_flush_bits        z__tr_flush_bits
44 #  define _tr_flush_block       z__tr_flush_block
45 #  define _tr_init              z__tr_init
46 #  define _tr_stored_block      z__tr_stored_block
47 #  define _tr_tally             z__tr_tally
48 #  define adler32               z_adler32
49 #  define adler32_combine       z_adler32_combine
50 #  define adler32_combine64     z_adler32_combine64
51 #  define adler32_z             z_adler32_z
52 #  ifndef Z_SOLO
53 #    define compress              zz_compress
54 #    define compress2             z_compress2
55 #    define compressBound         z_compressBound
56 #  endif
57 #  define crc32                 z_crc32
58 #  define crc32_combine         z_crc32_combine
59 #  define crc32_combine64       z_crc32_combine64
60 #  define crc32_z               z_crc32_z
61 #  define deflate               z_deflate
62 #  define deflateBound          z_deflateBound
63 #  define deflateCopy           z_deflateCopy
64 #  define deflateEnd            z_deflateEnd
65 #  define deflateGetDictionary  z_deflateGetDictionary
66 #  define deflateInit           z_deflateInit
67 #  define deflateInit2          z_deflateInit2
68 #  define deflateInit2_         z_deflateInit2_
69 #  define deflateInit_          z_deflateInit_
70 #  define deflateParams         z_deflateParams
71 #  define deflatePending        z_deflatePending
72 #  define deflatePrime          z_deflatePrime
73 #  define deflateReset          z_deflateReset
74 #  define deflateResetKeep      z_deflateResetKeep
75 #  define deflateSetDictionary  z_deflateSetDictionary
76 #  define deflateSetHeader      z_deflateSetHeader
77 #  define deflateTune           z_deflateTune
78 #  define deflate_copyright     z_deflate_copyright
79 #  define get_crc_table         z_get_crc_table
80 #  ifndef Z_SOLO
81 #    define gz_error              z_gz_error
82 #    define gz_intmax             z_gz_intmax
83 #    define gz_strwinerror        z_gz_strwinerror
84 #    define gzbuffer              z_gzbuffer
85 #    define gzclearerr            z_gzclearerr
86 #    define gzclose               z_gzclose
87 #    define gzclose_r             z_gzclose_r
88 #    define gzclose_w             z_gzclose_w
89 #    define gzdirect              z_gzdirect
90 #    define gzdopen               z_gzdopen
91 #    define gzeof                 z_gzeof
92 #    define gzerror               z_gzerror
93 #    define gzflush               z_gzflush
94 #    define gzfread               z_gzfread
95 #    define gzfwrite              z_gzfwrite
96 #    define gzgetc                z_gzgetc
97 #    define gzgetc_               z_gzgetc_
98 #    define gzgets                z_gzgets
99 #    define gzoffset              z_gzoffset
100 #    define gzoffset64            z_gzoffset64
101 #    define gzopen                z_gzopen
102 #    define gzopen64              z_gzopen64
103 #    ifdef _WIN32
104 #      define gzopen_w              z_gzopen_w
105 #    endif
106 #    define gzprintf              z_gzprintf
107 #    define gzputc                z_gzputc
108 #    define gzputs                z_gzputs
109 #    define gzread                z_gzread
110 #    define gzrewind              z_gzrewind
111 #    define gzseek                z_gzseek
112 #    define gzseek64              z_gzseek64
113 #    define gzsetparams           z_gzsetparams
114 #    define gztell                z_gztell
115 #    define gztell64              z_gztell64
116 #    define gzungetc              z_gzungetc
117 #    define gzvprintf             z_gzvprintf
118 #    define gzwrite               z_gzwrite
119 #  endif
120 #  define inflate               z_inflate
121 #  define inflateBack           z_inflateBack
122 #  define inflateBackEnd        z_inflateBackEnd
123 #  define inflateBackInit       z_inflateBackInit
124 #  define inflateBackInit_      z_inflateBackInit_
125 #  define inflateCodesUsed      z_inflateCodesUsed
126 #  define inflateCopy           z_inflateCopy
127 #  define inflateEnd            z_inflateEnd
128 #  define inflateGetDictionary  z_inflateGetDictionary
129 #  define inflateGetHeader      z_inflateGetHeader
130 #  define inflateInit           z_inflateInit
131 #  define inflateInit2          z_inflateInit2
132 #  define inflateInit2_         z_inflateInit2_
133 #  define inflateInit_          z_inflateInit_
134 #  define inflateMark           z_inflateMark
135 #  define inflatePrime          z_inflatePrime
136 #  define inflateReset          z_inflateReset
137 #  define inflateReset2         z_inflateReset2
138 #  define inflateResetKeep      z_inflateResetKeep
139 #  define inflateSetDictionary  z_inflateSetDictionary
140 #  define inflateSync           z_inflateSync
141 #  define inflateSyncPoint      z_inflateSyncPoint
142 #  define inflateUndermine      z_inflateUndermine
143 #  define inflateValidate       z_inflateValidate
144 #  define inflate_copyright     z_inflate_copyright
145 #  define inflate_fast          z_inflate_fast
146 #  define inflate_table         z_inflate_table
147 #  ifndef Z_SOLO
148 #    define uncompress            zz_uncompress
149 #    define uncompress2           z_uncompress2
150 #  endif
151 #  define zError                z_zError
152 #  ifndef Z_SOLO
153 #    define zcalloc               z_zcalloc
154 #    define zcfree                z_zcfree
155 #  endif
156 #  define zlibCompileFlags      z_zlibCompileFlags
157 #  define zlibVersion           z_zlibVersion
158 
159 /* all zlib typedefs in zlib.h and zconf.h */
160 #  define Byte                  z_Byte
161 #  define Bytef                 z_Bytef
162 #  define alloc_func            z_alloc_func
163 #  define charf                 z_charf
164 #  define free_func             z_free_func
165 #  ifndef Z_SOLO
166 #    define gzFile                z_gzFile
167 #  endif
168 #  define gz_header             z_gz_header
169 #  define gz_headerp            z_gz_headerp
170 #  define in_func               z_in_func
171 #  define intf                  z_intf
172 #  define out_func              z_out_func
173 #  define uInt                  z_uInt
174 #  define uIntf                 z_uIntf
175 #  define uLong                 z_uLong
176 #  define uLongf                z_uLongf
177 #  define voidp                 z_voidp
178 #  define voidpc                z_voidpc
179 #  define voidpf                z_voidpf
180 
181 /* all zlib structs in zlib.h and zconf.h */
182 #  define gz_header_s           z_gz_header_s
183 #  define internal_state        z_internal_state
184 
185 #endif
186 
187 #if defined(__MSDOS__) && !defined(MSDOS)
188 #  define MSDOS
189 #endif
190 #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
191 #  define OS2
192 #endif
193 #if defined(_WINDOWS) && !defined(WINDOWS)
194 #  define WINDOWS
195 #endif
196 #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
197 #  ifndef WIN32
198 #    define WIN32
199 #  endif
200 #endif
201 #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
202 #  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
203 #    ifndef SYS16BIT
204 #      define SYS16BIT
205 #    endif
206 #  endif
207 #endif
208 
209 /*
210  * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
211  * than 64k bytes at a time (needed on systems with 16-bit int).
212  */
213 #ifdef SYS16BIT
214 #  define MAXSEG_64K
215 #endif
216 #ifdef MSDOS
217 #  define UNALIGNED_OK
218 #endif
219 
220 #ifdef __STDC_VERSION__
221 #  ifndef STDC
222 #    define STDC
223 #  endif
224 #  if __STDC_VERSION__ >= 199901L
225 #    ifndef STDC99
226 #      define STDC99
227 #    endif
228 #  endif
229 #endif
230 #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
231 #  define STDC
232 #endif
233 #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
234 #  define STDC
235 #endif
236 #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
237 #  define STDC
238 #endif
239 #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
240 #  define STDC
241 #endif
242 
243 #if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
244 #  define STDC
245 #endif
246 
247 #ifndef STDC
248 #  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
249 #    define const       /* note: need a more gentle solution here */
250 #  endif
251 #endif
252 
253 #if defined(ZLIB_CONST) && !defined(z_const)
254 #  define z_const const
255 #else
256 #  define z_const
257 #endif
258 
259 #ifdef Z_SOLO
260    typedef unsigned long z_size_t;
261 #else
262 #  define z_longlong long long
263 #  if defined(NO_SIZE_T)
264      typedef unsigned NO_SIZE_T z_size_t;
265 #  elif defined(STDC)
266 #    ifndef _KERNEL
267 #        include <stddef.h>
268 #    endif
269      typedef size_t z_size_t;
270 #  else
271      typedef unsigned long z_size_t;
272 #  endif
273 #  undef z_longlong
274 #endif
275 
276 /* Maximum value for memLevel in deflateInit2 */
277 #ifndef MAX_MEM_LEVEL
278 #  ifdef MAXSEG_64K
279 #    define MAX_MEM_LEVEL 8
280 #  else
281 #    define MAX_MEM_LEVEL 9
282 #  endif
283 #endif
284 
285 /* Maximum value for windowBits in deflateInit2 and inflateInit2.
286  * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
287  * created by gzip. (Files created by minigzip can still be extracted by
288  * gzip.)
289  */
290 #ifndef MAX_WBITS
291 #  define MAX_WBITS   15 /* 32K LZ77 window */
292 #endif
293 
294 /* The memory requirements for deflate are (in bytes):
295             (1 << (windowBits+2)) +  (1 << (memLevel+9))
296  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
297  plus a few kilobytes for small objects. For example, if you want to reduce
298  the default memory requirements from 256K to 128K, compile with
299      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
300  Of course this will generally degrade compression (there's no free lunch).
301 
302    The memory requirements for inflate are (in bytes) 1 << windowBits
303  that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
304  for small objects.
305 */
306 
307                         /* Type declarations */
308 
309 #ifndef OF /* function prototypes */
310 #  ifdef STDC
311 #    define OF(args)  args
312 #  else
313 #    define OF(args)  ()
314 #  endif
315 #endif
316 
317 #ifndef Z_ARG /* function prototypes for stdarg */
318 #  if defined(STDC) || defined(Z_HAVE_STDARG_H)
319 #    define Z_ARG(args)  args
320 #  else
321 #    define Z_ARG(args)  ()
322 #  endif
323 #endif
324 
325 /* The following definitions for FAR are needed only for MSDOS mixed
326  * model programming (small or medium model with some far allocations).
327  * This was tested only with MSC; for other MSDOS compilers you may have
328  * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
329  * just define FAR to be empty.
330  */
331 #ifdef SYS16BIT
332 #  if defined(M_I86SM) || defined(M_I86MM)
333      /* MSC small or medium model */
334 #    define SMALL_MEDIUM
335 #    ifdef _MSC_VER
336 #      define FAR _far
337 #    else
338 #      define FAR far
339 #    endif
340 #  endif
341 #  if (defined(__SMALL__) || defined(__MEDIUM__))
342      /* Turbo C small or medium model */
343 #    define SMALL_MEDIUM
344 #    ifdef __BORLANDC__
345 #      define FAR _far
346 #    else
347 #      define FAR far
348 #    endif
349 #  endif
350 #endif
351 
352 #if defined(WINDOWS) || defined(WIN32)
353    /* If building or using zlib as a DLL, define ZLIB_DLL.
354     * This is not mandatory, but it offers a little performance increase.
355     */
356 #  ifdef ZLIB_DLL
357 #    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
358 #      ifdef ZLIB_INTERNAL
359 #        define ZEXTERN extern __declspec(dllexport)
360 #      else
361 #        define ZEXTERN extern __declspec(dllimport)
362 #      endif
363 #    endif
364 #  endif  /* ZLIB_DLL */
365    /* If building or using zlib with the WINAPI/WINAPIV calling convention,
366     * define ZLIB_WINAPI.
367     * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
368     */
369 #  ifdef ZLIB_WINAPI
370 #    ifdef FAR
371 #      undef FAR
372 #    endif
373 #    include <windows.h>
374      /* No need for _export, use ZLIB.DEF instead. */
375      /* For complete Windows compatibility, use WINAPI, not __stdcall. */
376 #    define ZEXPORT WINAPI
377 #    ifdef WIN32
378 #      define ZEXPORTVA WINAPIV
379 #    else
380 #      define ZEXPORTVA FAR CDECL
381 #    endif
382 #  endif
383 #endif
384 
385 #if defined (__BEOS__)
386 #  ifdef ZLIB_DLL
387 #    ifdef ZLIB_INTERNAL
388 #      define ZEXPORT   __declspec(dllexport)
389 #      define ZEXPORTVA __declspec(dllexport)
390 #    else
391 #      define ZEXPORT   __declspec(dllimport)
392 #      define ZEXPORTVA __declspec(dllimport)
393 #    endif
394 #  endif
395 #endif
396 
397 #ifndef ZEXTERN
398 #  define ZEXTERN extern
399 #endif
400 #ifndef ZEXPORT
401 #  define ZEXPORT
402 #endif
403 #ifndef ZEXPORTVA
404 #  define ZEXPORTVA
405 #endif
406 
407 #ifndef FAR
408 #  define FAR
409 #endif
410 
411 #if !defined(__MACTYPES__)
412 typedef unsigned char  Byte;  /* 8 bits */
413 #endif
414 typedef unsigned int   uInt;  /* 16 bits or more */
415 typedef unsigned long  uLong; /* 32 bits or more */
416 
417 #ifdef SMALL_MEDIUM
418    /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
419 #  define Bytef Byte FAR
420 #else
421    typedef Byte  FAR Bytef;
422 #endif
423 typedef char  FAR charf;
424 typedef int   FAR intf;
425 typedef uInt  FAR uIntf;
426 typedef uLong FAR uLongf;
427 
428 #ifdef STDC
429    typedef void const *voidpc;
430    typedef void FAR   *voidpf;
431    typedef void       *voidp;
432 #else
433    typedef Byte const *voidpc;
434    typedef Byte FAR   *voidpf;
435    typedef Byte       *voidp;
436 #endif
437 
438 #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
439 #  ifndef _KERNEL
440 #      include <limits.h>
441 #  endif
442 #  if (UINT_MAX == 0xffffffffUL)
443 #    define Z_U4 unsigned
444 #  elif (ULONG_MAX == 0xffffffffUL)
445 #    define Z_U4 unsigned long
446 #  elif (USHRT_MAX == 0xffffffffUL)
447 #    define Z_U4 unsigned short
448 #  endif
449 #endif
450 
451 #ifdef Z_U4
452    typedef Z_U4 z_crc_t;
453 #else
454    typedef unsigned long z_crc_t;
455 #endif
456 
457 #ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
458 #  define Z_HAVE_UNISTD_H
459 #endif
460 
461 #ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
462 #  define Z_HAVE_STDARG_H
463 #endif
464 
465 #ifdef STDC
466 #  ifndef Z_SOLO
467 #    include <sys/types.h>      /* for off_t */
468 #  endif
469 #endif
470 
471 #if defined(STDC) || defined(Z_HAVE_STDARG_H)
472 #  ifdef _KERNEL
473 #    include <sys/varargs.h>
474 #  else
475 #  ifndef Z_SOLO
476 #    include <stdarg.h>         /* for va_list */
477 #  endif
478 #  endif
479 #endif
480 
481 #ifdef _WIN32
482 #  ifndef Z_SOLO
483 #    include <stddef.h>         /* for wchar_t */
484 #  endif
485 #endif
486 
487 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
488  * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
489  * though the former does not conform to the LFS document), but considering
490  * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
491  * equivalently requesting no 64-bit operations
492  */
493 #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
494 #  undef _LARGEFILE64_SOURCE
495 #endif
496 
497 #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
498 #  define Z_HAVE_UNISTD_H
499 #endif
500 #ifndef Z_SOLO
501 #  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
502 #    ifndef _KERNEL
503 #      include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
504 #    endif
505 #    ifdef VMS
506 #      include <unixio.h>       /* for off_t */
507 #    endif
508 #    ifndef z_off_t
509 #      define z_off_t off_t
510 #    endif
511 #  endif
512 #endif
513 
514 #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
515 #  define Z_LFS64
516 #endif
517 
518 #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
519 #  define Z_LARGE64
520 #endif
521 
522 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
523 #  define Z_WANT64
524 #endif
525 
526 #if !defined(SEEK_SET) && !defined(Z_SOLO)
527 #  define SEEK_SET        0       /* Seek from beginning of file.  */
528 #  define SEEK_CUR        1       /* Seek from current position.  */
529 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
530 #endif
531 
532 #ifndef z_off_t
533 #  define z_off_t long
534 #endif
535 
536 #if !defined(_WIN32) && defined(Z_LARGE64)
537 #  define z_off64_t off64_t
538 #else
539 #  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
540 #    define z_off64_t __int64
541 #  else
542 #    define z_off64_t z_off_t
543 #  endif
544 #endif
545 
546 /* MVS linker does not support external names larger than 8 bytes */
547 #if defined(__MVS__)
548   #pragma map(deflateInit_,"DEIN")
549   #pragma map(deflateInit2_,"DEIN2")
550   #pragma map(deflateEnd,"DEEND")
551   #pragma map(deflateBound,"DEBND")
552   #pragma map(inflateInit_,"ININ")
553   #pragma map(inflateInit2_,"ININ2")
554   #pragma map(inflateEnd,"INEND")
555   #pragma map(inflateSync,"INSY")
556   #pragma map(inflateSetDictionary,"INSEDI")
557   #pragma map(compressBound,"CMBND")
558   #pragma map(inflate_table,"INTABL")
559   #pragma map(inflate_fast,"INFA")
560   #pragma map(inflate_copyright,"INCOPY")
561 #endif
562 
563 #endif /* ZCONF_H */
564