1/* zconf-ng.h -- configuration of the zlib-ng 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 ZCONFNG_H
7#define ZCONFNG_H
8
9#include "zlib_name_mangling-ng.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/* Always define z_const as const */
23#define z_const const
24
25/* Maximum value for memLevel in deflateInit2 */
26#ifndef MAX_MEM_LEVEL
27#  define MAX_MEM_LEVEL 9
28#endif
29
30/* Maximum value for windowBits in deflateInit2 and inflateInit2.
31 * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
32 * created by gzip. (Files created by minigzip can still be extracted by
33 * gzip.)
34 */
35#ifndef MAX_WBITS
36#  define MAX_WBITS   15 /* 32K LZ77 window */
37#endif
38
39/* The memory requirements for deflate are (in bytes):
40            (1 << (windowBits+2)) +  (1 << (memLevel+9))
41 that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
42 plus a few kilobytes for small objects. For example, if you want to reduce
43 the default memory requirements from 256K to 128K, compile with
44     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
45 Of course this will generally degrade compression (there's no free lunch).
46
47   The memory requirements for inflate are (in bytes) 1 << windowBits
48 that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
49 for small objects.
50*/
51
52/* Type declarations */
53
54#ifdef ZLIB_INTERNAL
55#  define Z_INTERNAL ZLIB_INTERNAL
56#endif
57
58/* If building or using zlib as a DLL, define ZLIB_DLL.
59 * This is not mandatory, but it offers a little performance increase.
60 */
61#if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)))
62#  ifdef Z_INTERNAL
63#    define Z_EXTERN extern __declspec(dllexport)
64#  else
65#    define Z_EXTERN extern __declspec(dllimport)
66#  endif
67#endif
68
69/* If building or using zlib with the WINAPI/WINAPIV calling convention,
70 * define ZLIB_WINAPI.
71 * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
72 */
73#if defined(ZLIB_WINAPI) && defined(_WIN32)
74#  include <windows.h>
75   /* No need for _export, use ZLIB.DEF instead. */
76   /* For complete Windows compatibility, use WINAPI, not __stdcall. */
77#  define Z_EXPORT WINAPI
78#  define Z_EXPORTVA WINAPIV
79#endif
80
81#ifndef Z_EXTERN
82#  define Z_EXTERN extern
83#endif
84#ifndef Z_EXPORT
85#  define Z_EXPORT
86#endif
87#ifndef Z_EXPORTVA
88#  define Z_EXPORTVA
89#endif
90
91/* Fallback for something that includes us. */
92typedef unsigned char Byte;
93typedef Byte Bytef;
94
95typedef unsigned int   uInt;  /* 16 bits or more */
96typedef unsigned long  uLong; /* 32 bits or more */
97
98typedef char  charf;
99typedef int   intf;
100typedef uInt  uIntf;
101typedef uLong uLongf;
102
103typedef void const *voidpc;
104typedef void       *voidpf;
105typedef void       *voidp;
106
107#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by configure/cmake/etc */
108#  define Z_HAVE_UNISTD_H
109#endif
110
111#ifdef NEED_PTRDIFF_T    /* may be set to #if 1 by configure/cmake/etc */
112typedef PTRDIFF_TYPE ptrdiff_t;
113#endif
114
115#include <sys/types.h>      /* for off_t */
116#include <stdarg.h>         /* for va_list */
117
118#include <stddef.h>         /* for wchar_t and NULL */
119
120/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
121 * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
122 * though the former does not conform to the LFS document), but considering
123 * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
124 * equivalently requesting no 64-bit operations
125 */
126#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
127#  undef _LARGEFILE64_SOURCE
128#endif
129
130#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
131#  include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
132#  ifndef z_off_t
133#    define z_off_t off_t
134#  endif
135#endif
136
137#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
138#  define Z_LFS64
139#endif
140
141#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
142#  define Z_LARGE64
143#endif
144
145#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
146#  define Z_WANT64
147#endif
148
149#if !defined(SEEK_SET) && defined(WITH_GZFILEOP)
150#  define SEEK_SET        0       /* Seek from beginning of file.  */
151#  define SEEK_CUR        1       /* Seek from current position.  */
152#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
153#endif
154
155#ifndef z_off_t
156#  define z_off_t long
157#endif
158
159#if !defined(_WIN32) && defined(Z_LARGE64)
160#  define z_off64_t off64_t
161#else
162#  if defined(__MSYS__)
163#    define z_off64_t _off64_t
164#  elif defined(_WIN32) && !defined(__GNUC__)
165#    define z_off64_t __int64
166#  else
167#    define z_off64_t z_off_t
168#  endif
169#endif
170
171#endif /* ZCONFNG_H */
172