Skip to content

#include cleanup 2 #10220

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 14 commits into from
Jan 10, 2023
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
6 changes: 6 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ PHP 8.3 INTERNALS UPGRADE NOTES
EG(stack_base).
* EG(opline_before_exception) may now be null if the VM throws an exception
before executing any opline.
* Many C header files have been cleaned up and include dependencies
have been reduced. Many headers which used to be always included by
Zend headers (e.g. "errno.h") are no longer implied, and this may
break the build of third-party extensions which relied on this
implementation detail. Those extensions may need to add the missing
#include lines.

========================
2. Build system changes
Expand Down
1 change: 1 addition & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "zend_observer.h"
#include "zend_fibers.h"
#include "zend_call_stack.h"
#include "zend_strtod.h"
#include "Optimizer/zend_optimizer.h"

static size_t global_map_ptr_last = 0;
Expand Down
26 changes: 10 additions & 16 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,25 @@

#define ZEND_INTENSIVE_DEBUGGING 0

#include <stdio.h>
#include <signal.h>

#include "zend.h"
#include "zend_compile.h"
#include "zend_execute.h"
#include "zend_API.h"
#include "zend_ptr_stack.h"
#include "zend_API.h" // for ZEND_FUNCTION()
#include "zend_arena.h"
#include "zend_constants.h"
#include "zend_extensions.h"
#include "zend_ini.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "zend_closures.h"
#include "zend_generators.h"
#include "zend_vm.h"
#include "zend_dtrace.h"
#include "zend_inheritance.h"
#include "zend_type_info.h"
#include "zend_generators.h" // for zend_ce_generator
#include "zend_inheritance.h" // for zend_do_link_class()
#include "zend_smart_str.h"
#include "zend_observer.h"
#include "zend_system_id.h"
#include "zend_call_stack.h"
#include "Optimizer/zend_func_info.h"

/* Virtual current working directory support */
#include "zend_virtual_cwd.h"

#include <stdio.h>
#include <signal.h>

#ifdef HAVE_GCC_GLOBAL_REGS
# if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
# define ZEND_VM_FP_GLOBAL_REG "%esi"
Expand Down Expand Up @@ -5283,6 +5274,9 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint
/* This callback disables optimization of "vm_stack_data" variable in VM */
ZEND_API void (ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data) = NULL;

#include "zend_fibers.h" // needed by zend_vm_execute.h
#include "zend_interfaces.h" // needed by zend_vm_execute.h
#include "zend_objects.h" // needed by zend_vm_execute.h
#include "zend_vm_execute.h"

ZEND_API zend_result zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler)
Expand Down
14 changes: 10 additions & 4 deletions Zend/zend_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
#ifndef ZEND_EXECUTE_H
#define ZEND_EXECUTE_H

#include "zend_compile.h"
#include "zend_hash.h"
#include "zend_operators.h"
#include "zend_variables.h"
#include "zend_compile.h" // for zend_op_array
#include "zend_list.h" // for zend_rsrc_list_get_rsrc_type()
#include "zend_portability.h" // for BEGIN_EXTERN_C
#include "zend_types.h" // for zend_execute_data

#if ZEND_DEBUG
#include "zend_globals.h" // for struct _zend_executor_globals
#include "zend_globals_macros.h" // for EG()
#endif

BEGIN_EXTERN_C()
struct _zend_fcall_info;
Expand Down Expand Up @@ -182,6 +187,7 @@ ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_with_ctx(zval *pp, zend_class_entry *scope, zend_ast_evaluate_ctx *ctx);

