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