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