Skip to content

Commit e649783

Browse files
Merge branch 'php:master' into master
2 parents 62d6514 + 4427b2e commit e649783

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+298
-89
lines changed

UPGRADING.INTERNALS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ PHP 8.3 INTERNALS UPGRADE NOTES
2020
EG(stack_base).
2121
* EG(opline_before_exception) may now be null if the VM throws an exception
2222
before executing any opline.
23+
* Many C header files have been cleaned up and include dependencies
24+
have been reduced. Many headers which used to be always included by
25+
Zend headers (e.g. "errno.h") are no longer implied, and this may
26+
break the build of third-party extensions which relied on this
27+
implementation detail. Those extensions may need to add the missing
28+
#include lines.
2329

2430
========================
2531
2. Build system changes

Zend/zend.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "zend_observer.h"
3737
#include "zend_fibers.h"
3838
#include "zend_call_stack.h"
39+
#include "zend_strtod.h"
3940
#include "Optimizer/zend_optimizer.h"
4041

4142
static size_t global_map_ptr_last = 0;

Zend/zend_execute.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,25 @@
2020

2121
#define ZEND_INTENSIVE_DEBUGGING 0
2222

23-
#include <stdio.h>
24-
#include <signal.h>
25-
26-
#include "zend.h"
27-
#include "zend_compile.h"
2823
#include "zend_execute.h"
29-
#include "zend_API.h"
30-
#include "zend_ptr_stack.h"
24+
#include "zend_API.h" // for ZEND_FUNCTION()
25+
#include "zend_arena.h"
3126
#include "zend_constants.h"
3227
#include "zend_extensions.h"
3328
#include "zend_ini.h"
3429
#include "zend_exceptions.h"
35-
#include "zend_interfaces.h"
3630
#include "zend_closures.h"
37-
#include "zend_generators.h"
38-
#include "zend_vm.h"
39-
#include "zend_dtrace.h"
40-
#include "zend_inheritance.h"
41-
#include "zend_type_info.h"
31+
#include "zend_generators.h" // for zend_ce_generator
32+
#include "zend_inheritance.h" // for zend_do_link_class()
4233
#include "zend_smart_str.h"
4334
#include "zend_observer.h"
44-
#include "zend_system_id.h"
45-
#include "zend_call_stack.h"
46-
#include "Optimizer/zend_func_info.h"
4735

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

39+
#include <stdio.h>
40+
#include <signal.h>
41+
5142
#ifdef HAVE_GCC_GLOBAL_REGS
5243
# if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
5344
# define ZEND_VM_FP_GLOBAL_REG "%esi"
@@ -5283,6 +5274,9 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint
52835274
/* This callback disables optimization of "vm_stack_data" variable in VM */
52845275
ZEND_API void (ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data) = NULL;
52855276

5277+
#include "zend_fibers.h" // needed by zend_vm_execute.h
5278+
#include "zend_interfaces.h" // needed by zend_vm_execute.h
5279+
#include "zend_objects.h" // needed by zend_vm_execute.h
52865280
#include "zend_vm_execute.h"
52875281

52885282
ZEND_API zend_result zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler)

Zend/zend_execute.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
#ifndef ZEND_EXECUTE_H
2222
#define ZEND_EXECUTE_H
2323

24-
#include "zend_compile.h"
25-
#include "zend_hash.h"
26-
#include "zend_operators.h"
27-
#include "zend_variables.h"
24+
#include "zend_compile.h" // for zend_op_array
25+
#include "zend_list.h" // for zend_rsrc_list_get_rsrc_type()
26+
#include "zend_portability.h" // for BEGIN_EXTERN_C
27+
#include "zend_types.h" // for zend_execute_data
28+
29+
#if ZEND_DEBUG
30+
#include "zend_globals.h" // for struct _zend_executor_globals
31+
#include "zend_globals_macros.h" // for EG()
32+
#endif
2833

2934
BEGIN_EXTERN_C()
3035
struct _zend_fcall_info;
@@ -182,6 +187,7 @@ ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_
182187
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_with_ctx(zval *pp, zend_class_entry *scope, zend_ast_evaluate_ctx *ctx);
183188

