Skip to content

Commit be02cd2

Browse files
tpuntnikic
authored andcommitted
Fix ZTS mode
This requires shifting str_ member variable out of the Zend globals (which is stored in TLS), and into a true global structure instead
1 parent 783fbb9 commit be02cd2

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

ast.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ typedef struct _ast_flag_info {
6666

6767
ZEND_DECLARE_MODULE_GLOBALS(ast)
6868

69+
ast_str_globals str_globals;
70+
6971
static zend_class_entry *ast_node_ce;
7072
static zend_class_entry *ast_decl_ce;
7173
static zend_class_entry *ast_metadata_ce;
@@ -953,12 +955,12 @@ static void ast_build_metadata(zval *result) {
953955
object_init_ex(&info_zv, ast_metadata_ce);
954956

955957
/* kind */
956-
ast_update_property_long(&info_zv, AST_G(str_kind), kind, NULL);
958+
ast_update_property_long(&info_zv, AST_STR(str_kind), kind, NULL);
957959

958960
/* name */
959961
ZVAL_STRING(&tmp_zv, ast_kind_to_name(kind));
960962
Z_TRY_DELREF(tmp_zv);
961-
ast_update_property(&info_zv, AST_G(str_name), &tmp_zv, NULL);
963+
ast_update_property(&info_zv, AST_STR(str_name), &tmp_zv, NULL);
962964

963965
/* flags */
964966
array_init(&tmp_zv);
@@ -969,11 +971,11 @@ static void ast_build_metadata(zval *result) {
969971
}
970972
}
971973
Z_TRY_DELREF(tmp_zv);
972-
ast_update_property(&info_zv, AST_G(str_flags), &tmp_zv, NULL);
974+
ast_update_property(&info_zv, AST_STR(str_flags), &tmp_zv, NULL);
973975

974976
/* flagsCombinable */
975977
ZVAL_BOOL(&tmp_zv, flag_info && flag_info->combinable);
976-
ast_update_property(&info_zv, AST_G(str_flagsCombinable), &tmp_zv, NULL);
978+
ast_update_property(&info_zv, AST_STR(str_flagsCombinable), &tmp_zv, NULL);
977979

978980
add_index_zval(result, kind, &info_zv);
979981
}

php_ast.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ extern zend_module_entry ast_module_entry;
2424
#define AST_NUM_CACHE_SLOTS (2 * 4)
2525

2626
ZEND_BEGIN_MODULE_GLOBALS(ast)
27-
#define X(str) zend_string *str_ ## str;
28-
AST_STR_DEFS
29-
#undef X
3027
void *cache_slots[AST_NUM_CACHE_SLOTS];
3128
zval metadata;
3229
ZEND_END_MODULE_GLOBALS(ast)
@@ -35,7 +32,15 @@ ZEND_EXTERN_MODULE_GLOBALS(ast)
3532

3633
#define AST_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(ast, v)
3734

38-
#define AST_STR(str) AST_G(str)
35+
typedef struct _ast_str_globals {
36+
#define X(str) zend_string *str_ ## str;
37+
AST_STR_DEFS
38+
#undef X
39+
} ast_str_globals;
40+
41+
extern ast_str_globals str_globals;
42+
43+
#define AST_STR(str) str_globals.str
3944

4045
/* Custom ast kind for names */
4146
#define AST_NAME 2048

0 commit comments

Comments
 (0)