Skip to content

Commit 0a6f5a7

Browse files
Use 2 bytes for constant flags, set class constant module number
1 parent 5c6d750 commit 0a6f5a7

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Zend/zend_API.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4884,7 +4884,13 @@ ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry
48844884
c = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
48854885
}
48864886
ZVAL_COPY_VALUE(&c->value, value);
4887-
ZEND_CLASS_CONST_FLAGS(c) = flags;
4887+
4888+
int module_number = PHP_USER_CONSTANT;
4889+
if (ce->type == ZEND_INTERNAL_CLASS) {
4890+
module_number = ce->info.internal.module->module_number;
4891+
}
4892+
ZEND_CONSTANT_SET_FLAGS(c, flags, module_number);
4893+
48884894
c->doc_comment = doc_comment;
48894895
c->attributes = NULL;
48904896
c->ce = ce;

Zend/zend_constants.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@
4545
} \
4646
} while (0)
4747

48-
#define PHP_USER_CONSTANT 0x7fffff /* a constant defined in user space */
48+
#define PHP_USER_CONSTANT 0x7fff /* a constant defined in user space */
4949

5050
typedef struct _zend_constant {
5151
zval value;
5252
zend_string *name;
5353
} zend_constant;
5454

5555
#define ZEND_CONSTANT_FLAGS(c) \
56-
(Z_CONSTANT_FLAGS((c)->value) & 0xff)
56+
(Z_CONSTANT_FLAGS((c)->value) & 0xffff)
5757

5858
#define ZEND_CONSTANT_MODULE_NUMBER(c) \
59-
(Z_CONSTANT_FLAGS((c)->value) >> 8)
59+
(Z_CONSTANT_FLAGS((c)->value) >> 16)
6060

6161
#define ZEND_CONSTANT_SET_FLAGS(c, _flags, _module_number) do { \
6262
Z_CONSTANT_FLAGS((c)->value) = \
63-
((_flags) & 0xff) | ((_module_number) << 8); \
63+
((_flags) & 0xffff) | ((_module_number) << 16); \
6464
} while (0)
6565

6666
#define REGISTER_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name)-1, (flags), module_number)

0 commit comments

Comments
 (0)