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.
This commit is contained in:
Lucas De Marchi 2015-02-10 00:45:11 -02:00
parent ba52c77e04
commit e6307200af
2 changed files with 8 additions and 1 deletions

View 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>])

View 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])
])