]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
build: check for required builtin functions
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 10 Feb 2015 02:45:11 +0000 (00:45 -0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 10 Feb 2015 02:45:42 +0000 (00:45 -0200)
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.

configure.ac
m4/attributes.m4

index 3dde5d931c52256775a01605e613695ad56ffbd1..30eea86153e7137d3259f46264b7f25ff40b66cb 100644 (file)
@@ -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>])
 
index af17a6b89d2cca3922aec4a4afa17535e876723b..db39bf9f577176d14f1146fb11203fa32e9e19c8 100644 (file)
@@ -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])
 ])