From 5adc829eb0787682111ca063bfc2b31558999dff Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 4 Jul 2012 23:06:25 +0100 Subject: configure: add functions for testing code fragments This simplifies testing arbitrary code fragments within a function body. Signed-off-by: Mans Rullgard Signed-off-by: Luca Barbato --- configure | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 9f70a36f74..a08b3af79e 100755 --- a/configure +++ b/configure @@ -660,6 +660,20 @@ check_ld(){ check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs } +check_code(){ + log check_code "$@" + check=$1 + headers=$2 + code=$3 + shift 3 + { + for hdr in $headers; do + echo "#include <$hdr>" + done + echo "int main(void) { $code; return 0; }" + } | check_$check "$@" +} + check_cppflags(){ log check_cppflags "$@" set -- $($filter_cppflags "$@") @@ -817,15 +831,7 @@ check_type(){ type=$2 shift 2 disable_safe "$type" - incs="" - for hdr in $headers; do - incs="$incs -#include <$hdr>" - done - check_cc "$@" <$member; -EOF + check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" && + enable_safe "${struct}_${member}" } require(){ @@ -2399,9 +2398,7 @@ case "$arch" in ;; x86) subarch="x86_32" - check_cc <