|
| 1 | +/* zconf.h -- configuration of the zlib compression library |
| 2 | + * Copyright (C) 1995-2024 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 | +#include "zlib_name_mangling.h" |
| 10 | + |
| 11 | +#if !defined(_WIN32) && defined(__WIN32__) |
| 12 | +# define _WIN32 |
| 13 | +#endif |
| 14 | + |
| 15 | +/* Clang macro for detecting declspec support |
| 16 | + * https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute |
| 17 | + */ |
| 18 | +#ifndef __has_declspec_attribute |
| 19 | +# define __has_declspec_attribute(x) 0 |
| 20 | +#endif |
| 21 | + |
| 22 | +#if defined(ZLIB_CONST) && !defined(z_const) |
| 23 | +# define z_const const |
| 24 | +#else |
| 25 | +# define z_const |
| 26 | +#endif |
| 27 | + |
| 28 | +/* Maximum value for memLevel in deflateInit2 */ |
| 29 | +#ifndef MAX_MEM_LEVEL |
| 30 | +# define MAX_MEM_LEVEL 9 |
| 31 | +#endif |
| 32 | + |
| 33 | +/* Maximum value for windowBits in deflateInit2 and inflateInit2. |
| 34 | + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files |
| 35 | + * created by gzip. (Files created by minigzip can still be extracted by |
| 36 | + * gzip.) |
| 37 | + */ |
| 38 | +#ifndef MIN_WBITS |
| 39 | +# define MIN_WBITS 8 /* 256 LZ77 window */ |
| 40 | +#endif |
| 41 | +#ifndef MAX_WBITS |
| 42 | +# define MAX_WBITS 15 /* 32K LZ77 window */ |
| 43 | +#endif |
| 44 | + |
| 45 | +/* The memory requirements for deflate are (in bytes): |
| 46 | + (1 << (windowBits+2)) + (1 << (memLevel+9)) |
| 47 | + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) |
| 48 | + plus a few kilobytes for small objects. For example, if you want to reduce |
| 49 | + the default memory requirements from 256K to 128K, compile with |
| 50 | + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" |
| 51 | + Of course this will generally degrade compression (there's no free lunch). |
| 52 | +
|
| 53 | + The memory requirements for inflate are (in bytes) 1 << windowBits |
| 54 | + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes |
| 55 | + for small objects. |
| 56 | +*/ |
| 57 | + |
| 58 | +/* Type declarations */ |
| 59 | + |
| 60 | + |
| 61 | +#ifndef OF /* function prototypes */ |
| 62 | +# define OF(args) args |
| 63 | +#endif |
| 64 | + |
| 65 | +#ifdef ZLIB_INTERNAL |
| 66 | +# define Z_INTERNAL ZLIB_INTERNAL |
| 67 | +#endif |
| 68 | + |
| 69 | +/* If building or using zlib as a DLL, define ZLIB_DLL. |
| 70 | + * This is not mandatory, but it offers a little performance increase. |
| 71 | + */ |
| 72 | +#if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport))) |
| 73 | +# ifdef Z_INTERNAL |
| 74 | +# define Z_EXTERN extern __declspec(dllexport) |
| 75 | +# else |
| 76 | +# define Z_EXTERN extern __declspec(dllimport) |
| 77 | +# endif |
| 78 | +#endif |
| 79 | + |
| 80 | +/* If building or using zlib with the WINAPI/WINAPIV calling convention, |
| 81 | + * define ZLIB_WINAPI. |
| 82 | + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. |
| 83 | + */ |
| 84 | +#if defined(ZLIB_WINAPI) && defined(_WIN32) |
| 85 | +# ifndef WIN32_LEAN_AND_MEAN |
| 86 | +# define WIN32_LEAN_AND_MEAN |
| 87 | +# endif |
| 88 | +# include <windows.h> |
| 89 | + /* No need for _export, use ZLIB.DEF instead. */ |
| 90 | + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ |
| 91 | +# define Z_EXPORT WINAPI |
| 92 | +# define Z_EXPORTVA WINAPIV |
| 93 | +#endif |
| 94 | + |
| 95 | +#ifndef Z_EXTERN |
| 96 | +# define Z_EXTERN extern |
| 97 | +#endif |
| 98 | +#ifndef Z_EXPORT |
| 99 | +# define Z_EXPORT |
| 100 | +#endif |
| 101 | +#ifndef Z_EXPORTVA |
| 102 | +# define Z_EXPORTVA |
| 103 | +#endif |
| 104 | + |
| 105 | +/* Conditional exports */ |
| 106 | +#define ZNG_CONDEXPORT Z_INTERNAL |
| 107 | + |
| 108 | +/* For backwards compatibility */ |
| 109 | + |
| 110 | +#ifndef ZEXTERN |
| 111 | +# define ZEXTERN Z_EXTERN |
| 112 | +#endif |
| 113 | +#ifndef ZEXPORT |
| 114 | +# define ZEXPORT Z_EXPORT |
| 115 | +#endif |
| 116 | +#ifndef ZEXPORTVA |
| 117 | +# define ZEXPORTVA Z_EXPORTVA |
| 118 | +#endif |
| 119 | +#ifndef FAR |
| 120 | +# define FAR |
| 121 | +#endif |
| 122 | + |
| 123 | +/* Legacy zlib typedefs for backwards compatibility. Don't assume stdint.h is defined. */ |
| 124 | +typedef unsigned char Byte; |
| 125 | +typedef Byte Bytef; |
| 126 | + |
| 127 | +typedef unsigned int uInt; /* 16 bits or more */ |
| 128 | +typedef unsigned long uLong; /* 32 bits or more */ |
| 129 | + |
| 130 | +typedef char charf; |
| 131 | +typedef int intf; |
| 132 | +typedef uInt uIntf; |
| 133 | +typedef uLong uLongf; |
| 134 | + |
| 135 | +typedef void const *voidpc; |
| 136 | +typedef void *voidpf; |
| 137 | +typedef void *voidp; |
| 138 | + |
| 139 | +typedef unsigned int z_crc_t; |
| 140 | + |
| 141 | +#if 1 |
| 142 | +# define Z_HAVE_UNISTD_H |
| 143 | +#endif |
| 144 | + |
| 145 | +#if 0 |
| 146 | +typedef PTRDIFF_TYPE ptrdiff_t; |
| 147 | +#endif |
| 148 | + |
| 149 | +#include <sys/types.h> /* for off_t */ |
| 150 | + |
| 151 | +#include <stddef.h> /* for wchar_t and NULL */ |
| 152 | + |
| 153 | +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and |
| 154 | + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even |
| 155 | + * though the former does not conform to the LFS document), but considering |
| 156 | + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as |
| 157 | + * equivalently requesting no 64-bit operations |
| 158 | + */ |
| 159 | +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 |
| 160 | +# undef _LARGEFILE64_SOURCE |
| 161 | +#endif |
| 162 | + |
| 163 | +#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) |
| 164 | +# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ |
| 165 | +# ifndef z_off_t |
| 166 | +# define z_off_t off_t |
| 167 | +# endif |
| 168 | +#endif |
| 169 | + |
| 170 | +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 |
| 171 | +# define Z_LFS64 |
| 172 | +#endif |
| 173 | + |
| 174 | +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) |
| 175 | +# define Z_LARGE64 |
| 176 | +#endif |
| 177 | + |
| 178 | +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) |
| 179 | +# define Z_WANT64 |
| 180 | +#endif |
| 181 | + |
| 182 | +#if !defined(SEEK_SET) |
| 183 | +# define SEEK_SET 0 /* Seek from beginning of file. */ |
| 184 | +# define SEEK_CUR 1 /* Seek from current position. */ |
| 185 | +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ |
| 186 | +#endif |
| 187 | + |
| 188 | +#ifndef z_off_t |
| 189 | +# define z_off_t long |
| 190 | +#endif |
| 191 | + |
| 192 | +#if !defined(_WIN32) && defined(Z_LARGE64) |
| 193 | +# define z_off64_t off64_t |
| 194 | +#else |
| 195 | +# if defined(__MSYS__) |
| 196 | +# define z_off64_t _off64_t |
| 197 | +# elif defined(_WIN32) && !defined(__GNUC__) |
| 198 | +# define z_off64_t __int64 |
| 199 | +# else |
| 200 | +# define z_off64_t z_off_t |
| 201 | +# endif |
| 202 | +#endif |
| 203 | + |
| 204 | +typedef size_t z_size_t; |
| 205 | + |
| 206 | +#endif /* ZCONF_H */ |
0 commit comments