From a82d86479c6852056421e4a54007a280086996cc Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Mon, 10 Jun 2024 21:59:41 +0200 Subject: [PATCH] Replace WIN32 conditions with _WIN32 or PHP_WIN32 (#14462) * Replace WIN32 conditions with _WIN32 or PHP_WIN32 WIN32 is defined by the SDK and not defined all the time on Windows by compilers or the environment. _WIN32 is defined as 1 when the compilation target is 32-bit ARM, 64-bit ARM, x86, or x64. Otherwise, undefined. This syncs these usages one step further. Upstream libgd has replaced WIN32 with _WIN32 via https://github.com/libgd/libgd/commit/c60d9fe577ae8dad88e26344c4ceaa90da86e2f6 PHP_WIN32 is added to ext/sockets/sockets.stub.php as done in other *.stub.php files at this point. * Use PHP_WIN32 in ext/random * Use PHP_WIN32 in ext/sockets * Use _WIN32 in xxhash.h as done upstream See https://github.com/Cyan4973/xxHash/pull/931 * Update end comment with PHP_WIN32 --- TSRM/TSRM.h | 2 +- ext/gd/libgd/gd.h | 2 +- ext/gd/libgd/gdft.c | 2 +- ext/hash/xxhash/xxhash.h | 2 +- ext/mbstring/libmbfl/mbfl/mbfl_defs.h | 4 +- ext/random/random.c | 2 +- ext/sockets/php_sockets.h | 82 +++++++++++++-------------- ext/sockets/sockets.stub.php | 2 +- ext/sockets/sockets_arginfo.h | 22 +++---- ext/standard/crc32.c | 2 +- sapi/cgi/cgi_main.c | 2 +- 11 files changed, 62 insertions(+), 62 deletions(-) diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index 4af3d51b89102..704f57b9a2caa 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -13,7 +13,7 @@ #ifndef TSRM_H #define TSRM_H -#if !defined(__CYGWIN__) && defined(WIN32) +#if !defined(__CYGWIN__) && defined(_WIN32) # define TSRM_WIN32 # include "Zend/zend_config.w32.h" #else diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h index 51e7fa7a6e1b0..783b3fa403a7a 100644 --- a/ext/gd/libgd/gd.h +++ b/ext/gd/libgd/gd.h @@ -21,7 +21,7 @@ extern "C" { /* default fontpath for netware systems */ #define DEFAULT_FONTPATH "sys:/java/nwgfx/lib/x11/fonts/ttf;." #define PATHSEPARATOR ";" -#elif defined(WIN32) +#elif defined(_WIN32) /* default fontpath for windows systems */ #define DEFAULT_FONTPATH "c:\\winnt\\fonts;c:\\windows\\fonts;." #define PATHSEPARATOR ";" diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index 6876ca6f6b428..67f553ebc9d7c 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -21,7 +21,7 @@ #endif #endif -#ifdef WIN32 +#ifdef _WIN32 #define access _access #ifndef R_OK #define R_OK 2 diff --git a/ext/hash/xxhash/xxhash.h b/ext/hash/xxhash/xxhash.h index 8e816c0584ebd..097f887be9e7f 100644 --- a/ext/hash/xxhash/xxhash.h +++ b/ext/hash/xxhash/xxhash.h @@ -229,7 +229,7 @@ extern "C" { */ /* specific declaration modes for Windows */ #if !defined(XXH_INLINE_ALL) && !defined(XXH_PRIVATE_API) -# if defined(WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) +# if defined(_WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) # ifdef XXH_EXPORT # define XXH_PUBLIC_API __declspec(dllexport) # elif XXH_IMPORT diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_defs.h b/ext/mbstring/libmbfl/mbfl/mbfl_defs.h index 8b18e5e0c48b4..297b122bdd71a 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfl_defs.h +++ b/ext/mbstring/libmbfl/mbfl/mbfl_defs.h @@ -43,7 +43,7 @@ #define SIZE_MAX ((size_t)~0) #endif -#ifdef WIN32 +#ifdef _WIN32 #ifdef MBFL_DLL_EXPORT #define MBFLAPI __declspec(dllexport) #else @@ -55,6 +55,6 @@ #else #define MBFLAPI #endif /* defined(__GNUC__) && __GNUC__ >= 4 */ -#endif /* WIN32 */ +#endif /* _WIN32 */ #endif /* MBFL_DEFS_H */ diff --git a/ext/random/random.c b/ext/random/random.c index 7a31f0a01d954..e18a887640163 100644 --- a/ext/random/random.c +++ b/ext/random/random.c @@ -635,7 +635,7 @@ PHPAPI uint64_t php_random_generate_fallback_seed(void) /* Various PIDs. */ pid = getpid(); fallback_seed_add(&c, &pid, sizeof(pid)); -#ifndef WIN32 +#ifndef PHP_WIN32 pid = getppid(); fallback_seed_add(&c, &pid, sizeof(pid)); #endif diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 057ef18fd01d2..ca9f3babf3628 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -153,31 +153,31 @@ PHP_SOCKETS_API bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket #define PHP_NORMAL_READ 0x0001 #define PHP_BINARY_READ 0x0002 -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EINTR WSAEINTR #elif defined(EINTR) #define PHP_SOCKET_EINTR EINTR #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EBADF WSAEBADF #elif defined(EBADF) #define PHP_SOCKET_EBADF EBADF #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EACCES WSAEACCES #elif defined(EACCES) #define PHP_SOCKET_EACCES EACCES #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EFAULT WSAEFAULT #elif defined(EFAULT) #define PHP_SOCKET_EFAULT EFAULT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EINVAL WSAEINVAL #elif defined(EINVAL) #define PHP_SOCKET_EINVAL EINVAL @@ -187,217 +187,217 @@ PHP_SOCKETS_API bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket #define PHP_SOCKET_ENFILE ENFILE #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EMFILE WSAEMFILE #elif defined(EMFILE) #define PHP_SOCKET_EMFILE EMFILE #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EWOULDBLOCK WSAEWOULDBLOCK #elif defined(EWOULDBLOCK) #define PHP_SOCKET_EWOULDBLOCK EWOULDBLOCK #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EINPROGRESS WSAEINPROGRESS #elif defined(EINPROGRESS) #define PHP_SOCKET_EINPROGRESS EINPROGRESS #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EALREADY WSAEALREADY #elif defined(EALREADY) #define PHP_SOCKET_EALREADY EALREADY #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENOTSOCK WSAENOTSOCK #elif defined(ENOTSOCK) #define PHP_SOCKET_ENOTSOCK ENOTSOCK #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EDESTADDRREQ WSAEDESTADDRREQ #elif defined(EDESTADDRREQ) #define PHP_SOCKET_EDESTADDRREQ EDESTADDRREQ #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EMSGSIZE WSAEMSGSIZE #elif defined(EMSGSIZE) #define PHP_SOCKET_EMSGSIZE EMSGSIZE #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EPROTOTYPE WSAEPROTOTYPE #elif defined(EPROTOTYPE) #define PHP_SOCKET_EPROTOTYPE EPROTOTYPE #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENOPROTOOPT WSAENOPROTOOPT #elif defined(ENOPROTOOPT) #define PHP_SOCKET_ENOPROTOOPT ENOPROTOOPT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EPROTONOSUPPORT WSAEPROTONOSUPPORT #elif defined(EPROTONOSUPPORT) #define PHP_SOCKET_EPROTONOSUPPORT EPROTONOSUPPORT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT #elif defined(ESOCKTNOSUPPORT) #define PHP_SOCKET_ESOCKTNOSUPPORT ESOCKTNOSUPPORT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EOPNOTSUPP WSAEOPNOTSUPP #elif defined(EOPNOTSUPP) #define PHP_SOCKET_EOPNOTSUPP EOPNOTSUPP #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EPFNOSUPPORT WSAEPFNOSUPPORT #elif defined(EPFNOSUPPORT) #define PHP_SOCKET_EPFNOSUPPORT EPFNOSUPPORT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EAFNOSUPPORT WSAEAFNOSUPPORT #elif defined(EAFNOSUPPORT) #define PHP_SOCKET_EAFNOSUPPORT EAFNOSUPPORT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EADDRINUSE WSAEADDRINUSE #elif defined(EADDRINUSE) #define PHP_SOCKET_EADDRINUSE EADDRINUSE #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EADDRNOTAVAIL WSAEADDRNOTAVAIL #elif defined(EADDRNOTAVAIL) #define PHP_SOCKET_EADDRNOTAVAIL EADDRNOTAVAIL #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENETDOWN WSAENETDOWN #elif defined(ENETDOWN) #define PHP_SOCKET_ENETDOWN ENETDOWN #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENETUNREACH WSAENETUNREACH #elif defined(ENETUNREACH) #define PHP_SOCKET_ENETUNREACH ENETUNREACH #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENETRESET WSAENETRESET #elif defined(ENETRESET) #define PHP_SOCKET_ENETRESET ENETRESET #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ECONNABORTED WSAECONNABORTED #elif defined(ECONNABORTED) #define PHP_SOCKET_ECONNABORTED ECONNABORTED #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ECONNRESET WSAECONNRESET #elif defined(ECONNRESET) #define PHP_SOCKET_ECONNRESET ECONNRESET #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENOBUFS WSAENOBUFS #elif defined(ENOBUFS) #define PHP_SOCKET_ENOBUFS ENOBUFS #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EISCONN WSAEISCONN #elif defined(EISCONN) #define PHP_SOCKET_EISCONN EISCONN #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENOTCONN WSAENOTCONN #elif defined(ENOTCONN) #define PHP_SOCKET_ENOTCONN ENOTCONN #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ESHUTDOWN WSAESHUTDOWN #elif defined(ESHUTDOWN) #define PHP_SOCKET_ESHUTDOWN ESHUTDOWN #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ETOOMANYREFS WSAETOOMANYREFS #elif defined(ETOOMANYREFS) #define PHP_SOCKET_ETOOMANYREFS ETOOMANYREFS #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ETIMEDOUT WSAETIMEDOUT #elif defined(ETIMEDOUT) #define PHP_SOCKET_ETIMEDOUT ETIMEDOUT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ECONNREFUSED WSAECONNREFUSED #elif defined(ECONNREFUSED) #define PHP_SOCKET_ECONNREFUSED ECONNREFUSED #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ELOOP WSAELOOP #elif defined(ELOOP) #define PHP_SOCKET_ELOOP ELOOP #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENAMETOOLONG WSAENAMETOOLONG #elif defined(ENAMETOOLONG) #define PHP_SOCKET_ENAMETOOLONG ENAMETOOLONG #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EHOSTDOWN WSAEHOSTDOWN #elif defined(EHOSTDOWN) #define PHP_SOCKET_EHOSTDOWN EHOSTDOWN #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EHOSTUNREACH WSAEHOSTUNREACH #elif defined(EHOSTUNREACH) #define PHP_SOCKET_EHOSTUNREACH EHOSTUNREACH #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_ENOTEMPTY WSAENOTEMPTY #elif defined(ENOTEMPTY) #define PHP_SOCKET_ENOTEMPTY ENOTEMPTY #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EUSERS WSAEUSERS #elif defined(EUSERS) #define PHP_SOCKET_EUSERS EUSERS #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EDQUOT WSAEDQUOT #elif defined(EDQUOT) #define PHP_SOCKET_EDQUOT EDQUOT #endif -#ifdef WIN32 +#ifdef PHP_WIN32 #define PHP_SOCKET_EREMOTE WSAEREMOTE #elif defined(EREMOTE) #define PHP_SOCKET_EREMOTE EREMOTE diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index 8074010709b84..3de9b6a899c63 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -1511,7 +1511,7 @@ const SOCKET_EMEDIUMTYPE = UNKNOWN; #endif -#ifdef WIN32 +#ifdef PHP_WIN32 /** * @var int * @cvalue WSAESTALE diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index 12f08f26ffbd4..f72cf038e7a18 100644 --- a/ext/sockets/sockets_arginfo.h +++ b/ext/sockets/sockets_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a551457ae505cd3d0a10da4e4b9897f556c390b4 */ + * Stub hash: 49b34a1e2f25000d71fb5bf6722db31607ded646 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(1, read, IS_ARRAY, 1) @@ -902,34 +902,34 @@ static void register_sockets_symbols(int module_number) #if defined(EMEDIUMTYPE) REGISTER_LONG_CONSTANT("SOCKET_EMEDIUMTYPE", EMEDIUMTYPE, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_ESTALE", WSAESTALE, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_EDISCON", WSAEDISCON, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_SYSNOTREADY", WSASYSNOTREADY, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_VERNOTSUPPORTED", WSAVERNOTSUPPORTED, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NOTINITIALISED", WSANOTINITIALISED, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_HOST_NOT_FOUND", WSAHOST_NOT_FOUND, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_TRY_AGAIN", WSATRY_AGAIN, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NO_RECOVERY", WSANO_RECOVERY, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NO_DATA", WSANO_DATA, CONST_PERSISTENT); #endif -#if defined(WIN32) +#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NO_ADDRESS", WSANO_ADDRESS, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("IPPROTO_IP", IPPROTO_IP, CONST_PERSISTENT); diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index 55a49fd688e81..9b598489d3f0b 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -55,7 +55,7 @@ static inline int has_crc32_insn(void) { if (sysctlbyname("hw.optional.armv8_crc32", &res, &reslen, NULL, 0) < 0) res = 0; return res; -# elif defined(WIN32) +# elif defined(_WIN32) res = (int)IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE); return res; # else diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 6a2f00a37f6dc..23359ee466cb3 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -2231,7 +2231,7 @@ consult the installation file that came with this distribution, or visit \n\ } else { parent = 0; } -#endif /* WIN32 */ +#endif /* PHP_WIN32 */ } zend_first_try {