]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Clean up windows defines, use _WIN32
authorPavel P <pavlov.pavel@gmail.com>
Mon, 20 Apr 2020 10:19:30 +0000 (16:19 +0600)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 8 Jun 2020 13:09:17 +0000 (15:09 +0200)
 + replaced WIN32 with _WIN32
 + removed unused WINDOWS/_WINDOWS defines
 + no need to test for __MINGW__, as _WIN32 is also defined

gzguts.h
gzlib.c
test/fuzz/minigzip_fuzzer.c
test/minigzip.c
zconf-ng.h.in
zconf.h.in
zendian.h
zlib-ng.h
zlib.h
zutil.h

index 83440d52c47ccfb9239fea98a5d8ff2644cca4f2..263bc9a0dfe9b4e68e4d9a59765f8151fe8fcbf8 100644 (file)
--- a/gzguts.h
+++ b/gzguts.h
@@ -34,7 +34,7 @@
 #  include "zlib-ng.h"
 #endif
 
-#ifdef WIN32
+#ifdef _WIN32
 #  include <stddef.h>
 #endif
 
 #  include <unistd.h>       /* for lseek(), read(), close(), write(), unlink() */
 #endif
 
-#if defined(_MSC_VER) || defined(WIN32)
+#if defined(_WIN32)
 #  include <io.h>
-#endif
-
-#if defined(_WIN32) || defined(__MINGW__)
 #  define WIDECHAR
 #endif
 
@@ -58,7 +55,7 @@
 #endif
 
 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-#if !defined(STDC99) && !defined(__CYGWIN__) && !defined(__MINGW__) && defined(WIN32)
+#if !defined(STDC99) && !defined(__CYGWIN__) && !defined(__MINGW__) && defined(_WIN32)
 #  if !defined(vsnprintf)
 #    if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
 #       define vsnprintf _vsnprintf
diff --git a/gzlib.c b/gzlib.c
index 56326ccc755e235ec3b0aefc838cb6709f6e306f..9da7a113d11f3a07865ff223c950f8efa5e8cad4 100644 (file)
--- a/gzlib.c
+++ b/gzlib.c
@@ -6,7 +6,7 @@
 #include "zbuild.h"
 #include "gzguts.h"
 
-#if defined(WIN32) && !defined(__BORLANDC__)
+#if defined(_WIN32) && !defined(__BORLANDC__)
 #  define LSEEK _lseeki64
 #else
 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