/* dedicated Zend executor functions - do not use! */
typedef struct _zend_vm_stack *zend_vm_stack;
struct _zend_vm_stack {
zval *top;
zval *end;
Expand Down
16 changes: 4 additions & 12 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,18 @@
+----------------------------------------------------------------------+
*/

#include <stdio.h>
#include <signal.h>

#include "zend.h"
#include "zend_compile.h"
#include "zend_execute.h"
#include "zend_API.h"
#include "zend_stack.h"
#include "zend_constants.h"
#include "zend_extensions.h"
#include "zend_exceptions.h"
#include "zend_closures.h"
#include "zend_generators.h"
#include "zend_vm.h"
#include "zend_float.h"
#include "zend_fibers.h"
#include "zend_weakrefs.h"
#include "zend_inheritance.h"
#include "zend_observer.h"
#include "zend_call_stack.h"

#include <stdio.h>
#include <signal.h>

#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
Expand Down
5 changes: 5 additions & 0 deletions Zend/zend_fibers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
+----------------------------------------------------------------------+
*/

#include "zend_fibers.h"
#include "zend_objects.h" // for zend_object_std_init()
#include "zend.h"
#include "zend_API.h"
#include "zend_ini.h"
Expand All @@ -42,6 +44,9 @@
# include <sys/mman.h>
# include <limits.h>

# include <errno.h>
# include <string.h> // for strerror()

# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
# define MAP_ANONYMOUS MAP_ANON
# endif
Expand Down
8 changes: 6 additions & 2 deletions Zend/zend_fibers.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
#ifndef ZEND_FIBERS_H
#define ZEND_FIBERS_H

#include "zend_API.h"
#include "zend_types.h"
#include "zend_API.h" // for struct zend_fcall_info
#include "zend_portability.h" // for BEGIN_EXTERN_C

#include <stddef.h>

#define ZEND_FIBER_GUARD_PAGES 1

#define ZEND_FIBER_DEFAULT_C_STACK_SIZE (4096 * (((sizeof(void *)) < 8) ? 256 : 512))
#define ZEND_FIBER_VM_STACK_SIZE (1024 * sizeof(zval))

typedef struct _zend_fiber_context zend_fiber_context;

BEGIN_EXTERN_C()

typedef enum {
Expand Down
4 changes: 3 additions & 1 deletion Zend/zend_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
+----------------------------------------------------------------------+
*/

#include "zend_ini.h"
#include "zend.h"
#include "zend_sort.h"
#include "zend_API.h"
#include "zend_ini.h"
#include "zend_alloc.h"
#include "zend_operators.h"
#include "zend_strtod.h"
#include "zend_modules.h"
#include "zend_smart_str.h"

#include <ctype.h>
#include <errno.h>

static HashTable *registered_zend_ini_directives;

Expand Down
12 changes: 12 additions & 0 deletions Zend/zend_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@
#ifndef ZEND_INI_H
#define ZEND_INI_H

#include "zend_portability.h" // for BEGIN_EXTERN_C
#include "zend_types.h" // for zend_result

#include <stdint.h>

#define ZEND_INI_USER (1<<0)
#define ZEND_INI_PERDIR (1<<1)
#define ZEND_INI_SYSTEM (1<<2)

#define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)

// forward declarations
typedef struct _zend_file_handle zend_file_handle;
typedef struct _zend_ini_entry zend_ini_entry;
typedef struct _zend_module_entry zend_module_entry;
typedef struct _zend_string zend_string;
typedef struct _zend_array HashTable;

#define ZEND_INI_MH(name) int name(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage)
#define ZEND_INI_DISP(name) ZEND_COLD void name(zend_ini_entry *ini_entry, int type)

Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_multibyte.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
+----------------------------------------------------------------------+
*/

#include "zend.h"
#include "zend_compile.h"
#include "zend_operators.h"
#include "zend_multibyte.h"
#include "zend_alloc.h"
#include "zend_globals.h" // for struct _zend_compiler_globals
#include "zend_globals_macros.h" // for LANG_SCNG()
#include "zend_ini.h"

static const zend_encoding *dummy_encoding_fetcher(const char *encoding_name)
Expand Down
6 changes: 6 additions & 0 deletions Zend/zend_multibyte.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#ifndef ZEND_MULTIBYTE_H
#define ZEND_MULTIBYTE_H

#include "zend_portability.h" // for BEGIN_EXTERN_C
#include "zend_types.h" // for zend_result

#include <stdbool.h>
#include <stddef.h> // for size_t

typedef struct _zend_encoding zend_encoding;

typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
+----------------------------------------------------------------------+
*/

#include "zend_object_handlers.h"
#include "zend.h"
#include "zend_globals.h"
#include "zend_variables.h"
#include "zend_API.h"
#include "zend_objects.h"
#include "zend_objects_API.h"
#include "zend_object_handlers.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"
#include "zend_closures.h"
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_object_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef ZEND_OBJECT_HANDLERS_H
#define ZEND_OBJECT_HANDLERS_H

#include "zend_types.h"

struct _zend_property_info;

#define ZEND_WRONG_PROPERTY_INFO \
Expand Down
8 changes: 5 additions & 3 deletions Zend/zend_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
+----------------------------------------------------------------------+
*/

#include <ctype.h>

#include "zend.h"
#include "zend_operators.h"
#include "zend.h"
#include "zend_variables.h"
#include "zend_objects.h" // for zend_objects_new()
#include "zend_globals.h"
#include "zend_multiply.h" // for ZEND_SIGNED_MULTIPLY_LONG()
#include "zend_list.h"
#include "zend_API.h"
#include "zend_strtod.h"
#include "zend_exceptions.h"
#include "zend_closures.h"

#include <ctype.h>

#include <locale.h>
#ifdef HAVE_LANGINFO_H
# include <langinfo.h>
Expand Down
13 changes: 6 additions & 7 deletions Zend/zend_operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H

#include <errno.h>
#include "zend_hash.h" // for zend_hash_num_elements()
#include "zend_object_handlers.h" // for struct _zend_object_handlers
#include "zend_portability.h" // for BEGIN_EXTERN_
#include "zend_types.h" // for zend_result
#include "zend_string.h" // for zend_string_copy()

#include <math.h>
#include <assert.h>
#include <stddef.h>

#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif

#include "zend_portability.h"
#include "zend_strtod.h"
#include "zend_multiply.h"
#include "zend_object_handlers.h"

#define LONG_SIGN_MASK ZEND_LONG_MIN

BEGIN_EXTERN_C()
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_ptr_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
+----------------------------------------------------------------------+
*/

#include "zend.h"
#include "zend_ptr_stack.h"

#include <stdarg.h>

ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, bool persistent)
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_ptr_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#ifndef ZEND_PTR_STACK_H
#define ZEND_PTR_STACK_H

#include "zend_alloc.h" // for safe_perealloc()
#include "zend_portability.h" // for BEGIN_EXTERN_C

typedef struct _zend_ptr_stack {
int top, max;
void **elements;
Expand Down
9 changes: 6 additions & 3 deletions Zend/zend_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <string.h>

#include "zend.h"
#include "zend_globals.h"
#include "zend_signal.h"
#include "zend_alloc.h"
#include "zend.h" // for zend_output_debug_string(), zend_error(), ...

#include <errno.h>
#include <signal.h>
#include <string.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
Expand Down
9 changes: 9 additions & 0 deletions Zend/zend_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@
#ifndef ZEND_SIGNAL_H
#define ZEND_SIGNAL_H

#ifdef PHP_WIN32
#include "config.w32.h"
#else
#include "php_config.h" // for ZEND_SIGNALS
#endif

#ifdef ZEND_SIGNALS

#include "zend_portability.h" // for BEGIN_EXTERN_C

#include <signal.h>
#include <stdbool.h>

#ifndef NSIG
#define NSIG 65
Expand Down
4 changes: 3 additions & 1 deletion Zend/zend_smart_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
+----------------------------------------------------------------------+
*/

#include <zend.h>
#include "zend_smart_str.h"
#include "zend_smart_string.h"
#include "zend_globals_macros.h" // for EG()
#include "zend_globals.h" // struct _zend_executor_globals
#include "zend_strtod.h" // for zend_gcvt()

#define SMART_STR_OVERHEAD (ZEND_MM_OVERHEAD + _ZSTR_HEADER_SIZE + 1)
#define SMART_STR_START_SIZE 256
Expand Down
Loading