Skip to content

Commit 84a0da1

Browse files
authored
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).
1 parent 52f6e09 commit 84a0da1

32 files changed

+76
-80
lines changed

Zend/zend_API.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3346,7 +3346,7 @@ void module_destructor(zend_module_entry *module) /* {{{ */
33463346

33473347
void module_registry_unload(const zend_module_entry *module)
33483348
{
3349-
#if HAVE_LIBDL
3349+
#ifdef HAVE_LIBDL
33503350
if (!getenv("ZEND_DONT_UNLOAD_MODULES")) {
33513351
DL_UNLOAD(module->handle);
33523352
}

Zend/zend_virtual_cwd.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
#include <stdarg.h>
3333
#include <limits.h>
3434

35-
#if HAVE_SYS_PARAM_H
35+
#ifdef HAVE_SYS_PARAM_H
3636
# include <sys/param.h>
3737
#endif
3838

3939
#ifndef MAXPATHLEN
40-
# if _WIN32
40+
# ifdef _WIN32
4141
# include "win32/ioutil.h"
4242
# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
4343
# elif PATH_MAX

ext/date/php_date.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ static void php_date_set_time_fraction(timelib_time *time, int microsecond)
23812381

23822382
static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *usec)
23832383
{
2384-
#if HAVE_GETTIMEOFDAY
2384+
#ifdef HAVE_GETTIMEOFDAY
23852385
struct timeval tp = {0}; /* For setting microsecond */
23862386

23872387
gettimeofday(&tp, NULL);

ext/dba/libflatfile/flatfile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <stdlib.h>
3030
#include <string.h>
3131
#include <errno.h>
32-
#if HAVE_UNISTD_H
32+
#ifdef HAVE_UNISTD_H
3333
#include <unistd.h>
3434
#endif
3535

ext/dba/libinifile/inifile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <stdlib.h>
2727
#include <string.h>
2828
#include <errno.h>
29-
#if HAVE_UNISTD_H
29+
#ifdef HAVE_UNISTD_H
3030
#include <unistd.h>
3131
#endif
3232

ext/dom/html_document.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ PHP_METHOD(Dom_HTMLDocument, createFromFile)
11141114
xmlFree(converted);
11151115
lxml_doc->URL = new_buffer;
11161116
} else {
1117-
#if PHP_WIN32
1117+
#ifdef PHP_WIN32
11181118
converted = php_dom_libxml_fix_file_path(converted);
11191119
#endif
11201120
lxml_doc->URL = converted;

ext/dom/xml_document.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ PHP_METHOD(Dom_XMLDocument, createEmpty)
101101
zend_argument_value_error(2, "is not a valid document encoding");
102102
RETURN_THROWS();
103103
}
104-
104+
105105
xmlDocPtr lxml_doc = xmlNewDoc((const xmlChar *) version);
106106
if (UNEXPECTED(lxml_doc == NULL)) {
107107
goto oom;
@@ -197,7 +197,7 @@ static void load_from_helper(INTERNAL_FUNCTION_PARAMETERS, int mode)
197197
if (!php_is_stream_path((char *) lxml_doc->URL)) {
198198
/* Check for "file:/" instead of "file://" because of libxml2 quirk */
199199
if (strncmp((const char *) lxml_doc->URL, "file:/", sizeof("file:/") - 1) != 0) {
200-
#if PHP_WIN32
200+
#ifdef PHP_WIN32
201201
xmlChar *buffer = xmlStrdup((const xmlChar *) "file:///");
202202
#else
203203
xmlChar *buffer = xmlStrdup((const xmlChar *) "file://");
@@ -212,7 +212,7 @@ static void load_from_helper(INTERNAL_FUNCTION_PARAMETERS, int mode)
212212
}
213213
}
214214
} else {
215-
#if PHP_WIN32
215+
#ifdef PHP_WIN32
216216
lxml_doc->URL = php_dom_libxml_fix_file_path(BAD_CAST lxml_doc->URL);
217217
#endif
218218
}

ext/opcache/ZendAccelerator.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ static int zend_get_stream_timestamp(const char *filename, zend_stat_t *statbuf)
962962
return SUCCESS;
963963
}
964964

965-
#if ZEND_WIN32
965+
#ifdef ZEND_WIN32
966966
static accel_time_t zend_get_file_handle_timestamp_win(zend_file_handle *file_handle, size_t *size)
967967
{
968968
static unsigned __int64 utc_base = 0;
@@ -2177,7 +2177,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
21772177
HANDLE_UNBLOCK_INTERRUPTIONS();
21782178
} else {
21792179

2180-
#if !ZEND_WIN32
2180+
#ifndef ZEND_WIN32
21812181
ZCSG(hits)++; /* TBFixed: may lose one hit */
21822182
persistent_script->dynamic_members.hits++; /* see above */
21832183
#else

ext/opcache/ZendAccelerator.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
/* 8 - Standalone Open Source Zend OPcache */
3737
#define ACCELERATOR_API_NO 8
3838

39-
#if ZEND_WIN32
39+
#ifdef ZEND_WIN32
4040
# include "zend_config.w32.h"
4141
#else
4242
#include "zend_config.h"
4343
# include <sys/time.h>
4444
# include <sys/resource.h>
4545
#endif
4646

47-
#if HAVE_UNISTD_H
47+
#ifdef HAVE_UNISTD_H
4848
# include "unistd.h"
4949
#endif
5050

@@ -97,7 +97,7 @@ extern int lock_file;
9797
# define ENABLE_FILE_CACHE_FALLBACK 0
9898
#endif
9999

100-
#if ZEND_WIN32
100+
#ifdef ZEND_WIN32
101101
typedef unsigned __int64 accel_time_t;
102102
#else
103103
typedef time_t accel_time_t;

ext/opcache/jit/zend_jit.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string *memb
691691
# pragma clang diagnostic pop
692692
#endif
693693

694-
#if _WIN32
694+
#ifdef _WIN32
695695
# include <Windows.h>
696696
#else
697697
# include <sys/mman.h>
@@ -3246,7 +3246,7 @@ ZEND_EXT_API void zend_jit_unprotect(void)
32463246
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
32473247
}
32483248
}
3249-
#elif _WIN32
3249+
#elif defined(_WIN32)
32503250
if (!(JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP))) {
32513251
DWORD old, new;
32523252
#ifdef ZTS
@@ -3277,7 +3277,7 @@ ZEND_EXT_API void zend_jit_protect(void)
32773277
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
32783278
}
32793279
}
3280-
#elif _WIN32
3280+
#elif defined(_WIN32)
32813281
if (!(JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP))) {
32823282
DWORD old;
32833283

@@ -3520,7 +3520,7 @@ ZEND_EXT_API void zend_jit_startup(void *buf, size_t size, bool reattached)
35203520
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
35213521
}
35223522
}
3523-
#elif _WIN32
3523+
#elif defined(_WIN32)
35243524
if (JIT_G(debug) & (ZEND_JIT_DEBUG_GDB|ZEND_JIT_DEBUG_PERF_DUMP)) {
35253525
DWORD old;
35263526

ext/opcache/jit/zend_jit_ir.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,7 @@ static void zend_jit_calc_trace_prologue_size(void)
31253125
zend_jit_trace_prologue_size = size;
31263126
}
31273127

3128-
#if !ZEND_WIN32 && !defined(IR_TARGET_AARCH64)
3128+
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
31293129
static uintptr_t zend_jit_hybrid_vm_sp_adj = 0;
31303130

31313131
typedef struct _Unwind_Context _Unwind_Context;
@@ -3239,7 +3239,7 @@ static void zend_jit_setup(void)
32393239
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Could not enable JIT: offset >= size");
32403240
}
32413241
} while(0);
3242-
# elif ZEND_WIN32
3242+
# elif defined(ZEND_WIN32)
32433243
tsrm_tls_index = _tls_index * sizeof(void*);
32443244

