From abb437c0abedc6646927381017666db3f962befd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Sep 2011 07:05:13 +0930 Subject: [PATCH] ccan: configure check for HAVE_BUILTIN_CHOOSE_EXPR We weren't testing for this, and without it, typesafe_cb just casts its function argument. This is why I didn't get a warning when one of my patches amended a function incorrectly. Signed-off-by: Rusty Russell --- lib/ccan/libccan.m4 | 15 +++++++++++++++ lib/ccan/wscript | 3 +++ 2 files changed, 18 insertions(+) diff --git a/lib/ccan/libccan.m4 b/lib/ccan/libccan.m4 index df38d3b962d..7dbea5815cb 100644 --- a/lib/ccan/libccan.m4 +++ b/lib/ccan/libccan.m4 @@ -236,6 +236,21 @@ if test x"$samba_cv_builtin_types_compatible_p" = xyes ; then [whether we have __builtin_types_compatible_p]) fi +AC_CACHE_CHECK([whether we have __builtin_choose_exptr], + samba_cv_builtin_choose_expr, + [ + AC_LINK_IFELSE( + [int main(void) { + return __builtin_choose_expr(1, 0, "garbage"); + }], + samba_cv_builtin_types_choose_expr=yes) + ]) + +if test x"$samba_cv_builtin_choose_expr" = xyes ; then + AC_DEFINE(HAVE_BUILTIN_CHOOSE_EXPR, 1, + [whether we have __builtin_choose_expr]) +fi + AC_CACHE_CHECK([whether we have __builtin_compound_literals], samba_cv_builtin_compound_literals, [ diff --git a/lib/ccan/wscript b/lib/ccan/wscript index 0543a4de075..9daf091e5b6 100644 --- a/lib/ccan/wscript +++ b/lib/ccan/wscript @@ -79,6 +79,9 @@ def configure(conf): Logs.error("Failed endian determination. The PDP-11 is back?") sys.exit(1) + conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");', + link=True, + define='HAVE_BUILTIN_CHOOSE_EXPR') conf.CHECK_CODE('return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;', link=True, define='HAVE_BUILTIN_CLZ') -- 2.34.1