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