32453245
/* 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)
33393339
# endif
33403340
#endif
33413341

3342-
#if !ZEND_WIN32 && !defined(IR_TARGET_AARCH64)
3342+
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
33433343
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
33443344
zend_jit_set_sp_adj_vm(); // set zend_jit_hybrid_vm_sp_adj
33453345
}
@@ -5441,7 +5441,7 @@ static int zend_jit_add_arrays(zend_jit_ctx *jit, const zend_op *opline, uint32_
54415441
static int zend_jit_long_math_helper(zend_jit_ctx *jit,
54425442
const zend_op *opline,
54435443
uint8_t opcode,
5444-
uint8_t op1_type,
5444+
uint8_t op1_type,
54455445
znode_op op1,
54465446
zend_jit_addr op1_addr,
54475447
uint32_t op1_info,
@@ -7982,7 +7982,7 @@ static int zend_jit_type_check(zend_jit_ctx *jit, const zend_op *opline, uint32_
79827982

79837983
if (op1_info & (MAY_BE_ANY|MAY_BE_REF)) {
79847984
mask = opline->extended_value;
7985-
if (!(op1_info & MAY_BE_GUARD) && !(op1_info & (MAY_BE_ANY - mask))) {
7985+
if (!(op1_info & MAY_BE_GUARD) && !(op1_info & (MAY_BE_ANY - mask))) {
79867986
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
79877987
if (exit_addr) {
79887988
if (smart_branch_opcode == ZEND_JMPNZ) {
@@ -11840,7 +11840,7 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
1184011840
if (opline->op2_type != IS_CONST) {
1184111841
ir_ref if_num, end1, ref2;
1184211842

11843-
if_num = ir_IF(
11843+
if_num = ir_IF(
1184411844
ir_ULE(
1184511845
ir_LOAD_C(ir_ADD_OFFSET(key, offsetof(zend_string, val))),
1184611846
ir_CONST_CHAR('9')));
@@ -16030,7 +16030,7 @@ static void *zend_jit_finish(zend_jit_ctx *jit)
1603016030
// ir_mem_unprotect(entry, size);
1603116031
if (!(jit->ctx.flags & IR_FUNCTION)
1603216032
&& zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
16033-
#if !ZEND_WIN32 && !defined(IR_TARGET_AARCH64)
16033+
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
1603416034
sp_offset = zend_jit_hybrid_vm_sp_adj;
1603516035
#else
1603616036
sp_offset = sizeof(void*);

ext/opcache/zend_accelerator_module.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ ZEND_INI_BEGIN()
323323
#ifndef ZEND_WIN32
324324
STD_PHP_INI_ENTRY("opcache.preload_user" , "" , PHP_INI_SYSTEM, OnUpdateStringUnempty, accel_directives.preload_user, zend_accel_globals, accel_globals)
325325
#endif
326-
#if ZEND_WIN32
326+
#ifdef ZEND_WIN32
327327
STD_PHP_INI_ENTRY("opcache.cache_id" , "" , PHP_INI_SYSTEM, OnUpdateString, accel_directives.cache_id, zend_accel_globals, accel_globals)
328328
#endif
329329
#ifdef HAVE_JIT
@@ -838,7 +838,7 @@ ZEND_FUNCTION(opcache_get_configuration)
838838
#ifndef ZEND_WIN32
839839
add_assoc_string(&directives, "opcache.preload_user", STRING_NOT_NULL(ZCG(accel_directives).preload_user));
840840
#endif
841-
#if ZEND_WIN32
841+
#ifdef ZEND_WIN32
842842
add_assoc_string(&directives, "opcache.cache_id", STRING_NOT_NULL(ZCG(accel_directives).cache_id));
843843
#endif
844844
#ifdef HAVE_JIT

ext/opcache/zend_file_cache.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include <sys/stat.h>
4545
#include <fcntl.h>
4646

47-
#if HAVE_UNISTD_H
47+
#ifdef HAVE_UNISTD_H
4848
#include <unistd.h>
4949
#endif
5050

ext/random/csprng.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "php_random.h"
3232
#include "php_random_csprng.h"
3333

34-
#if HAVE_UNISTD_H
34+
#ifdef HAVE_UNISTD_H
3535
# include <unistd.h>
3636
#endif
3737

@@ -45,7 +45,7 @@
4545
# include <sys/syscall.h>
4646
#endif
4747

48-
#if HAVE_SYS_PARAM_H
48+
#ifdef HAVE_SYS_PARAM_H
4949
# include <sys/param.h>
5050
# if (__FreeBSD__ && __FreeBSD_version > 1200000) || (__DragonFly__ && __DragonFly_version >= 500700) || \
5151
defined(__sun) || (defined(__NetBSD__) && __NetBSD_Version__ >= 1000000000) || defined(__midipix__)

ext/random/random.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "php_random_csprng.h"
3535
#include "ext/standard/sha1.h"
3636

37-
#if HAVE_UNISTD_H
37+
#ifdef HAVE_UNISTD_H
3838
# include <unistd.h>
3939
#endif
4040

@@ -46,7 +46,7 @@
4646
# include <sys/time.h>
4747
#endif
4848

49-
#if HAVE_SYS_PARAM_H
49+
#ifdef HAVE_SYS_PARAM_H
5050
# include <sys/param.h>
5151
#endif
5252

ext/sockets/php_sockets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef PHP_SOCKETS_H
2121
#define PHP_SOCKETS_H
2222

23-
#if HAVE_CONFIG_H
23+
#ifdef HAVE_CONFIG_H
2424
# include "config.h"
2525
#endif
2626

ext/standard/file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# include "win32/fnmatch.h"
4646
# include "win32/ioutil.h"
4747
#else
48-
# if HAVE_SYS_PARAM_H
48+
# ifdef HAVE_SYS_PARAM_H
4949
# include <sys/param.h>
5050
# endif
5151
# if HAVE_SYS_SELECT_H
@@ -54,7 +54,7 @@
5454
# include <sys/socket.h>
5555
# include <netinet/in.h>
5656
# include <netdb.h>
57-
# if HAVE_ARPA_INET_H
57+
# ifdef HAVE_ARPA_INET_H
5858
# include <arpa/inet.h>
5959
# endif
6060
#endif

ext/standard/streamsfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ PHP_FUNCTION(stream_isatty)
16971697
#ifdef PHP_WIN32
16981698
/* Check if the Windows standard handle is redirected to file */
16991699
RETVAL_BOOL(php_win32_console_fileno_is_console(fileno));
1700-
#elif HAVE_UNISTD_H
1700+
#elif defined(HAVE_UNISTD_H)
17011701
/* Check if the file descriptor identifier is a terminal */
17021702
RETVAL_BOOL(isatty(fileno));
17031703
#else