184189
/* dedicated Zend executor functions - do not use! */
190+
typedef struct _zend_vm_stack *zend_vm_stack;
185191
struct _zend_vm_stack {
186192
zval *top;
187193
zval *end;

Zend/zend_execute_API.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,18 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21-
#include <stdio.h>
22-
#include <signal.h>
23-
24-
#include "zend.h"
25-
#include "zend_compile.h"
26-
#include "zend_execute.h"
2721
#include "zend_API.h"
28-
#include "zend_stack.h"
2922
#include "zend_constants.h"
3023
#include "zend_extensions.h"
3124
#include "zend_exceptions.h"
3225
#include "zend_closures.h"
33-
#include "zend_generators.h"
34-
#include "zend_vm.h"
35-
#include "zend_float.h"
3626
#include "zend_fibers.h"
3727
#include "zend_weakrefs.h"
38-
#include "zend_inheritance.h"
3928
#include "zend_observer.h"
40-
#include "zend_call_stack.h"
29+
30+
#include <stdio.h>
31+
#include <signal.h>
32+
4133
#ifdef HAVE_SYS_TIME_H
4234
#include <sys/time.h>
4335
#endif

Zend/zend_fibers.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
+----------------------------------------------------------------------+
1818
*/
1919

20+
#include "zend_fibers.h"
21+
#include "zend_objects.h" // for zend_object_std_init()
2022
#include "zend.h"
2123
#include "zend_API.h"
2224
#include "zend_ini.h"
@@ -42,6 +44,9 @@
4244
# include <sys/mman.h>
4345
# include <limits.h>
4446

47+
# include <errno.h>
48+
# include <string.h> // for strerror()
49+
4550
# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
4651
# define MAP_ANONYMOUS MAP_ANON
4752
# endif

Zend/zend_fibers.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
#ifndef ZEND_FIBERS_H
2121
#define ZEND_FIBERS_H
2222

23-
#include "zend_API.h"
24-
#include "zend_types.h"
23+
#include "zend_API.h" // for struct zend_fcall_info
24+
#include "zend_portability.h" // for BEGIN_EXTERN_C
25+
26+
#include <stddef.h>
2527

2628
#define ZEND_FIBER_GUARD_PAGES 1
2729

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

33+
typedef struct _zend_fiber_context zend_fiber_context;
34+
3135
BEGIN_EXTERN_C()
3236

3337
typedef enum {

Zend/zend_ini.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
+----------------------------------------------------------------------+
1717
*/
1818

19+
#include "zend_ini.h"
1920
#include "zend.h"
2021
#include "zend_sort.h"
2122
#include "zend_API.h"
22-
#include "zend_ini.h"
2323
#include "zend_alloc.h"
2424
#include "zend_operators.h"
2525
#include "zend_strtod.h"
2626
#include "zend_modules.h"
2727
#include "zend_smart_str.h"
28+
2829
#include <ctype.h>
30+
#include <errno.h>
2931

3032
static HashTable *registered_zend_ini_directives;
3133

Zend/zend_ini.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,24 @@
1919
#ifndef ZEND_INI_H
2020
#define ZEND_INI_H
2121

22+
#include "zend_portability.h" // for BEGIN_EXTERN_C
23+
#include "zend_types.h" // for zend_result
24+
25+
#include <stdint.h>
26+
2227
#define ZEND_INI_USER (1<<0)
2328
#define ZEND_INI_PERDIR (1<<1)
2429
#define ZEND_INI_SYSTEM (1<<2)
2530

2631
#define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)
2732

33+
// forward declarations
34+
typedef struct _zend_file_handle zend_file_handle;
35+
typedef struct _zend_ini_entry zend_ini_entry;
36+
typedef struct _zend_module_entry zend_module_entry;
37+
typedef struct _zend_string zend_string;
38+
typedef struct _zend_array HashTable;
39+
2840
#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)
2941
#define ZEND_INI_DISP(name) ZEND_COLD void name(zend_ini_entry *ini_entry, int type)
3042

Zend/zend_multibyte.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
+----------------------------------------------------------------------+
1818
*/
1919

20-
#include "zend.h"
21-
#include "zend_compile.h"
22-
#include "zend_operators.h"
2320
#include "zend_multibyte.h"
21+
#include "zend_alloc.h"
22+
#include "zend_globals.h" // for struct _zend_compiler_globals
23+
#include "zend_globals_macros.h" // for LANG_SCNG()
2424
#include "zend_ini.h"
2525

2626
static const zend_encoding *dummy_encoding_fetcher(const char *encoding_name)

Zend/zend_multibyte.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#ifndef ZEND_MULTIBYTE_H
2121
#define ZEND_MULTIBYTE_H
2222

23+
#include "zend_portability.h" // for BEGIN_EXTERN_C
24+
#include "zend_types.h" // for zend_result
25+
26+
#include <stdbool.h>
27+
#include <stddef.h> // for size_t
28+
2329
typedef struct _zend_encoding zend_encoding;
2430

2531
typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length);

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21+
#include "zend_object_handlers.h"
2122
#include "zend.h"
2223
#include "zend_globals.h"
2324
#include "zend_variables.h"
2425
#include "zend_API.h"
2526
#include "zend_objects.h"
2627
#include "zend_objects_API.h"
27-
#include "zend_object_handlers.h"
2828
#include "zend_interfaces.h"
2929
#include "zend_exceptions.h"
3030
#include "zend_closures.h"

Zend/zend_object_handlers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#ifndef ZEND_OBJECT_HANDLERS_H
2121
#define ZEND_OBJECT_HANDLERS_H
2222

23+
#include "zend_types.h"
24+
2325
struct _zend_property_info;
2426

2527
#define ZEND_WRONG_PROPERTY_INFO \

Zend/zend_operators.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21-
#include <ctype.h>
22-
23-
#include "zend.h"
2421
#include "zend_operators.h"
22+
#include "zend.h"
2523
#include "zend_variables.h"
24+
#include "zend_objects.h" // for zend_objects_new()
2625
#include "zend_globals.h"
26+
#include "zend_multiply.h" // for ZEND_SIGNED_MULTIPLY_LONG()
2727
#include "zend_list.h"
2828
#include "zend_API.h"
2929
#include "zend_strtod.h"
3030
#include "zend_exceptions.h"
3131
#include "zend_closures.h"
3232

33+
#include <ctype.h>
34+
3335
#include <locale.h>
3436
#ifdef HAVE_LANGINFO_H
3537
# include <langinfo.h>

Zend/zend_operators.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,19 @@
2121
#ifndef ZEND_OPERATORS_H
2222
#define ZEND_OPERATORS_H
2323

24-
#include <errno.h>
24+
#include "zend_hash.h" // for zend_hash_num_elements()
25+
#include "zend_object_handlers.h" // for struct _zend_object_handlers
26+
#include "zend_portability.h" // for BEGIN_EXTERN_
27+
#include "zend_types.h" // for zend_result
28+
#include "zend_string.h" // for zend_string_copy()
29+
2530
#include <math.h>
26-
#include <assert.h>
2731
#include <stddef.h>
2832

2933
#ifdef HAVE_IEEEFP_H
3034
#include <ieeefp.h>
3135
#endif
3236

33-
#include "zend_portability.h"
34-
#include "zend_strtod.h"
35-
#include "zend_multiply.h"
36-
#include "zend_object_handlers.h"
37-
3837
#define LONG_SIGN_MASK ZEND_LONG_MIN
3938

4039
BEGIN_EXTERN_C()

Zend/zend_portability.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ extern "C++" {
701701
# define ZEND_VOIDP(ptr) (ptr)
702702
#endif
703703

704-
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 9000
704+
#if __has_attribute(__indirect_return__)
705705
# define ZEND_INDIRECT_RETURN __attribute__((__indirect_return__))
706706
#else
707707
# define ZEND_INDIRECT_RETURN

Zend/zend_ptr_stack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
+----------------------------------------------------------------------+
1818
*/
1919

20-
#include "zend.h"
2120
#include "zend_ptr_stack.h"
21+
2222
#include <stdarg.h>
2323

2424
ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, bool persistent)

Zend/zend_ptr_stack.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#ifndef ZEND_PTR_STACK_H
2121
#define ZEND_PTR_STACK_H
2222

23+
#include "zend_alloc.h" // for safe_perealloc()
24+
#include "zend_portability.h" // for BEGIN_EXTERN_C
25+
2326
typedef struct _zend_ptr_stack {
2427
int top, max;
2528
void **elements;

Zend/zend_signal.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
#ifndef _GNU_SOURCE
2929
# define _GNU_SOURCE
3030
#endif
31-
#include <string.h>
3231

33-
#include "zend.h"
34-
#include "zend_globals.h"
32+
#include "zend_signal.h"
33+
#include "zend_alloc.h"
34+
#include "zend.h" // for zend_output_debug_string(), zend_error(), ...
35+
36+
#include <errno.h>
3537
#include <signal.h>
38+
#include <string.h>
3639

3740
#ifdef HAVE_UNISTD_H
3841
#include <unistd.h>

Zend/zend_signal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@
2121
#ifndef ZEND_SIGNAL_H
2222
#define ZEND_SIGNAL_H
2323

24+
#ifdef PHP_WIN32
25+
#include "config.w32.h"
26+
#else
27+
#include "php_config.h" // for ZEND_SIGNALS
28+
#endif
29+
2430
#ifdef ZEND_SIGNALS
2531

32+
#include "zend_portability.h" // for BEGIN_EXTERN_C
33+
2634
#include <signal.h>
35+
#include <stdbool.h>
2736

2837
#ifndef NSIG
2938
#define NSIG 65

Zend/zend_smart_str.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#include <zend.h>
1817
#include "zend_smart_str.h"
1918
#include "zend_smart_string.h"
19+
#include "zend_globals_macros.h" // for EG()
20+
#include "zend_globals.h" // struct _zend_executor_globals
21+
#include "zend_strtod.h" // for zend_gcvt()
2022

2123
#define SMART_STR_OVERHEAD (ZEND_MM_OVERHEAD + _ZSTR_HEADER_SIZE + 1)
2224
#define SMART_STR_START_SIZE 256

0 commit comments

Comments
 (0)