Skip to content

Commit d6e9504

Browse files
MaxKellermannGirgias
authored andcommitted
Zend/zend_types.h: move zend_rc_debug to zend_rc_debug.h
`zend_rc_debug` is not a type and does not really belong in `zend_types.h`; this allows using `ZEND_RC_MOD_CHECK()` without including the huge `zend_types.h` header and allows decoupling circular header dependencies.
1 parent 9108a32 commit d6e9504

File tree

11 files changed

+82
-22
lines changed

11 files changed

+82
-22
lines changed

Zend/zend.c

-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ void (*zend_on_timeout)(int seconds);
9494
static void (*zend_message_dispatcher_p)(zend_long message, const void *data);
9595
static zval *(*zend_get_configuration_directive_p)(zend_string *name);
9696

97-
#if ZEND_RC_DEBUG
98-
ZEND_API bool zend_rc_debug = 0;
99-
#endif
100-
10197
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
10298
{
10399
if (!new_value) {

Zend/zend_API.c

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "zend_ini.h"
3333
#include "zend_enum.h"
3434
#include "zend_observer.h"
35+
#include "zend_rc_debug.h"
3536

3637
#include <stdarg.h>
3738

Zend/zend_rc_debug.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Zend Engine |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 2.00 of the Zend license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.zend.com/license/2_00.txt. |
11+
| If you did not receive a copy of the Zend license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| [email protected] so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#include "zend_rc_debug.h"
18+
19+
#if ZEND_RC_DEBUG
20+
ZEND_API bool zend_rc_debug = false;
21+
#endif

Zend/zend_rc_debug.h

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Zend Engine |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 2.00 of the Zend license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.zend.com/license/2_00.txt. |
11+
| If you did not receive a copy of the Zend license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| [email protected] so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#ifndef ZEND_RC_DEBUG_H
18+
#define ZEND_RC_DEBUG_H
19+
20+
#ifndef ZEND_RC_DEBUG
21+
# define ZEND_RC_DEBUG 0
22+
#endif
23+
24+
#if ZEND_RC_DEBUG
25+
26+
#ifdef PHP_WIN32
27+
# include "zend_config.w32.h"
28+
#else
29+
# include "zend_config.h"
30+
#endif
31+
32+
#include <stdbool.h>
33+
#include <stdint.h>
34+
35+
extern ZEND_API bool zend_rc_debug;
36+
37+
/* The GC_PERSISTENT flag is reused for IS_OBJ_WEAKLY_REFERENCED on objects.
38+
* Skip checks for OBJECT/NULL type to avoid interpreting the flag incorrectly. */
39+
# define ZEND_RC_MOD_CHECK(p) do { \
40+
if (zend_rc_debug) { \
41+
uint8_t type = zval_gc_type((p)->u.type_info); \
42+
if (type != IS_OBJECT && type != IS_NULL) { \
43+
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
44+
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
45+
} \
46+
} \
47+
} while (0)
48+
#else
49+
# define ZEND_RC_MOD_CHECK(p) \
50+
do { } while (0)
51+
#endif
52+
53+
#endif /* ZEND_RC_DEBUG_H */

Zend/zend_string.c

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "zend.h"
2020
#include "zend_globals.h"
21+
#include "zend_rc_debug.h"
2122

2223
#ifdef HAVE_VALGRIND
2324
# include "valgrind/callgrind.h"

Zend/zend_types.h

+1-18
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "zend_portability.h"
2626
#include "zend_long.h"
27+
#include "zend_rc_debug.h"
2728
#include "zend_result.h"
2829

2930
#include <stdbool.h>
@@ -1161,29 +1162,11 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
11611162
#define Z_TRY_ADDREF(z) Z_TRY_ADDREF_P(&(z))
11621163
#define Z_TRY_DELREF(z) Z_TRY_DELREF_P(&(z))
11631164

1164-
#ifndef ZEND_RC_DEBUG
1165-
# define ZEND_RC_DEBUG 0
1166-
#endif
1167-
11681165
#if ZEND_RC_DEBUG
1169-
extern ZEND_API bool zend_rc_debug;
1170-
/* The GC_PERSISTENT flag is reused for IS_OBJ_WEAKLY_REFERENCED on objects.
1171-
* Skip checks for OBJECT/NULL type to avoid interpreting the flag incorrectly. */
1172-
# define ZEND_RC_MOD_CHECK(p) do { \
1173-
if (zend_rc_debug) { \
1174-
uint8_t type = zval_gc_type((p)->u.type_info); \
1175-
if (type != IS_OBJECT && type != IS_NULL) { \
1176-
ZEND_ASSERT(!(zval_gc_flags((p)->u.type_info) & GC_IMMUTABLE)); \
1177-
ZEND_ASSERT((zval_gc_flags((p)->u.type_info) & (GC_PERSISTENT|GC_PERSISTENT_LOCAL)) != GC_PERSISTENT); \
1178-
} \
1179-
} \
1180-
} while (0)
11811166
# define GC_MAKE_PERSISTENT_LOCAL(p) do { \
11821167
GC_ADD_FLAGS(p, GC_PERSISTENT_LOCAL); \
11831168
} while (0)
11841169
#else
1185-
# define ZEND_RC_MOD_CHECK(p) \
1186-
do { } while (0)
11871170
# define GC_MAKE_PERSISTENT_LOCAL(p) \
11881171
do { } while (0)
11891172
#endif

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,7 @@ PHP_ADD_SOURCES(Zend, \
17221722
zend_virtual_cwd.c zend_ast.c zend_objects.c zend_object_handlers.c zend_objects_API.c \
17231723
zend_default_classes.c zend_inheritance.c zend_smart_str.c zend_cpuinfo.c zend_gdb.c \
17241724
zend_observer.c zend_system_id.c zend_enum.c zend_fibers.c zend_atomic.c \
1725+
zend_rc_debug.c \
17251726
Optimizer/zend_optimizer.c \
17261727
Optimizer/pass1.c \
17271728
Optimizer/pass3.c \

main/main.c

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include "zend_ini.h"
7272
#include "zend_dtrace.h"
7373
#include "zend_observer.h"
74+
#include "zend_rc_debug.h"
7475
#include "zend_system_id.h"
7576

7677
#include "php_content_types.h"

main/php.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include "php_version.h"
3131
#include "zend.h"
32+
#include "zend_rc_debug.h"
3233
#include "zend_sort.h"
3334
#include "php_compat.h"
3435

main/php_ini.c

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ext/standard/dl.h"
2323
#include "zend_extensions.h"
2424
#include "zend_highlight.h"
25+
#include "zend_rc_debug.h"
2526
#include "SAPI.h"
2627
#include "php_main.h"
2728
#include "php_scandir.h"

sapi/fpm/fpm/fpm_main.c

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "php.h"
2828
#include "zend_ini_scanner.h"
2929
#include "zend_globals.h"
30+
#include "zend_rc_debug.h"
3031
#include "zend_stream.h"
3132

3233
#include "SAPI.h"

0 commit comments

Comments
 (0)