Skip to content

Sync #if/ifdef/defined #14508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_virtual_cwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,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);
Expand Down
2 changes: 1 addition & 1 deletion ext/dba/libflatfile/flatfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ext/dba/libinifile/inifile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ext/dom/html_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions ext/dom/xml_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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://");
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
/* 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"
# include <sys/time.h>
# include <sys/resource.h>
#endif

#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include "unistd.h"
#endif

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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')));
Expand Down Expand Up @@ -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*);
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/zend_file_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <sys/stat.h>
#include <fcntl.h>

#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

Expand Down
4 changes: 2 additions & 2 deletions ext/random/csprng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions ext/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -46,7 +46,7 @@
# include <sys/time.h>
#endif

#if HAVE_SYS_PARAM_H
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion ext/sockets/php_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef PHP_SOCKETS_H
#define PHP_SOCKETS_H

#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/streamsfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions main/fopen_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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, '/');

Expand Down
4 changes: 2 additions & 2 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading
Loading