summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2015-02-10 00:45:11 -0200
committerLucas De Marchi <lucas.demarchi@intel.com>2015-02-10 00:45:42 -0200
commite6307200af74d1556466522216e8ae77b7c8b843 (patch)
tree752e3ed562011f36ea380ac1ed1766974c9c1bb5
parentba52c77e04b0f2d5a9ebee147f4445ac8b1f2b2a (diff)
downloadkmod-e6307200af74d1556466522216e8ae77b7c8b843.tar.gz
build: check for required builtin functions
These builtins are implemented by both gcc and clang since a long time and we don't provide fallback for them. Let the configure phase check for them.
-rw-r--r--configure.ac3
-rw-r--r--m4/attributes.m46
2 files changed, 8 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 3dde5d9..30eea86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,9 @@ AC_CHECK_FUNCS_ONCE(__xstat)
AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv])
AC_CHECK_FUNCS_ONCE([finit_module])
+CC_CHECK_FUNC_BUILTIN([__builtin_clz])
+CC_CHECK_FUNC_BUILTIN([__builtin_types_compatible_p])
+
# dietlibc doesn't have st.st_mtim struct member
AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
diff --git a/m4/attributes.m4 b/m4/attributes.m4
index af17a6b..db39bf9 100644
--- a/m4/attributes.m4
+++ b/m4/attributes.m4
@@ -260,6 +260,8 @@ AC_DEFUN([CC_CHECK_FUNC_BUILTIN], [
[cc_cv_have_$1],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [
m4_case([$1],
+ [__builtin_clz], [$1(0)],
+ [__builtin_types_compatible_p], [$1(int, int)],
[__builtin_expect], [$1(0, 0)]
)])],
[cc_cv_have_$1=yes],
@@ -267,7 +269,9 @@ AC_DEFUN([CC_CHECK_FUNC_BUILTIN], [
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])
+ $2],
+ [AS_IF([test "x$3" = "x"], [AC_MSG_ERROR([*** builtin function not found: $1()])], [$3])]
+ )
m4_popdef([UPNAME])
])