main/fopen_wrappers.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
#include "php_network.h"
4141
#include "zend_smart_str.h"
4242

43-
#if HAVE_PWD_H
43+
#ifdef HAVE_PWD_H
4444
#include <pwd.h>
4545
#endif
4646

4747
#include <sys/types.h>
48-
#if HAVE_SYS_SOCKET_H
48+
#ifdef HAVE_SYS_SOCKET_H
4949
#include <sys/socket.h>
5050
#endif
5151

@@ -54,7 +54,7 @@
5454
#else
5555
#include <netinet/in.h>
5656
#include <netdb.h>
57-
#if HAVE_ARPA_INET_H
57+
#ifdef HAVE_ARPA_INET_H
5858
#include <arpa/inet.h>
5959
#endif
6060
#endif
@@ -368,7 +368,7 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle)
368368
memset(file_handle, 0, sizeof(zend_file_handle));
369369

370370
path_info = SG(request_info).request_uri;
371-
#if HAVE_PWD_H
371+
#ifdef HAVE_PWD_H
372372
if (PG(user_dir) && *PG(user_dir) && path_info && '/' == path_info[0] && '~' == path_info[1]) {
373373
char *s = strchr(path_info + 2, '/');
374374

main/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
#include "win32/winutil.h"
3131
#include <process.h>
3232
#endif
33-
#if HAVE_SYS_TIME_H
33+
#ifdef HAVE_SYS_TIME_H
3434
#include <sys/time.h>
3535
#endif
36-
#if HAVE_UNISTD_H
36+
#ifdef HAVE_UNISTD_H
3737
#include <unistd.h>
3838
#endif
3939

0 commit comments

Comments
 (0)