Commit 05e5bb05 authored by Kenneth Raffenetti's avatar Kenneth Raffenetti
Browse files

Add configure test for __builtin_expect



Fixes #1695
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@mcs.anl.gov>
parent 828b0b4d
......@@ -1651,3 +1651,21 @@ AC_DEFUN([PAC_C_MACRO_VA_ARGS],[
fi
rm -f pac_test.log
])dnl
# Will AC_DEFINE([HAVE_BUILTIN_EXPECT]) if the compiler supports __builtin_expect.
AC_DEFUN([PAC_C_BUILTIN_EXPECT],[
AC_MSG_CHECKING([if C compiler supports __builtin_expect])
AC_TRY_LINK(, [
return __builtin_expect(1, 1) ? 1 : 0
], [
have_builtin_expect=yes
AC_MSG_RESULT([yes])
], [
have_builtin_expect=no
AC_MSG_RESULT([no])
])
if test x$have_builtin_expect = xyes ; then
AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler supports __builtin_expect.])
fi
])
......@@ -2738,6 +2738,7 @@ AC_C_RESTRICT
AC_C_INLINE
PAC_C_GNU_ATTRIBUTE
PAC_C_BUILTIN_EXPECT
# We need to check for the endianess in order to implement the
# "external32" representations. This defines "WORDS_BIGENDIAN when
# the system is bigendian.
......
......@@ -338,8 +338,7 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
*
* These macros are not namespaced because the namespacing is cumbersome.
*/
/* safety guard for now, add a configure check in the future */
#if ( defined(__GNUC__) && (__GNUC__ >= 3) ) || defined(__xlc__)
#ifdef HAVE_BUILTIN_EXPECT
# define unlikely(x_) __builtin_expect(!!(x_),0)
# define likely(x_) __builtin_expect(!!(x_),1)
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment