From 985f024b7dfb9382460c3a1f0d3937b5795d585d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 22 Jan 2023 08:45:44 +0100 Subject: [PATCH 01/22] Zend/zend_iterators: add include guards --- Zend/zend_iterators.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Zend/zend_iterators.h b/Zend/zend_iterators.h index 5e7451f7eacc7..52247ea5f4af8 100644 --- a/Zend/zend_iterators.h +++ b/Zend/zend_iterators.h @@ -17,6 +17,9 @@ +----------------------------------------------------------------------+ */ +#ifndef ZEND_ITERATORS_H +#define ZEND_ITERATORS_H + /* These iterators were designed to operate within the foreach() * structures provided by the engine, but could be extended for use * with other iterative engine opcodes. @@ -89,3 +92,5 @@ ZEND_API void zend_iterator_dtor(zend_object_iterator *iter); ZEND_API void zend_register_iterator_wrapper(void); END_EXTERN_C() + +#endif /* ZEND_ITERATORS_H */ From 9842ad1fd961e4cae3b939e35da9e12dd84664d9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 22 Jan 2023 08:30:39 +0100 Subject: [PATCH 02/22] main/php.h: add #include directives that some extensions rely on These are currently indirectly included, but in order to retain source compatibility with out-of-tree extensions when #includes are cleaned up in those parts of PHP, we need to re-add them to the "php.h" header. --- main/php.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main/php.h b/main/php.h index c3d139059c48f..e6083a1f1c8c0 100644 --- a/main/php.h +++ b/main/php.h @@ -441,4 +441,19 @@ typedef bool zend_bool; typedef intptr_t zend_intptr_t; typedef uintptr_t zend_uintptr_t; +/* the following headers used to be included indirectly, and we have + * them here only for backwards compatibility with thirdparty + * extensions */ +#include "php_globals.h" +#include "php_ini.h" +#include "zend_alloc.h" +#include "zend_arena.h" +#include "zend_iterators.h" +#include "zend_multiply.h" +#include "zend_objects.h" +#include "zend_strtod.h" +#include +#include +#include + #endif From 919dbb9e5eee36e4c2462caf6cc208df250d25d9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 10:18:49 +0100 Subject: [PATCH 03/22] Zend/zend_portability: include php_config.h for HAVE_* --- Zend/zend_portability.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 8f9b7fd4a9e30..0861fc07e562d 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -21,6 +21,12 @@ #ifndef ZEND_PORTABILITY_H #define ZEND_PORTABILITY_H +#ifdef PHP_WIN32 +#include "config.w32.h" +#else +#include "zend_config.h" +#endif + #ifdef __cplusplus #define BEGIN_EXTERN_C() extern "C" { #define END_EXTERN_C() } From c28faec5a545ecb4677d17146201b1f38e868e48 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 20:34:59 +0100 Subject: [PATCH 04/22] Zend/zend_globals_macros: add missing includes --- Zend/zend_globals_macros.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Zend/zend_globals_macros.h b/Zend/zend_globals_macros.h index 59b3daca53fd4..98f4940f47913 100644 --- a/Zend/zend_globals_macros.h +++ b/Zend/zend_globals_macros.h @@ -20,6 +20,12 @@ #ifndef ZEND_GLOBALS_MACROS_H #define ZEND_GLOBALS_MACROS_H +#include "zend_portability.h" + +#ifdef ZTS +# include "TSRM.h" +#endif + typedef struct _zend_compiler_globals zend_compiler_globals; typedef struct _zend_executor_globals zend_executor_globals; typedef struct _zend_php_scanner_globals zend_php_scanner_globals; From 911225cbdbdc34422b864118ccc9d7616fa2223a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Jan 2023 10:08:11 +0100 Subject: [PATCH 05/22] Zend/Optimizer/optimize_temp_vars_5: add missing include --- Zend/Optimizer/optimize_temp_vars_5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/Optimizer/optimize_temp_vars_5.c b/Zend/Optimizer/optimize_temp_vars_5.c index 33d418ffbd99c..899ba3d345d22 100644 --- a/Zend/Optimizer/optimize_temp_vars_5.c +++ b/Zend/Optimizer/optimize_temp_vars_5.c @@ -21,6 +21,7 @@ #include "Optimizer/zend_optimizer.h" #include "Optimizer/zend_optimizer_internal.h" +#include "zend_arena.h" #include "zend_API.h" #include "zend_constants.h" #include "zend_execute.h" From 207dff8e3b31777bea7f1feb81c78fe5e196f29a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Jan 2023 10:08:37 +0100 Subject: [PATCH 06/22] Zend/Optimizer/compact_literals: add missing include --- Zend/Optimizer/compact_literals.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/Optimizer/compact_literals.c b/Zend/Optimizer/compact_literals.c index 9248f0b822441..db0ef752ee222 100644 --- a/Zend/Optimizer/compact_literals.c +++ b/Zend/Optimizer/compact_literals.c @@ -23,6 +23,7 @@ #include "Optimizer/zend_optimizer.h" #include "Optimizer/zend_optimizer_internal.h" +#include "zend_arena.h" #include "zend_API.h" #include "zend_constants.h" #include "zend_execute.h" From ed251cb799864205905e4ead99860afe9400c405 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Jan 2023 10:40:59 +0100 Subject: [PATCH 07/22] Zend/Optimizer/block_pass: add missing include --- Zend/Optimizer/block_pass.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/Optimizer/block_pass.c b/Zend/Optimizer/block_pass.c index 41f6234652bac..4fe6d872028e1 100644 --- a/Zend/Optimizer/block_pass.c +++ b/Zend/Optimizer/block_pass.c @@ -22,6 +22,7 @@ #include "Optimizer/zend_optimizer.h" #include "Optimizer/zend_optimizer_internal.h" #include "zend_API.h" +#include "zend_arena.h" #include "zend_constants.h" #include "zend_execute.h" #include "zend_vm.h" From fbbd28059af344ba1e301a119a72e03f819b8116 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Jan 2023 10:40:02 +0100 Subject: [PATCH 08/22] Zend/Optimizer/dfa_pass: add missing include --- Zend/Optimizer/dfa_pass.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/Optimizer/dfa_pass.c b/Zend/Optimizer/dfa_pass.c index ac99455c1f808..0b006598e3e11 100644 --- a/Zend/Optimizer/dfa_pass.c +++ b/Zend/Optimizer/dfa_pass.c @@ -19,6 +19,7 @@ #include "Optimizer/zend_optimizer.h" #include "Optimizer/zend_optimizer_internal.h" #include "zend_API.h" +#include "zend_arena.h" #include "zend_constants.h" #include "zend_execute.h" #include "zend_vm.h" From 891acc03e274d2f618a2cb70d6cd48c61a4e3b55 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 12 Jan 2023 17:03:36 +0100 Subject: [PATCH 09/22] ext/opcache/ZendAccelerator.h: add missing include for "INIT_FUNC_ARGS" --- ext/opcache/ZendAccelerator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 568d8f4972419..e7685f2da0309 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -50,6 +50,7 @@ #include "zend_extensions.h" #include "zend_compile.h" +#include "zend_modules.h" #include "Optimizer/zend_optimizer.h" #include "zend_accelerator_hash.h" From 2f1fa76ad6752adf847a00ff4eda226b93a17cd7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 15:03:56 +0100 Subject: [PATCH 10/22] main: add missing includes --- main/main.c | 2 ++ main/streams/plain_wrapper.c | 3 +++ main/streams/streams.c | 3 +++ main/streams/xp_socket.c | 3 +++ 4 files changed, 11 insertions(+) diff --git a/main/main.c b/main/main.c index 8e09f4cd4c0b2..bb319310880f5 100644 --- a/main/main.c +++ b/main/main.c @@ -83,6 +83,8 @@ #include "rfc1867.h" #include "ext/standard/html_tables.h" + +#include #include "main_arginfo.h" /* }}} */ diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 3a6b2ccf28dcc..f8984148ce8bf 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -42,6 +42,9 @@ # include "win32/readdir.h" #endif +#include +#include + #define php_stream_fopen_from_fd_int(fd, mode, persistent_id) _php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_CC) #define php_stream_fopen_from_fd_int_rel(fd, mode, persistent_id) _php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_REL_CC) #define php_stream_fopen_from_file_int(file, mode) _php_stream_fopen_from_file_int((file), (mode) STREAMS_CC) diff --git a/main/streams/streams.c b/main/streams/streams.c index 9663f792bc393..3bbdf54879563 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -32,6 +32,9 @@ #include #include "php_streams_int.h" +#include +#include + /* {{{ resource and registration code */ /* Global wrapper hash, copied to FG(stream_wrappers) on registration of volatile wrapper */ static HashTable url_stream_wrappers_hash; diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 3a4beca9f077b..5ea41a420a8bd 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -25,8 +25,11 @@ #ifdef AF_UNIX #include +#include #endif +#include + #ifndef MSG_DONTWAIT # define MSG_DONTWAIT 0 #endif From 6029cdfb3dcc73511d97d86b356cc25d93bcf583 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 16:12:50 +0100 Subject: [PATCH 11/22] sapi/*: add missing includes --- sapi/cgi/cgi_main.c | 2 ++ sapi/cli/php_cli.c | 2 ++ sapi/cli/php_cli_server.c | 3 +++ sapi/fpm/fpm/fpm_main.c | 3 +++ sapi/phpdbg/phpdbg_io.c | 2 ++ 5 files changed, 12 insertions(+) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index b45468031fcd0..f4f37537e722a 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -95,6 +95,8 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; # include "valgrind/callgrind.h" #endif +#include + #ifndef PHP_WIN32 /* XXX this will need to change later when threaded fastcgi is implemented. shane */ struct sigaction act, old_term, old_quit, old_int; diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index cc9a26c41389d..c2c91574d5789 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -92,6 +92,8 @@ # include "openssl/applink.c" #endif +#include + PHPAPI extern char *php_ini_opened_path; PHPAPI extern char *php_ini_scanned_path; PHPAPI extern char *php_ini_scanned_files; diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index e59037ac2e8d3..946ad1de1c23a 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -106,6 +106,9 @@ #include "php_cli_process_title.h" #include "php_cli_process_title_arginfo.h" +#include +#include + #define OUTPUT_NOT_CHECKED -1 #define OUTPUT_IS_TTY 1 #define OUTPUT_NOT_TTY 0 diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 5f47dd8efcc22..87c7dc3ec045d 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -94,6 +94,9 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #include "fpm_log.h" #include "zlog.h" +#include +#include + /* XXX this will need to change later when threaded fastcgi is implemented. shane */ struct sigaction act, old_term, old_quit, old_int; diff --git a/sapi/phpdbg/phpdbg_io.c b/sapi/phpdbg/phpdbg_io.c index 14ae71a0ebd1b..6cf827c1be010 100644 --- a/sapi/phpdbg/phpdbg_io.c +++ b/sapi/phpdbg/phpdbg_io.c @@ -20,6 +20,8 @@ #include "phpdbg_io.h" +#include + ZEND_EXTERN_MODULE_GLOBALS(phpdbg) /* is easy to generalize ... but not needed for now */ From 6476bfd5e7a2783fbd31af9e40491d9f935bb72e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Jan 2023 17:56:48 +0100 Subject: [PATCH 12/22] Zend/zend_build.h: include zend_config.h Without this, the macros ZTS, ZEND_DEBUG and PHP_COMPILER_ID may be unavailable. --- Zend/zend_build.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Zend/zend_build.h b/Zend/zend_build.h index c604fb311a74e..f7f88cf46a53a 100644 --- a/Zend/zend_build.h +++ b/Zend/zend_build.h @@ -19,6 +19,12 @@ #ifndef ZEND_BUILD_H #define ZEND_BUILD_H +#ifdef PHP_WIN32 +#include "config.w32.h" +#else +#include "zend_config.h" +#endif + #define ZEND_TOSTR_(x) #x #define ZEND_TOSTR(x) ZEND_TOSTR_(x) From 99996a3d600ec1430c0029f7b0b34ee966382184 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Jan 2023 18:09:51 +0100 Subject: [PATCH 13/22] main/php_globals.h: add missing include for PHPAPI --- main/php_globals.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main/php_globals.h b/main/php_globals.h index d5e372cf2b408..44749ee565ccd 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -17,6 +17,7 @@ #ifndef PHP_GLOBALS_H #define PHP_GLOBALS_H +#include "php.h" #include "zend_globals.h" #include From 32fcd433bcb112520505e56a35c7f7f5878eb61f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Jan 2023 10:12:01 +0100 Subject: [PATCH 14/22] Zend/zend_multiply: add missing includes --- Zend/zend_multiply.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index a99e858bd7798..26c47e3d0aa21 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -17,11 +17,15 @@ +----------------------------------------------------------------------+ */ -#include "zend_portability.h" - #ifndef ZEND_MULTIPLY_H #define ZEND_MULTIPLY_H +#include "zend_long.h" +#include "zend_portability.h" +#include "zend.h" + +#include + #if PHP_HAVE_BUILTIN_SMULL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ From f2e71906c5dc4ea813651390a2bf73e5b63c1395 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 09:43:27 +0100 Subject: [PATCH 15/22] Zend/zend_long: include zend_config.h --- Zend/zend_long.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Zend/zend_long.h b/Zend/zend_long.h index 3796f1c5ababb..a85481946c49b 100644 --- a/Zend/zend_long.h +++ b/Zend/zend_long.h @@ -19,6 +19,12 @@ #ifndef ZEND_LONG_H #define ZEND_LONG_H +#ifdef PHP_WIN32 +#include "config.w32.h" +#else +#include "zend_config.h" +#endif + #include #include From 87b900428693e49755b9218d16273f65a1bc3956 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 21:55:37 +0100 Subject: [PATCH 16/22] Zend/Optimizer/dce: add missing include --- Zend/Optimizer/dce.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/Optimizer/dce.c b/Zend/Optimizer/dce.c index 15c9cf5e6e22a..4419126e76e9e 100644 --- a/Zend/Optimizer/dce.c +++ b/Zend/Optimizer/dce.c @@ -22,6 +22,7 @@ #include "Optimizer/zend_ssa.h" #include "Optimizer/zend_func_info.h" #include "Optimizer/zend_call_graph.h" +#include "zend_arena.h" #include "zend_bitset.h" /* This pass implements a form of dead code elimination (DCE). The algorithm optimistically assumes From acae83ff59c26f5c0627a907205d8fe704e73f7c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 22:18:07 +0100 Subject: [PATCH 17/22] Zend/Optimizer/sccp: add missing includes --- Zend/Optimizer/sccp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index b039501c921f9..ee755998b7d84 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -18,8 +18,11 @@ */ #include "zend_API.h" +#include "zend_arena.h" +#include "zend_multiply.h" #include "zend_exceptions.h" #include "zend_ini.h" +#include "zend_optimizer.h" #include "zend_type_info.h" #include "Optimizer/zend_optimizer_internal.h" #include "Optimizer/zend_call_graph.h" From ef046e8ad0215fdb0b9efee24b709c4ecfdd8aea Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 09:38:38 +0100 Subject: [PATCH 18/22] Zend/zend_types: add missing include --- Zend/zend_types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 3d900226e54e5..cb611b644c6c7 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -28,6 +28,7 @@ #include "zend_refcounted.h" #include "zend_result.h" #include "zend_type_code.h" +#include "zend_type_info.h" #include #include From 2cc4811ecdf485cdcd5908386d35b19a12959e92 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Jan 2023 10:30:57 +0100 Subject: [PATCH 19/22] Zend/zend_inheritance: add missing include --- Zend/zend_inheritance.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 61b1e06e7cb65..9a72c47510f59 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -18,6 +18,7 @@ */ #include "zend.h" +#include "zend_arena.h" #include "zend_API.h" #include "zend_compile.h" #include "zend_execute.h" From 84f3a53893d89f7d01322bddb583509516d028bc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 16 Jan 2023 12:18:26 +0100 Subject: [PATCH 20/22] ext/opcache/zend_accelerator_hash: add missing includes --- ext/opcache/zend_accelerator_hash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c index 2fd3dfb5ed56e..322d8ad47ebc6 100644 --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@ -21,8 +21,10 @@ #include "ZendAccelerator.h" #include "zend_accelerator_hash.h" -#include "zend_hash.h" +#include "zend_accelerator_debug.h" #include "zend_shared_alloc.h" +#include "ZendAccelerator.h" +#include "Zend/zend_string.h" /* Generated on an Octa-ALPHA 300MHz CPU & 2.5GB RAM monster */ static const uint32_t prime_numbers[] = From cc80ba3daabec8730b20b2186ce4bcecd5c950e4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 16 Jan 2023 12:22:50 +0100 Subject: [PATCH 21/22] ext/opcache/shared_alloc_mmap: add missing includes for MAXPATHLEN, getpid() --- ext/opcache/shared_alloc_mmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/opcache/shared_alloc_mmap.c b/ext/opcache/shared_alloc_mmap.c index 1414ef96149d0..76190511f25bf 100644 --- a/ext/opcache/shared_alloc_mmap.c +++ b/ext/opcache/shared_alloc_mmap.c @@ -23,6 +23,10 @@ #ifdef USE_MMAP +#if defined(__linux__) +# include "ZendAccelerator.h" +#endif + #include #include #include @@ -38,6 +42,10 @@ #include #endif +#if defined(__FreeBSD__) || (defined(HAVE_PROCCTL) && defined(PROC_WXMAP_CTL)) +# include +#endif + #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) # define MAP_ANONYMOUS MAP_ANON #endif From 6df70c24cbe7a8656a7de14b64b745535021841a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 20 Jan 2023 11:54:36 +0100 Subject: [PATCH 22/22] ext/opcache/shared_alloc_win32: add missing include --- ext/opcache/shared_alloc_win32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/opcache/shared_alloc_win32.c b/ext/opcache/shared_alloc_win32.c index 893fe98ec189c..d77e50d034472 100644 --- a/ext/opcache/shared_alloc_win32.c +++ b/ext/opcache/shared_alloc_win32.c @@ -23,6 +23,7 @@ #include "ZendAccelerator.h" #include "zend_shared_alloc.h" #include "zend_accelerator_util_funcs.h" +#include "zend_accelerator_debug.h" #include "zend_execute.h" #include "zend_system_id.h" #include "SAPI.h"