Skip to content

Commit

Permalink
Replace WIN32 conditions with _WIN32 or PHP_WIN32 (#14462)
Browse files Browse the repository at this point in the history
* 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
libgd/libgd@c60d9fe

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 Cyan4973/xxHash#931

* Update end comment with PHP_WIN32
  • Loading branch information
petk authored Jun 10, 2024
1 parent bcecbb5 commit a82d864
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/libgd/gd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ";"
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/libgd/gdft.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#endif
#endif

#ifdef WIN32
#ifdef _WIN32
#define access _access
#ifndef R_OK
#define R_OK 2
Expand Down
2 changes: 1 addition & 1 deletion ext/hash/xxhash/xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ext/mbstring/libmbfl/mbfl/mbfl_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define SIZE_MAX ((size_t)~0)
#endif

#ifdef WIN32
#ifdef _WIN32
#ifdef MBFL_DLL_EXPORT
#define MBFLAPI __declspec(dllexport)
#else
Expand All @@ -55,6 +55,6 @@
#else
#define MBFLAPI
#endif /* defined(__GNUC__) && __GNUC__ >= 4 */
#endif /* WIN32 */
#endif /* _WIN32 */

#endif /* MBFL_DEFS_H */
2 changes: 1 addition & 1 deletion ext/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
82 changes: 41 additions & 41 deletions ext/sockets/php_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/sockets/sockets.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@
const SOCKET_EMEDIUMTYPE = UNKNOWN;
#endif

#ifdef WIN32
#ifdef PHP_WIN32
/**
* @var int
* @cvalue WSAESTALE
Expand Down
Loading

0 comments on commit a82d864

Please sign in to comment.