Patch-Source: https://github.com/krakjoe/apcu/commit/95f9ab828f95c6ca5877e584ead109189d0cec61 From 95f9ab828f95c6ca5877e584ead109189d0cec61 Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Thu, 30 Apr 2026 20:43:38 +0200 Subject: [PATCH] Replace XtOffsetOf() with offsetof() for PHP 8.6 PHP 8.6 removed XtOffsetOf(), which was an alias for the standard C offsetof() macro. Replace all usages in apc_cache.h and apc_iterator with offsetof() directly. Ref: https://github.com/php/php-src/commit/7114314c5a96c362b95663f7e7c9184586721f58 --- apc_cache.h | 2 +- apc_iterator.c | 2 +- apc_iterator.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apc_cache.h b/apc_cache.h index 36e81123..1db9b29c 100644 --- a/apc_cache.h +++ b/apc_cache.h @@ -295,7 +295,7 @@ static inline void apc_cache_runlock(apc_cache_t *cache) { } /* APC_ENTRY_SIZE takes into account the trailing key-string + terminating 0-byte */ -#define APC_ENTRY_SIZE(key_len) (ZEND_MM_ALIGNED_SIZE(XtOffsetOf(apc_cache_entry_t, key.val) + key_len + 1)) +#define APC_ENTRY_SIZE(key_len) (ZEND_MM_ALIGNED_SIZE(offsetof(apc_cache_entry_t, key.val) + key_len + 1)) /* ENTRYAT and ENTRYOF are used to convert between offsets and pointers to cache entries. * Both expect the presence of cache->header that points to the cache header in the diff --git a/apc_iterator.c b/apc_iterator.c index 535a9df7..cb7edc3b 100644 --- a/apc_iterator.c +++ b/apc_iterator.c @@ -548,7 +548,7 @@ int apc_iterator_init(int module_number) { apc_iterator_object_handlers.clone_obj = NULL; apc_iterator_object_handlers.free_obj = apc_iterator_free; - apc_iterator_object_handlers.offset = XtOffsetOf(apc_iterator_t, obj); + apc_iterator_object_handlers.offset = offsetof(apc_iterator_t, obj); return SUCCESS; } diff --git a/apc_iterator.h b/apc_iterator.h index d38a5a35..362dcb43 100644 --- a/apc_iterator.h +++ b/apc_iterator.h @@ -69,7 +69,7 @@ typedef struct _apc_iterator_t { zend_object obj; } apc_iterator_t; -#define apc_iterator_fetch_from(o) ((apc_iterator_t*)((char*)o - XtOffsetOf(apc_iterator_t, obj))) +#define apc_iterator_fetch_from(o) ((apc_iterator_t*)((char*)o - offsetof(apc_iterator_t, obj))) #define apc_iterator_fetch(z) apc_iterator_fetch_from(Z_OBJ_P(z)) typedef struct _apc_iterator_item_t {