projects/aports·blob master · refs

56 lines · 2.3 KiB

1Patch-Source: https://github.com/krakjoe/apcu/commit/95f9ab828f95c6ca5877e584ead109189d0cec61
2From 95f9ab828f95c6ca5877e584ead109189d0cec61 Mon Sep 17 00:00:00 2001
3From: Andy Postnikov <[email protected]>
4Date: Thu, 30 Apr 2026 20:43:38 +0200
5Subject: [PATCH] Replace XtOffsetOf() with offsetof() for PHP 8.6
6
7PHP 8.6 removed XtOffsetOf(), which was an alias for the standard C
8offsetof() macro. Replace all usages in apc_cache.h and apc_iterator
9with offsetof() directly.
10
11Ref: 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
18diff --git a/apc_cache.h b/apc_cache.h
19index 36e81123..1db9b29c 100644
20--- a/apc_cache.h
21+++ b/apc_cache.h
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
31diff --git a/apc_iterator.c b/apc_iterator.c
32index 535a9df7..cb7edc3b 100644
33--- a/apc_iterator.c
34+++ b/apc_iterator.c
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 }
44diff --git a/apc_iterator.h b/apc_iterator.h
45index d38a5a35..362dcb43 100644
46--- a/apc_iterator.h
47+++ b/apc_iterator.h
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 {