Skip to content

Commit 61b012e

Browse files
committed
zend_portability: Add ZEND_CONTAINER_OF()
1 parent 7114314 commit 61b012e

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

UPGRADING.INTERNALS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ PHP 8.6 INTERNALS UPGRADE NOTES
9898
the non-throw versions.
9999
. The XtOffsetOf() alias of C’s offsetof() macro has been removed. Use
100100
offsetof() directly.
101+
. Added ZEND_CONTAINER_OF().
101102

102103
========================
103104
2. Build system changes

Zend/zend_portability.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ char *alloca();
385385
#define ZEND_ELEMENT_COUNT(m)
386386
#endif
387387

388+
#define ZEND_CONTAINER_OF(ptr, Type, member) ((Type*)((char*)(1 ? (ptr) : &((Type*)0)->member) - offsetof(Type, member)))
389+
388390
#ifdef HAVE_BUILTIN_CONSTANT_P
389391
# define ZEND_CONST_COND(_condition, _default) \
390392
(__builtin_constant_p(_condition) ? (_condition) : (_default))

0 commit comments

Comments
 (0)