Sync #if/ifdef/defined (#14508)

This syncs CPP macro conditions:
- _WIN32
- _WIN64
- HAVE_ALLOCA_H
- HAVE_ALPHASORT
- HAVE_ARPA_INET_H
- HAVE_CONFIG_H
- HAVE_DIRENT_H
- HAVE_DLFCN_H
- HAVE_GETTIMEOFDAY
- HAVE_LIBDL
- HAVE_POLL_H
- HAVE_PWD_H
- HAVE_SCANDIR
- HAVE_SYS_FILE_H
- HAVE_SYS_PARAM_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_TIME_H
- HAVE_SYS_TYPES_H
- HAVE_SYS_WAIT_H
- HAVE_UNISTD_H
- PHP_WIN32
- ZEND_WIN32

These are either undefined or defined to 1 in Autotools and Windows.

Follow up of GH-5526 (-Wundef).
This commit is contained in:
Peter Kokot 2024-06-09 14:23:41 +02:00 committed by GitHub
parent 52f6e099b0
commit 84a0da1574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 76 additions and 80 deletions

View File

@ -3346,7 +3346,7 @@ void module_destructor(zend_module_entry *module) /* {{{ */
void module_registry_unload(const zend_module_entry *module)
{
#if HAVE_LIBDL
#ifdef HAVE_LIBDL
if (!getenv("ZEND_DONT_UNLOAD_MODULES")) {
DL_UNLOAD(module->handle);
}

View File

@ -32,12 +32,12 @@
#include <stdarg.h>
#include <limits.h>
#if HAVE_SYS_PARAM_H
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifndef MAXPATHLEN
# if _WIN32
# ifdef _WIN32
# include "win32/ioutil.h"
# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
# elif PATH_MAX

View File

@ -2381,7 +2381,7 @@ static void php_date_set_time_fraction(timelib_time *time, int microsecond)
static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *usec)
{
#if HAVE_GETTIMEOFDAY
#ifdef HAVE_GETTIMEOFDAY
struct timeval tp = {0}; /* For setting microsecond */
gettimeofday(&tp, NULL);

View File

@ -29,7 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@ -1114,7 +1114,7 @@ PHP_METHOD(Dom_HTMLDocument, createFromFile)
xmlFree(converted);
lxml_doc->URL = new_buffer;
} else {
#if PHP_WIN32
#ifdef PHP_WIN32
converted = php_dom_libxml_fix_file_path(converted);
#endif
lxml_doc->URL = converted;

View File

@ -101,7 +101,7 @@ PHP_METHOD(Dom_XMLDocument, createEmpty)
zend_argument_value_error(2, "is not a valid document encoding");
RETURN_THROWS();
}
xmlDocPtr lxml_doc = xmlNewDoc((const xmlChar *) version);
if (UNEXPECTED(lxml_doc == NULL)) {
goto oom;
@ -197,7 +197,7 @@ static void load_from_helper(INTERNAL_FUNCTION_PARAMETERS, int mode)
if (!php_is_stream_path((char *) lxml_doc->URL)) {
/* Check for "file:/" instead of "file://" because of libxml2 quirk */
if (strncmp((const char *) lxml_doc->URL, "file:/", sizeof("file:/") - 1) != 0) {
#if PHP_WIN32
#ifdef PHP_WIN32
xmlChar *buffer = xmlStrdup((const xmlChar *) "file:///");
#else
xmlChar *buffer = xmlStrdup((const xmlChar *) "file://");
@ -212,7 +212,7 @@ static void load_from_helper(INTERNAL_FUNCTION_PARAMETERS, int mode)
}
}
} else {
#if PHP_WIN32
#ifdef PHP_WIN32
lxml_doc->URL = php_dom_libxml_fix_file_path(BAD_CAST lxml_doc->URL);
#endif
}

View File

