[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/12] use a shell function for AC_COMPUTE_INT
From: |
Paolo Bonzini |
Subject: |
[PATCH 10/12] use a shell function for AC_COMPUTE_INT |
Date: |
Mon, 20 Oct 2008 15:35:47 +0200 |
The remaining three patches achieve the final 5-10% reduction.
2008-10-12 Paolo Bonzini <address@hidden>
* lib/autoconf/general.m4 (_AC_COMPUTE_INT_COMPILE,
_AC_COMPUTE_INT_RUN): Add IF-SUCCESS argument.
(AC_COMPUTE_INT): Use a shell function.
---
lib/autoconf/general.m4 | 49 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 2987716..fd5eb80 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2825,8 +2825,9 @@ AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
## ----------------------------------- ##
-# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS])
-# -------------------------------------------------------------------
+# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, PROLOGUE, [IF-SUCCESS],
+# [IF-FAILURE])
+# ---------------------------------------------------------------------
# Compute the integer EXPRESSION and store the result in the VARIABLE.
# Works OK if cross compiling, but assumes twos-complement arithmetic.
m4_define([_AC_COMPUTE_INT_COMPILE],
@@ -2862,32 +2863,56 @@ while test "x$ac_lo" != "x$ac_hi"; do
_AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_mid])],
[ac_hi=$ac_mid], [ac_lo=`expr '(' $ac_mid ')' + 1`])
done
+AS_VAR_PUSHDEF([ac_Result], [$2])dnl
case $ac_lo in
-?*) $2=$ac_lo;;
-'') $4 ;;
+?*) AS_VAR_SET([ac_Result], [$ac_lo]); $4 ;;
+'') $5 ;;
esac[]dnl
+AS_VAR_POPDEF([ac_Result])dnl
])# _AC_COMPUTE_INT_COMPILE
-# _AC_COMPUTE_INT_RUN(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS])
-# ---------------------------------------------------------------
+# _AC_COMPUTE_INT_RUN(EXPRESSION, VARIABLE, PROLOGUE, [IF-SUCCESS],
+# [IF-FAILURE])
+# -----------------------------------------------------------------
# Store the evaluation of the integer EXPRESSION in VARIABLE.
m4_define([_AC_COMPUTE_INT_RUN],
-[_AC_RUN_IFELSE([AC_LANG_INT_SAVE([$3], [$1])],
- [$2=`cat conftest.val`], [$4])])
+[AS_VAR_PUSHDEF([ac_Result], [$2])dnl
+_AC_RUN_IFELSE([AC_LANG_INT_SAVE([$3], [$1])],
+ [AS_VAR_SET([ac_Result], [`cat conftest.val`]); $4], [$5])
+rm -f conftest.val
+AS_VAR_POPDEF([ac_Result])dnl
+])
# AC_COMPUTE_INT(VARIABLE, EXPRESSION, PROLOGUE, [IF-FAILS])
# ----------------------------------------------------------
AC_DEFUN([AC_COMPUTE_INT],
[AC_LANG_COMPILER_REQUIRE()dnl
+AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_compute_int],
+ [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_compute_int],
+ [LINENO VAR EXPR INCLUDES],
+ [Tries to find the compile-time value of EXPR in a program that includes
+ INCLUDES, setting VAR accordingly. Returns whether the value could
+ be computed])], [
+AS_LINENO_PUSH([$[]1])
+ac_var=[$]2
+ac_expr=[$]3
+ac_prologue=[$]4
if test "$cross_compiling" = yes; then
- _AC_COMPUTE_INT_COMPILE([$2], [$1], [$3], [$4])
+ _AC_COMPUTE_INT_COMPILE([$ac_expr], [$ac_var], [$ac_prologue],
+ [ac_retval=0], [ac_retval=1])
else
- _AC_COMPUTE_INT_RUN([$2], [$1], [$3], [$4])
+ _AC_COMPUTE_INT_RUN([$ac_expr], [$ac_var], [$ac_prologue],
+ [ac_retval=0], [ac_retval=1])
fi
-rm -f conftest.val[]dnl
-])# _AC_COMPUTE_INT
+rm -f conftest.val
+AS_LINENO_POP
+return $ac_retval
+])dnl
+AS_IF([ac_func_[]_AC_LANG_ABBREV[]_compute_int "$LINENO" "$1" "$2"
"AS_ESCAPE([$3], ["])"],
+ [], [$4])
+])# AC_COMPUTE_INT
# _AC_COMPUTE_INT(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS])
# -----------------------------------------------------------
--
1.5.5
- [PATCH 10/12] use a shell function for AC_COMPUTE_INT,
Paolo Bonzini <=