zconf-ng.h.in 4.9 KB

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