Skip to content

Commit 220ddc3

Browse files
committed
Use __attribute__((assume())) in ZEND_ASSUME when available
1 parent 4091d24 commit 220ddc3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Zend/Zend.m4

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,23 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
405405
if test "$ac_cv_cpuid_count_available" = "yes"; then
406406
AC_DEFINE([HAVE_CPUID_COUNT], 1, [whether __cpuid_count is available])
407407
fi
408+
409+
AC_MSG_CHECKING(whether statement attribute assume is available)
410+
411+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
412+
struct Foo {
413+
int bar;
414+
};
415+
void foo(struct Foo *foo) {
416+
__attribute__((assume(foo->bar != 0)));
417+
}
418+
]], [[
419+
]])], [
420+
HAVE_STATEMENT_ATTRIBUTE_ASSUME=yes
421+
], [
422+
HAVE_STATEMENT_ATTRIBUTE_ASSUME=no
423+
])
424+
if test "$HAVE_STATEMENT_ATTRIBUTE_ASSUME" = "yes"; then
425+
AC_DEFINE([HAVE_STATEMENT_ATTRIBUTE_ASSUME], 1, [whether statement attribute assume is available])
426+
fi
427+
AC_MSG_RESULT($HAVE_STATEMENT_ATTRIBUTE_ASSUME)

Zend/zend_portability.h

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

9090
#if defined(ZEND_WIN32) && !defined(__clang__)
9191
# define ZEND_ASSUME(c) __assume(c)
92+
#elif HAVE_STATEMENT_ATTRIBUTE_ASSUME
93+
# define ZEND_ASSUME(c) __attribute__((assume(c)))
9294
#elif defined(__clang__) && __has_builtin(__builtin_assume)
9395
# pragma clang diagnostic ignored "-Wassume"
9496
# define ZEND_ASSUME(c) __builtin_assume(c)

0 commit comments

Comments
 (0)