@ -962,7 +962,7 @@ static int zend_get_stream_timestamp(const char *filename, zend_stat_t *statbuf)
return SUCCESS;
}
#if ZEND_WIN32
#ifdef ZEND_WIN32
static accel_time_t zend_get_file_handle_timestamp_win(zend_file_handle *file_handle, size_t *size)
{
static unsigned __int64 utc_base = 0;
@ -2177,7 +2177,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
HANDLE_UNBLOCK_INTERRUPTIONS();
} else {
#if !ZEND_WIN32
#ifndef ZEND_WIN32
ZCSG(hits)++; /* TBFixed: may lose one hit */
persistent_script->dynamic_members.hits++; /* see above */
#else

View File

@ -36,7 +36,7 @@
/* 8 - Standalone Open Source Zend OPcache */
#define ACCELERATOR_API_NO 8
#if ZEND_WIN32
#ifdef ZEND_WIN32
# include "zend_config.w32.h"
#else
#include "zend_config.h"
@ -44,7 +44,7 @@
# include <sys/resource.h>
#endif
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include "unistd.h"
#endif
@ -97,7 +97,7 @@ extern int lock_file;
# define ENABLE_FILE_CACHE_FALLBACK 0
#endif
#if ZEND_WIN32
#ifdef ZEND_WIN32
typedef unsigned __int64 accel_time_t;
#else
typedef time_t accel_time_t;

View File

@ -691,7 +691,7 @@ static bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string *memb
# pragma clang diagnostic pop
#endif
#if _WIN32
#ifdef _WIN32
# include <Windows.h>
#else
# include <sys/mman.h>
@ -3246,7 +3246,7 @@ ZEND_EXT_API void zend_jit_unprotect(void)
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
}
}
#elif _WIN32
#elif defined(_WIN32)
if (!(JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP))) {
DWORD old, new;
#ifdef ZTS
@ -3277,7 +3277,7 @@ ZEND_EXT_API void zend_jit_protect(void)
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
}
}
#elif _WIN32
#elif defined(_WIN32)
if (!(JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP))) {
DWORD old;
@ -3520,7 +3520,7 @@ ZEND_EXT_API void zend_jit_startup(void *buf, size_t size, bool reattached)
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
}
}
#elif _WIN32
#elif defined(_WIN32)
if (JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP)) {
DWORD old;

View File

@ -3125,7 +3125,7 @@ static void zend_jit_calc_trace_prologue_size(void)
zend_jit_trace_prologue_size = size;
}
#if !ZEND_WIN32 && !defined(IR_TARGET_AARCH64)
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
static uintptr_t zend_jit_hybrid_vm_sp_adj = 0;
typedef struct _Unwind_Context _Unwind_Context;
@ -3239,7 +3239,7 @@ static void zend_jit_setup(void)
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Could not enable JIT: offset >= size");
}
} while(0);
# elif ZEND_WIN32
# elif defined(ZEND_WIN32)
tsrm_tls_index = _tls_index * sizeof(void*);
/* To find offset of "_tsrm_ls_cache" in TLS segment we perform a linear scan of local TLS memory */
@ -3339,7 +3339,7 @@ static void zend_jit_setup(void)
# endif
#endif
#if !ZEND_WIN32 && !defined(IR_TARGET_AARCH64)
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
zend_jit_set_sp_adj_vm(); // set zend_jit_hybrid_vm_sp_adj
}
@ -5441,7 +5441,7 @@ static int zend_jit_add_arrays(zend_jit_ctx *jit, const zend_op *opline, uint32_
static int zend_jit_long_math_helper(zend_jit_ctx *jit,
const zend_op *opline,
uint8_t opcode,
uint8_t op1_type,
uint8_t op1_type,
znode_op op1,
zend_jit_addr op1_addr,
uint32_t op1_info,
@ -7982,7 +7982,7 @@ static int zend_jit_type_check(zend_jit_ctx *jit, const zend_op *opline, uint32_
if (op1_info & (MAY_BE_ANY|MAY_BE_REF)) {
mask = opline->extended_value;
if (!(op1_info & MAY_BE_GUARD) && !(op1_info & (MAY_BE_ANY - mask))) {
if (!(op1_info & MAY_BE_GUARD) && !(op1_info & (MAY_BE_ANY - mask))) {
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
if (exit_addr) {
if (smart_branch_opcode == ZEND_JMPNZ) {
@ -11840,7 +11840,7 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
if (opline->op2_type != IS_CONST) {
ir_ref if_num, end1, ref2;
if_num = ir_IF(
if_num = ir_IF(
ir_ULE(
ir_LOAD_C(ir_ADD_OFFSET(key, offsetof(zend_string, val))),
ir_CONST_CHAR('9')));
@ -16030,7 +16030,7 @@ static void *zend_jit_finish(zend_jit_ctx *jit)
// ir_mem_unprotect(entry, size);
if (!(jit->ctx.flags & IR_FUNCTION)
&& zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
#if !ZEND_WIN32 && !defined(IR_TARGET_AARCH64)
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
sp_offset = zend_jit_hybrid_vm_sp_adj;
#else
sp_offset = sizeof(void*);

View File

@ -323,7 +323,7 @@ ZEND_INI_BEGIN()
#ifndef ZEND_WIN32
STD_PHP_INI_ENTRY("opcache.preload_user" , "" , PHP_INI_SYSTEM, OnUpdateStringUnempty, accel_directives.preload_user, zend_accel_globals, accel_globals)
#endif
#if ZEND_WIN32
#ifdef ZEND_WIN32
STD_PHP_INI_ENTRY("opcache.cache_id" , "" , PHP_INI_SYSTEM, OnUpdateString, accel_directives.cache_id, zend_accel_globals, accel_globals)
#endif
#ifdef HAVE_JIT
@ -838,7 +838,7 @@ ZEND_FUNCTION(opcache_get_configuration)
#ifndef ZEND_WIN32
add_assoc_string(&directives, "opcache.preload_user", STRING_NOT_NULL(ZCG(accel_directives).preload_user));
#endif
#if ZEND_WIN32
#ifdef ZEND_WIN32
add_assoc_string(&directives, "opcache.cache_id", STRING_NOT_NULL(ZCG(accel_directives).cache_id));
#endif
#ifdef HAVE_JIT

View File

@ -44,7 +44,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@ -31,7 +31,7 @@
#include "php_random.h"
#include "php_random_csprng.h"
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@ -45,7 +45,7 @@
# include <sys/syscall.h>
#endif
#if HAVE_SYS_PARAM_H
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
# if (__FreeBSD__ && __FreeBSD_version > 1200000) || (__DragonFly__ && __DragonFly_version >= 500700) || \
defined(__sun) || (defined(__NetBSD__) && __NetBSD_Version__ >= 1000000000) || defined(__midipix__)

View File

@ -34,7 +34,7 @@
#include "php_random_csprng.h"
#include "ext/standard/sha1.h"
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@ -46,7 +46,7 @@
# include <sys/time.h>
#endif
#if HAVE_SYS_PARAM_H
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif

View File

@ -20,7 +20,7 @@
#ifndef PHP_SOCKETS_H
#define PHP_SOCKETS_H
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

View File

@ -45,7 +45,7 @@
# include "win32/fnmatch.h"
# include "win32/ioutil.h"
#else
# if HAVE_SYS_PARAM_H
# ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
# endif
# if HAVE_SYS_SELECT_H
@ -54,7 +54,7 @@
# include <sys/socket.h>
# include <netinet/in.h>
# include <netdb.h>
# if HAVE_ARPA_INET_H
# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
#endif

View File

@ -1697,7 +1697,7 @@ PHP_FUNCTION(stream_isatty)
#ifdef PHP_WIN32
/* Check if the Windows standard handle is redirected to file */
RETVAL_BOOL(php_win32_console_fileno_is_console(fileno));
#elif HAVE_UNISTD_H
#elif defined(HAVE_UNISTD_H)
/* Check if the file descriptor identifier is a terminal */
RETVAL_BOOL(isatty(fileno));
#else

View File

@ -40,12 +40,12 @@
#include "php_network.h"
#include "zend_smart_str.h"
#if HAVE_PWD_H
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@ -54,7 +54,7 @@
#else
#include <netinet/in.h>
#include <netdb.h>
#if HAVE_ARPA_INET_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#endif
@ -368,7 +368,7 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle)
memset(file_handle, 0, sizeof(zend_file_handle));
path_info = SG(request_info).request_uri;
#if HAVE_PWD_H
#ifdef HAVE_PWD_H
if (PG(user_dir) && *PG(user_dir) && path_info && '/' == path_info[0] && '~' == path_info[1]) {
char *s = strchr(path_info + 2, '/');

View File

@ -30,10 +30,10 @@
#include "win32/winutil.h"
#include <process.h>
#endif
#if HAVE_SYS_TIME_H
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@ -33,7 +33,7 @@
#endif
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@ -44,7 +44,7 @@
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#if HAVE_POLL_H
#ifdef HAVE_POLL_H
#include <poll.h>
#elif HAVE_SYS_POLL_H
#include <sys/poll.h>
@ -54,7 +54,7 @@
#ifndef PHP_WIN32
#include <netinet/in.h>
#include <netdb.h>
#if HAVE_ARPA_INET_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#endif
@ -774,7 +774,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
struct sockaddr **sal, **psal, *sa;
struct timeval working_timeout;
socklen_t socklen;
#if HAVE_GETTIMEOFDAY
#ifdef HAVE_GETTIMEOFDAY
struct timeval limit_time, time_now;
#endif
@ -787,7 +787,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
if (timeout) {
memcpy(&working_timeout, timeout, sizeof(working_timeout));
#if HAVE_GETTIMEOFDAY
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&limit_time, NULL);
limit_time.tv_sec += working_timeout.tv_sec;
limit_time.tv_usec += working_timeout.tv_usec;
@ -906,7 +906,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
}
/* adjust timeout for next attempt */
#if HAVE_GETTIMEOFDAY
#ifdef HAVE_GETTIMEOFDAY
if (timeout) {
gettimeofday(&time_now, NULL);

View File

@ -122,11 +122,11 @@ typedef int pid_t;
#include <unix.h>
#endif
#if HAVE_ALLOCA_H
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#if HAVE_BUILD_DEFS_H
#ifdef HAVE_BUILD_DEFS_H
#include <build-defs.h>
#endif
@ -209,7 +209,7 @@ typedef unsigned int socklen_t;
#include <stdlib.h>
#include <ctype.h>
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -220,7 +220,7 @@ typedef unsigned int socklen_t;
#include "zend_stack.h"
#include <string.h>
#if HAVE_PWD_H
#ifdef HAVE_PWD_H
# ifdef PHP_WIN32
#include "win32/param.h"
# else

View File

@ -30,7 +30,7 @@
#include "win32/winutil.h"
#endif
#if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
#if defined(HAVE_SCANDIR) && defined(HAVE_ALPHASORT) && defined(HAVE_DIRENT_H)
#include <dirent.h>
#endif

View File

@ -31,7 +31,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#if HAVE_ARPA_INET_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#endif

View File

@ -19,7 +19,7 @@
#include <Ws2tcpip.h>
#endif
#if HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif

View File

@ -23,10 +23,10 @@
#include "ext/standard/php_filestat.h"
#include <stddef.h>
#include <fcntl.h>
#if HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#if HAVE_SYS_FILE_H
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#ifdef HAVE_SYS_MMAN_H

View File

@ -36,11 +36,11 @@
# include <process.h>
#endif
#if HAVE_SYS_TIME_H
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@ -48,11 +48,11 @@
#include <locale.h>
#if HAVE_SYS_TYPES_H
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
@ -1737,7 +1737,7 @@ int main(int argc, char *argv[])
int warmup_repeats = 0;
int repeats = 1;
int benchmark = 0;
#if HAVE_GETTIMEOFDAY
#ifdef HAVE_GETTIMEOFDAY
struct timeval start, end;
#else
time_t start, end;

View File

@ -39,10 +39,10 @@
#include <process.h>
#include <shellapi.h>
#endif
#if HAVE_SYS_TIME_H
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@ -36,17 +36,17 @@
#include <unixlib/local.h>
#endif
#if HAVE_SYS_TIME_H
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <signal.h>
#include <locale.h>
#if HAVE_DLFCN_H
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
@ -222,7 +222,7 @@ static const php_cli_server_http_response_status_code_pair template_map[] = {
static int php_cli_server_log_level = 3;
#if HAVE_UNISTD_H || defined(PHP_WIN32)
#if defined(HAVE_UNISTD_H) || defined(PHP_WIN32)
static int php_cli_output_is_tty = OUTPUT_NOT_CHECKED;
#endif
@ -1164,7 +1164,7 @@ static bool php_cli_server_content_sender_pull(php_cli_server_content_sender *se
return true;
} /* }}} */
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
static int php_cli_is_output_tty(void) /* {{{ */
{
if (php_cli_output_is_tty == OUTPUT_NOT_CHECKED) {
@ -1199,7 +1199,7 @@ static void php_cli_server_log_response(php_cli_server_client *client, int statu
}
}
#if HAVE_UNISTD_H || defined(PHP_WIN32)
#if defined(HAVE_UNISTD_H) || defined(PHP_WIN32)
if (CLI_SERVER_G(color) && php_cli_is_output_tty() == OUTPUT_IS_TTY) {
if (effective_status >= 500) {
/* server error: red */

View File

@ -30,17 +30,15 @@
#include <stdio.h>
#include <stdlib.h>
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/wait.h>
#include <sys/stat.h>
#if HAVE_SYS_TYPES_H
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <signal.h>

View File

@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include <stdlib.h>
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -60,10 +60,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/stat.h>
#if HAVE_SYS_TYPES_H
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <sys/types.h>

View File

@ -683,7 +683,7 @@ __forceinline static char *php_win32_ioutil_realpath(const char *path, char *res
}/*}}}*/
#include <sys/stat.h>
#if _WIN64
#ifdef _WIN64
typedef unsigned __int64 php_win32_ioutil_dev_t;
typedef unsigned __int64 php_win32_ioutil_ino_t;
typedef __time64_t php_win32_ioutil_time_t;