| 1 | Patch-Source: https://github.com/krakjoe/apcu/commit/95f9ab828f95c6ca5877e584ead109189d0cec61
|
| 2 | From 95f9ab828f95c6ca5877e584ead109189d0cec61 Mon Sep 17 00:00:00 2001
|
| 3 | From: Andy Postnikov <[email protected]>
|
| 4 | Date: Thu, 30 Apr 2026 20:43:38 +0200
|
| 5 | Subject: [PATCH] Replace XtOffsetOf() with offsetof() for PHP 8.6
|
| 6 |
|
| 7 | PHP 8.6 removed XtOffsetOf(), which was an alias for the standard C
|
| 8 | offsetof() macro. Replace all usages in apc_cache.h and apc_iterator
|
| 9 | with offsetof() directly.
|
| 10 |
|
| 11 | Ref: https://github.com/php/php-src/commit/7114314c5a96c362b95663f7e7c9184586721f58
|
| 12 | ---
|
| 13 | apc_cache.h | 2 +-
|
| 14 | apc_iterator.c | 2 +-
|
| 15 | apc_iterator.h | 2 +-
|
| 16 | 3 files changed, 3 insertions(+), 3 deletions(-)
|
| 17 |
|
| 18 | diff --git a/apc_cache.h b/apc_cache.h
|
| 19 | index 36e81123..1db9b29c 100644
|
| 20 | |
| 21 | |
| 22 | @@ -295,7 +295,7 @@ static inline void apc_cache_runlock(apc_cache_t *cache) {
|
| 23 | }
|
| 24 |
|
| 25 | /* APC_ENTRY_SIZE takes into account the trailing key-string + terminating 0-byte */
|
| 26 | -#define APC_ENTRY_SIZE(key_len) (ZEND_MM_ALIGNED_SIZE(XtOffsetOf(apc_cache_entry_t, key.val) + key_len + 1))
|
| 27 | +#define APC_ENTRY_SIZE(key_len) (ZEND_MM_ALIGNED_SIZE(offsetof(apc_cache_entry_t, key.val) + key_len + 1))
|
| 28 |
|
| 29 | /* ENTRYAT and ENTRYOF are used to convert between offsets and pointers to cache entries.
|
| 30 | * Both expect the presence of cache->header that points to the cache header in the
|
| 31 | diff --git a/apc_iterator.c b/apc_iterator.c
|
| 32 | index 535a9df7..cb7edc3b 100644
|
| 33 | |
| 34 | |
| 35 | @@ -548,7 +548,7 @@ int apc_iterator_init(int module_number) {
|
| 36 |
|
| 37 | apc_iterator_object_handlers.clone_obj = NULL;
|
| 38 | apc_iterator_object_handlers.free_obj = apc_iterator_free;
|
| 39 | - apc_iterator_object_handlers.offset = XtOffsetOf(apc_iterator_t, obj);
|
| 40 | + apc_iterator_object_handlers.offset = offsetof(apc_iterator_t, obj);
|
| 41 |
|
| 42 | return SUCCESS;
|
| 43 | }
|
| 44 | diff --git a/apc_iterator.h b/apc_iterator.h
|
| 45 | index d38a5a35..362dcb43 100644
|
| 46 | |
| 47 | |
| 48 | @@ -69,7 +69,7 @@ typedef struct _apc_iterator_t {
|
| 49 | zend_object obj;
|
| 50 | } apc_iterator_t;
|
| 51 |
|
| 52 | -#define apc_iterator_fetch_from(o) ((apc_iterator_t*)((char*)o - XtOffsetOf(apc_iterator_t, obj)))
|
| 53 | +#define apc_iterator_fetch_from(o) ((apc_iterator_t*)((char*)o - offsetof(apc_iterator_t, obj)))
|
| 54 | #define apc_iterator_fetch(z) apc_iterator_fetch_from(Z_OBJ_P(z))
|
| 55 |
|
| 56 | typedef struct _apc_iterator_item_t {
|