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