• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#if !defined(_WIN32) && defined(__WIN32__)
10#  define _WIN32
11#endif
12
13#ifdef __STDC_VERSION__
14#  if __STDC_VERSION__ >= 199901L
15#    ifndef STDC99
16#      define STDC99
17#    endif
18#  endif
19#endif
20
21/* Clang macro for detecting declspec support
22 * https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute
23 */
24#ifndef __has_declspec_attribute
25#  define __has_declspec_attribute(x) 0
26#endif
27
28/* Always define z_const as const */
29#define z_const const
30
31/* Maximum value for memLevel in deflateInit2 */
32#ifndef MAX_MEM_LEVEL
33#  define MAX_MEM_LEVEL 9
34#endif
35
36/* Maximum value for windowBits in deflateInit2 and inflateInit2.
37 * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
38 * created by gzip. (Files created by minigzip can still be extracted by
39 * gzip.)
40 */
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#ifdef ZLIB_INTERNAL
61#  define Z_INTERNAL ZLIB_INTERNAL
62#endif
63
64/* If building or using zlib as a DLL, define ZLIB_DLL.
65 * This is not mandatory, but it offers a little performance increase.
66 */
67#if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)))
68#  ifdef Z_INTERNAL
69#    define Z_EXTERN extern __declspec(dllexport)
70#  else
71#    define Z_EXTERN extern __declspec(dllimport)
72#  endif
73#endif
74
75/* If building or using zlib with the WINAPI/WINAPIV calling convention,
76 * define ZLIB_WINAPI.
77 * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
78 */
79#if defined(ZLIB_WINAPI) && defined(_WIN32)
80#  include <windows.h>
81   /* No need for _export, use ZLIB.DEF instead. */
82   /* For complete Windows compatibility, use WINAPI, not __stdcall. */
83#  define Z_EXPORT WINAPI
84#  define Z_EXPORTVA WINAPIV
85#endif
86
87#ifndef Z_EXTERN
88#  define Z_EXTERN extern
89#endif
90#ifndef Z_EXPORT
91#  define Z_EXPORT
92#endif
93#ifndef Z_EXPORTVA
94#  define Z_EXPORTVA
95#endif
96
97/* Fallback for something that includes us. */
98typedef unsigned char Byte;
99typedef Byte Bytef;
100
101typedef unsigned int   uInt;  /* 16 bits or more */
102typedef unsigned long  uLong; /* 32 bits or more */
103
104typedef char  charf;
105typedef int   intf;
106typedef uInt  uIntf;
107typedef uLong uLongf;
108
109typedef void const *voidpc;
110typedef void       *voidpf;
111typedef void       *voidp;
112
113#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by configure/cmake/etc */
114#  define Z_HAVE_UNISTD_H
115#endif
116
117#ifdef NEED_PTRDIFF_T    /* may be set to #if 1 by configure/cmake/etc */
118typedef PTRDIFF_TYPE ptrdiff_t;
119#endif
120
121#include <sys/types.h>      /* for off_t */
122#include <stdarg.h>         /* for va_list */
123
124#include <stddef.h>         /* for wchar_t and NULL */
125
126/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
127 * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
128 * though the former does not conform to the LFS document), but considering
129 * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
130 * equivalently requesting no 64-bit operations
131 */
132#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
133#  undef _LARGEFILE64_SOURCE
134#endif
135
136#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
137#  include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
138#  ifndef z_off_t
139#    define z_off_t off_t
140#  endif
141#endif
142
143#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
144#  define Z_LFS64
145#endif
146
147#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
148#  define Z_LARGE64
149#endif
150
151#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
152#  define Z_WANT64
153#endif
154
155#if !defined(SEEK_SET) && defined(WITH_GZFILEOP)
156#  define SEEK_SET        0       /* Seek from beginning of file.  */
157#  define SEEK_CUR        1       /* Seek from current position.  */
158#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
159#endif
160
161#ifndef z_off_t
162#  define z_off_t long
163#endif
164
165#if !defined(_WIN32) && defined(Z_LARGE64)
166#  define z_off64_t off64_t
167#else
168#  if defined(__MSYS__)
169#    define z_off64_t _off64_t
170#  elif defined(_WIN32) && !defined(__GNUC__)
171#    define z_off64_t __int64
172#  else
173#    define z_off64_t z_off_t
174#  endif
175#endif
176
177#endif /* ZCONFNG_H */
178