@@ -181,7 +181,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
 
     /* open the file with the appropriate flags (or just use fd) */
     state->fd = fd > -1 ? fd : (
-#if defined(WIN32) || defined(__MINGW__)
+#if defined(_WIN32)
         fd == -2 ? _wopen(path, oflag, 0666) :
 #elif __CYGWIN__
         fd == -2 ? open(state->path, oflag, 0666) :
index c66ad2e0227b12c48e71e65db8530b1e016179d0..e2ac6f7b17df890efcae120d1c6784d2299378bb 100644 (file)
@@ -33,7 +33,7 @@
 #  include <malloc.h>
 #endif
 
-#if defined(WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__)
 #  include <fcntl.h>
 #  include <io.h>
 #  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
@@ -46,7 +46,7 @@
 #endif
 
 #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
-#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
+#ifndef _WIN32 /* unlink already in stdio.h for Win32 */
 extern int unlink (const char *);
 #endif
 #endif
index 611391b0851a2dc308f6abba2b0cd84d96dc49ee..d75c317fb97f5f6a0d857511b9b528b71a537474 100644 (file)
@@ -36,7 +36,7 @@
 #  include <malloc.h>
 #endif
 
-#if defined(WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__)
 #  include <fcntl.h>
 #  include <io.h>
 #  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
@@ -49,7 +49,7 @@
 #endif
 
 #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
-#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
+#ifndef _WIN32 /* unlink already in stdio.h for Win32 */
 extern int unlink (const char *);
 #endif
 #endif
index 49075b7afb669ca8f53d1cebb09de327284858dd..c6c81f63387a7d058d28db8568afbac1fa2a6d03 100644 (file)
@@ -6,13 +6,8 @@
 #ifndef ZCONFNG_H
 #define ZCONFNG_H
 
-#if defined(_WINDOWS) && !defined(WINDOWS)
-#  define WINDOWS
-#endif
-#if defined(_WIN32) || defined(__WIN32__)
-#  ifndef WIN32
-#    define WIN32
-#  endif
+#if !defined(_WIN32) && defined(__WIN32__)
+#  define _WIN32
 #endif
 
 #ifdef __STDC_VERSION__
  for small objects.
 */
 
-                        /* Type declarations */
+/* Type declarations */
 
 
-#if defined(WINDOWS) || defined(WIN32)
+#if defined(_WIN32)
    /* If building or using zlib as a DLL, define ZLIB_DLL.
     * This is not mandatory, but it offers a little performance increase.
     */
-#  ifdef ZLIB_DLL
-#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-#      ifdef ZLIB_INTERNAL
-#        define ZEXTERN extern __declspec(dllexport)
-#      else
-#        define ZEXTERN extern __declspec(dllimport)
-#      endif
+#  if defined(ZLIB_DLL) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+#    ifdef ZLIB_INTERNAL
+#      define ZEXTERN extern __declspec(dllexport)
+#    else
+#      define ZEXTERN extern __declspec(dllimport)
 #    endif
 #  endif  /* ZLIB_DLL */
    /* If building or using zlib with the WINAPI/WINAPIV calling convention,
@@ -157,12 +150,12 @@ typedef PTRDIFF_TYPE ptrdiff_t;
 #  define z_off_t long
 #endif
 
-#if !defined(WIN32) && defined(Z_LARGE64)
+#if !defined(_WIN32) && defined(Z_LARGE64)
 #  define z_off64_t off64_t
 #else
 #  if defined(__MSYS__)
 #    define z_off64_t _off64_t
-#  elif defined(WIN32) && !defined(__GNUC__)
+#  elif defined(_WIN32) && !defined(__GNUC__)
 #    define z_off64_t __int64
 #  else
 #    define z_off64_t z_off_t
index f890fcd9e2d13e476b3d3b30d301601bf192ef5f..44c1697ab2cdf82a3b3921fac42dc56dc5a2edf4 100644 (file)
@@ -6,13 +6,8 @@
 #ifndef ZCONF_H
 #define ZCONF_H
 
-#if defined(_WINDOWS) && !defined(WINDOWS)
-#  define WINDOWS
-#endif
-#if defined(_WIN32) || defined(__WIN32__)
-#  ifndef WIN32
-#    define WIN32
-#  endif
+#if !defined(_WIN32) && defined(__WIN32__)
+#  define _WIN32
 #endif
 
 #ifdef __STDC_VERSION__
  for small objects.
 */
 
-                        /* Type declarations */
+/* Type declarations */
 
 
 #ifndef OF /* function prototypes */
 #  define OF(args)  args
 #endif
 
-#if defined(WINDOWS) || defined(WIN32)
+#if defined(_WIN32)
    /* If building or using zlib as a DLL, define ZLIB_DLL.
     * This is not mandatory, but it offers a little performance increase.
     */
-#  ifdef ZLIB_DLL
-#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-#      ifdef ZLIB_INTERNAL
-#        define ZEXTERN extern __declspec(dllexport)
-#      else
-#        define ZEXTERN extern __declspec(dllimport)
-#      endif
+#  if defined(ZLIB_DLL) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+#    ifdef ZLIB_INTERNAL
+#      define ZEXTERN extern __declspec(dllexport)
+#    else
+#      define ZEXTERN extern __declspec(dllimport)
 #    endif
 #  endif  /* ZLIB_DLL */
    /* If building or using zlib with the WINAPI/WINAPIV calling convention,
@@ -161,12 +154,12 @@ typedef PTRDIFF_TYPE ptrdiff_t;
 #  define z_off_t long
 #endif
 
-#if !defined(WIN32) && defined(Z_LARGE64)
+#if !defined(_WIN32) && defined(Z_LARGE64)
 #  define z_off64_t off64_t
 #else
 #  if defined(__MSYS__)
 #    define z_off64_t _off64_t
-#  elif defined(WIN32) && !defined(__GNUC__)
+#  elif defined(_WIN32) && !defined(__GNUC__)
 #    define z_off64_t __int64
 #  else
 #    define z_off64_t z_off_t
index 4236b13019e4a3c7c8f9d57c61d7149b4cdfbff4..54718ed14f1330b84d72564602d29e304944f8ef 100644 (file)
--- a/zendian.h
+++ b/zendian.h
@@ -24,7 +24,7 @@
 #  endif
 #elif defined(__MINGW32__)
 #  include <sys/param.h>
-#elif defined(WIN32) || defined(_WIN32)
+#elif defined(_WIN32)
 #  define LITTLE_ENDIAN 1234
 #  define BIG_ENDIAN 4321
 #  if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) || defined (_M_ARM64)
index 33033b44051284bd9226f72cbb8f06bb8e58d083..7d792eeed8a4487ccad01306c1612771fd2f4586 100644 (file)
--- a/zlib-ng.h
+++ b/zlib-ng.h
@@ -1939,7 +1939,7 @@ ZEXTERN ZEXPORT int              zng_inflateResetKeep (zng_stream *);
 ZEXTERN ZEXPORT int              zng_deflateResetKeep (zng_stream *);
 
 #ifdef WITH_GZFILEOP
-#  if (defined(WIN32) || defined(__MINGW__))
+#  if defined(_WIN32)
      ZEXTERN ZEXPORT gzFile zng_gzopen_w(const wchar_t *path, const char *mode);
 #  endif
 ZEXTERN ZEXPORTVA int zng_gzvprintf(gzFile file, const char *format, va_list va);
diff --git a/zlib.h b/zlib.h
index cc6632ac9251d79f8fbe4309752fb631f110f2d7..33bfd9cb84c1139ff5dd1d9a6e6f7adbdaf96a15 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -1836,7 +1836,7 @@ ZEXTERN unsigned long    ZEXPORT inflateCodesUsed (z_stream *);
 ZEXTERN int              ZEXPORT inflateResetKeep (z_stream *);
 ZEXTERN int              ZEXPORT deflateResetKeep (z_stream *);
 
-#if (defined(WIN32) || defined(__MINGW__))
+#if defined(_WIN32)
     ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode);
 #endif
 ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va);
diff --git a/zutil.h b/zutil.h
index b8bce163a60d99954dbb72671ca4386d850cb509..f4d26e3dc6e79a6d3088d54b2772a93633ecf822 100644 (file)
--- a/zutil.h
+++ b/zutil.h
@@ -102,7 +102,7 @@ extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */
 #  define OS_CODE 13
 #endif
 
-#if defined(WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #  define OS_CODE  10
 #endif
 
@@ -115,7 +115,7 @@ extern const char * const zng_errmsg[10]; /* indexed by 2-zlib_error */
 #endif
 
 /* provide prototypes for these when building zlib without LFS */
-#if !defined(WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
+#if !defined(_WIN32) && !defined(__MSYS__) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
 #  include "zbuild.h"  /* For PREFIX() */
     ZEXTERN uint32_t ZEXPORT PREFIX(adler32_combine64)(uint32_t, uint32_t, z_off_t);
     ZEXTERN uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t, uint32_t, z_off_t);
@@ -168,7 +168,7 @@ void ZLIB_INTERNAL   zng_cfree(void *opaque, void *ptr);
 
 /* Reverse the bytes in a value. Use compiler intrinsics when
    possible to take advantage of hardware implementations. */
-#if defined(WIN32) && (_MSC_VER >= 1300)
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
 #  pragma intrinsic(_byteswap_ulong)
 #  define ZSWAP16(q) _byteswap_ushort(q)
 #  define ZSWAP32(q) _byteswap_ulong(q)