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