[php-src] master: opcache: Rely on `alignof()` for `PLATFORM_ALIGNMENT` (#23906)

From: Date: Mon, 28 Sep 2026 10:38:57 +0000
Subject: [php-src] master: opcache: Rely on `alignof()` for `PLATFORM_ALIGNMENT` (#23906)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141614@lists.php.net to get a copy of this message
Author: Tim Düsterhus (TimWolla) Committer: GitHub (web-flow) Pusher: TimWolla Date: 2026-09-28T12:38:53+02:00 Commit: https://github.com/php/php-src/commit/586fc22acc019f8370a8bd152dd72a05b35de960 Raw diff: https://github.com/php/php-src/commit/586fc22acc019f8370a8bd152dd72a05b35de960.diff opcache: Rely on alignof() for PLATFORM_ALIGNMENT (#23906) Changed paths: M Zend/zend_portability.h M ext/opcache/zend_shared_alloc.h Diff: diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index e6c7ed992b40..a4f72d76881c 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -56,6 +56,7 @@ # include <unix.h> #endif +#include <stdalign.h> #include <stdarg.h> #include <stddef.h> diff --git a/ext/opcache/zend_shared_alloc.h b/ext/opcache/zend_shared_alloc.h index cf0bb10d8932..e9568fc368b7 100644 --- a/ext/opcache/zend_shared_alloc.h +++ b/ext/opcache/zend_shared_alloc.h @@ -164,15 +164,7 @@ typedef union _align_test { zend_long lng; } align_test; -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L -# define PLATFORM_ALIGNMENT (alignof(align_test) < 8 ? 8 : alignof(align_test)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -# define PLATFORM_ALIGNMENT (_Alignof(align_test) < 8 ? 8 : _Alignof(align_test)) -#elif ZEND_GCC_VERSION >= 2000 || defined(__clang__) -# define PLATFORM_ALIGNMENT (__alignof__(align_test) < 8 ? 8 : __alignof__(align_test)) -#else -# define PLATFORM_ALIGNMENT (sizeof(align_test)) -#endif +#define PLATFORM_ALIGNMENT (alignof(align_test) < 8 ? 8 : alignof(align_test)) #define ZEND_ALIGNED_SIZE(size) \ ZEND_MM_ALIGNED_SIZE_EX(size, PLATFORM_ALIGNMENT)

« previous php.cvs (#141614) next »