summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2015-02-10 00:31:08 -0200
committerLucas De Marchi <lucas.demarchi@intel.com>2015-02-10 00:31:25 -0200
commitba52c77e04b0f2d5a9ebee147f4445ac8b1f2b2a (patch)
treec502631ed6089df287ce829da9d679058ef5887a /m4
parentd9ab7abe1e135a71685f0eb21a423c9db12e9580 (diff)
downloadkmod-ba52c77e04b0f2d5a9ebee147f4445ac8b1f2b2a.tar.gz
kmod-ba52c77e04b0f2d5a9ebee147f4445ac8b1f2b2a.tar.bz2
kmod-ba52c77e04b0f2d5a9ebee147f4445ac8b1f2b2a.zip
build: add better check for builtin function
It's not used right now in kmod, but may be used in future for other builtins, so let the macro generic.
Diffstat (limited to 'm4')
-rw-r--r--m4/attributes.m436
1 files changed, 15 insertions, 21 deletions
diff --git a/m4/attributes.m4 b/m4/attributes.m4
index e822197..af17a6b 100644
--- a/m4/attributes.m4
+++ b/m4/attributes.m4
@@ -254,27 +254,21 @@ AC_DEFUN([CC_FLAG_VISIBILITY], [
[$2])
])
-AC_DEFUN([CC_FUNC_EXPECT], [
- AC_REQUIRE([CC_CHECK_WERROR])
- AC_CACHE_CHECK([if compiler has __builtin_expect function],
- [cc_cv_func_expect],
- [ac_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $cc_cv_werror"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE(
- [int some_function() {
- int a = 3;
- return (int)__builtin_expect(a, 3);
- }])],
- [cc_cv_func_expect=yes],
- [cc_cv_func_expect=no])
- CFLAGS="$ac_save_CFLAGS"
- ])
-
- AS_IF([test "x$cc_cv_func_expect" = "xyes"],
- [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
- [Define this if the compiler supports __builtin_expect() function])
- $1],
- [$2])
+AC_DEFUN([CC_CHECK_FUNC_BUILTIN], [
+ m4_pushdef([UPNAME], m4_translit([$1], [-a-z], [_A-Z]))
+ AC_CACHE_CHECK([if compiler has $1 function],
+ [cc_cv_have_$1],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [
+ m4_case([$1],
+ [__builtin_expect], [$1(0, 0)]
+ )])],
+ [cc_cv_have_$1=yes],
+ [cc_cv_have_$1=no])])
+
+ AS_IF([test "x$cc_cv_have_$1" = "xyes"],
+ [AC_DEFINE([HAVE_]m4_defn([UPNAME]), 1, [Define this if the compiler supports $1() function])
+ $2], [$3])
+ m4_popdef([UPNAME])
])
AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [