Skip to content

Commit bf4ec8b

Browse files
committed
Use __attribute__((assume())) in ZEND_ASSUME when available
Closes GH-13171
1 parent 98e2948 commit bf4ec8b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Zend/zend_portability.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989

9090
#if defined(ZEND_WIN32) && !defined(__clang__)
9191
# define ZEND_ASSUME(c) __assume(c)
92+
#elif defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 13
93+
/* GCC emits a warning when __attribute__ appears directly after a label, so we need a do-while loop. */
94+
# define ZEND_ASSUME(c) do { __attribute__((assume(c))); } while (0)
9295
#elif defined(__clang__) && __has_builtin(__builtin_assume)
9396
# pragma clang diagnostic ignored "-Wassume"
9497
# define ZEND_ASSUME(c) __builtin_assume(c)

sapi/phpdbg/phpdbg_watch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,10 @@ void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals) {
333333

334334
/* ### REGISTER WATCHPOINT ### To be used only by watch element and collision managers ### */
335335
static inline void phpdbg_store_watchpoint_btree(phpdbg_watchpoint_t *watch) {
336-
phpdbg_btree_result *res;
337-
ZEND_ASSERT((res = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr)) == NULL || res->ptr == watch);
336+
#if ZEND_DEBUG
337+
phpdbg_btree_result *res = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr);
338+
ZEND_ASSERT(res == NULL || res->ptr == watch);
339+
#endif
338340
phpdbg_btree_insert(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr, watch);
339341
}
340342

0 commit comments

Comments
 (0)