Skip to content

Commit 4a4b03b

Browse files
committed
Remove XtOffsetOf hack
1 parent 9ed4966 commit 4a4b03b

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

Zend/zend_constants.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len)
275275
return NULL;
276276
}
277277

278-
static zend_constant *zend_get_constant_impl(zend_string *name)
278+
ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name)
279279
{
280280
zend_constant *c = zend_hash_find_ptr(EG(zend_constants), name);
281281
if (c) {
@@ -292,7 +292,7 @@ static zend_constant *zend_get_constant_impl(zend_string *name)
292292

293293
ZEND_API zval *zend_get_constant(zend_string *name)
294294
{
295-
zend_constant *c = zend_get_constant_impl(name);
295+
zend_constant *c = zend_get_constant_ptr(name);
296296
if (c) {
297297
return &c->value;
298298
}
@@ -521,7 +521,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
521521
}
522522
} else {
523523
if (cname) {
524-
c = zend_get_constant_impl(cname);
524+
c = zend_get_constant_ptr(cname);
525525
} else {
526526
c = zend_get_constant_str_impl(name, name_len);
527527
}

Zend/zend_constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void zend_shutdown_constants(void);
7575
void zend_register_standard_constants(void);
7676
ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce);
7777
ZEND_API zval *zend_get_constant(zend_string *name);
78+
ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name);
7879
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
7980
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
8081
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags);

ext/reflection/php_reflection.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7232,16 +7232,13 @@ ZEND_METHOD(ReflectionConstant, __construct)
72327232
}
72337233
memcpy(ZSTR_VAL(lc_name) + ns_len, source + ns_len, source_len - ns_len);
72347234

7235-
zval *const_zv = zend_get_constant(lc_name);
7235+
zend_constant *const_ = zend_get_constant_ptr(lc_name);
72367236
zend_string_release_ex(lc_name, /* persistent */ false);
7237-
7238-
if (!const_zv) {
7237+
if (!const_) {
72397238
zend_throw_exception_ex(reflection_exception_ptr, 0, "Constant \"%s\" does not exist", ZSTR_VAL(name));
72407239
RETURN_THROWS();
72417240
}
72427241

7243-
zend_constant *const_ = (zend_constant*)((uintptr_t)const_zv - XtOffsetOf(zend_constant, value));
7244-
72457242
intern->ptr = const_;
72467243
intern->ref_type = REF_TYPE_OTHER;
72477244

0 commit comments

Comments
 (0)