autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[CFT] Shell functionization patch (if you don't know what that means, it


From: Paolo Bonzini
Subject: [CFT] Shell functionization patch (if you don't know what that means, it's faster Autoconf and leaner configure scripts)
Date: Thu, 16 Oct 2008 18:38:19 +0200
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

Hi all, this is *the* patch to add shell functions to Autoconf at last.

I am submitting it in one piece for testing, but I'm not really calling
for review; for that, I'll submit it split in 12 pieces.  Also, the zsh
issue has to be understood better (and could be a deal breaker, though I
don't think so).

But if you love using the bleeding edge of Autoconf, install the git
master branch somewhere and throw the functionized Autoconf at it.  The
patch applies on top of 2535dcc192d86c46478463049b2acb39f4856413.  Any
Debian, Fedora or Gentoo mavens listening?

Statistics can be interesting, but maybe those are better sent privately
to me (I'll collect them).  From my big sample of 2 GNU projects (GNU
Smalltalk and GNU sed), chosen among the 2 projects I maintain, it is
about 20% faster and producer 30-45% leaner scripts compared to master.

The speed of configure scripts is more-or-less unchanged, though I
expect that the more readable code of configure scripts will help in the
medium term squeezing some percentage out of that too.

Testsuite passes.

Paolo
2008-10-16  Paolo Bonzini  <address@hidden>
    
        * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_OLD,
        _AC_CHECK_HEADER_NEW): Use a shell function.
        * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Use a shell
        function.
        * lib/autoconf/functions.m4 (AC_CHECK_FUNC): Use a shell function.
        * lib/autoconf/general.m4 (_AC_COMPUTE_INT_COMPILE,
        _AC_COMPUTE_INT_RUN): Add IF-SUCCESS argument.
        (AC_COMPUTE_INT): Use a shell function.
        (AC_CHECK_DECL): Use a shell function.
        (_AC_RUN_IFELSE): Use a shell function.
        (_AC_LINK_IFELSE): Use a shell function.
        (_AC_COMPILE_IFELSE): Use a shell function.
        (_AC_PREPROC_IFELSE): Use a shell function.
        * lib/autoconf/types.m4 (_AC_TYPE_INT, _AC_TYPE_UNSIGNED_INT): Use
        a shell function.
        (AC_CHECK_MEMBER): Use a shell function.
        (_AC_CHECK_TYPE_NEW): Use a shell function.

diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index c325f30..dfb88b4 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -65,11 +65,18 @@
 # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # -----------------------------------------------------------------
 AC_DEFUN([AC_CHECK_FUNC],
-[AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
-AC_CACHE_CHECK([for $1], [ac_var],
-[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
-               [AS_VAR_SET([ac_var], [yes])],
-               [AS_VAR_SET([ac_var], [no])])])
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_func], [
+  AS_LINENO_PUSH([$[]1])
+  AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$[]2])dnl
+  AC_CACHE_CHECK([for $[]2], [ac_var],
+  [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$][2])],
+                 [AS_VAR_SET([ac_var], [yes])],
+                 [AS_VAR_SET([ac_var], [no])])])
+  AS_VAR_POPDEF([ac_var])dnl
+  AS_LINENO_POP
+])dnl
+ac_func_[]_AC_LANG_ABBREV[]_check_func "$LINENO" "$1"
+AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
 AS_VAR_IF([ac_var], [yes], [$2], [$3])dnl
 AS_VAR_POPDEF([ac_var])dnl
 ])# AC_CHECK_FUNC
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index beb3104..c5787e9 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2362,18 +2362,24 @@ AC_DEFUN([AC_RUN_LOG],
 # This macro can be used during the selection of a preprocessor.
 # eval is necessary to expand ac_cpp.
 AC_DEFUN([_AC_PREPROC_IFELSE],
-[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-AS_IF([_AC_DO_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null && {
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_cpp], [
+  AS_LINENO_PUSH([$[]1])
+  AS_IF([_AC_DO_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null && {
         test -z 
"$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag$ac_[]_AC_LANG_ABBREV[]_werror_flag" 
||
         test ! -s conftest.err
        }],
-  [$2],
-  [_AC_MSG_LOG_CONFTEST
-  $3])
-rm -f conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl
+    [ac_retval=0],
+    [_AC_MSG_LOG_CONFTEST
+    ac_retval=1])
+  rm -f conftest.err
+  AS_LINENO_POP
+  return $ac_retval
+])dnl
+m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
+AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_cpp "$LINENO"], [$2], [$3])
+m4_ifvaln([$1], [rm -f conftest.$ac_ext])
 ])# _AC_PREPROC_IFELSE
 
-
 # AC_PREPROC_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
 # ---------------------------------------------------------------
 # Try to preprocess PROGRAM.  Requires that the preprocessor for the
@@ -2434,17 +2440,24 @@ AC_DEFUN([AC_EGREP_HEADER],
 # ----------------------------------------------------------------
 # Try to compile PROGRAM.
 # This macro can be used during the selection of a compiler.
-m4_define([_AC_COMPILE_IFELSE],
-[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-rm -f conftest.$ac_objext
-AS_IF([_AC_DO_STDERR($ac_compile) && {
+AC_DEFUN([_AC_COMPILE_IFELSE],
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_compile], [
+  AS_LINENO_PUSH([$[]1])
+  rm -f conftest.$ac_objext
+  AS_IF([_AC_DO_STDERR($ac_compile) && {
         test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest.$ac_objext],
-      [$2],
+      [ac_retval=0],
       [_AC_MSG_LOG_CONFTEST
-       $3])
-rm -f core conftest.err conftest.$ac_objext m4_ifval([$1], 
[conftest.$ac_ext])[]dnl
+       ac_retval=1])
+  rm -f core conftest.err conftest.$ac_objext
+  AS_LINENO_POP
+  return $ac_retval
+])dnl
+m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
+AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_compile "$LINENO"], [$2], [$3])
+m4_ifvaln([$1], [rm -f conftest.$ac_ext])
 ])# _AC_COMPILE_IFELSE
 
 
@@ -2482,25 +2495,32 @@ AU_DEFUN([AC_TRY_COMPILE],
 # reported by Chris Johns in
 # <http://lists.gnu.org/archive/html/autoconf/2007-03/msg00085.html>.
 #
-m4_define([_AC_LINK_IFELSE],
-[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-rm -f conftest.$ac_objext conftest$ac_exeext
-AS_IF([_AC_DO_STDERR($ac_link) && {
+AC_DEFUN([_AC_LINK_IFELSE],
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_link], [
+  AS_LINENO_PUSH([$[]1])
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  AS_IF([_AC_DO_STDERR($ac_link) && {
         test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
         test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
         test "$cross_compiling" = yes ||
         AS_TEST_X([conftest$ac_exeext])
        }],
-      [$2],
+      [ac_retval=0],
       [_AC_MSG_LOG_CONFTEST
-       $3])
-dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
-dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
-dnl as it would interfere with the next link command.
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
+       ac_retval=1])
+  # Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
+  # information created by the PGI compiler (conftest_ipa8_conftest.oo),
+  # as it would interfere with the next link command.
+  rm -rf conftest.dSYM
+  rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext
+  AS_LINENO_POP
+  return $ac_retval
+])dnl
+m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
+AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_link "$LINENO"], [$2], [$3])
+m4_ifvaln([$1], [rm -f conftest.$ac_ext])
 ])# _AC_LINK_IFELSE
 
 
@@ -2544,22 +2564,24 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])], [$4], 
[$5])])
 # We also remove conftest.o as if the compilation fails, some compilers
 # don't remove it.  We remove gmon.out and bb.out, which may be
 # created during the run if the program is built with profiling support.
-m4_define([_AC_RUN_IFELSE],
-[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-rm -f conftest$ac_exeext
-AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS(./conftest$ac_exeext)],
-      [$2],
+AC_DEFUN([_AC_RUN_IFELSE],
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_try_run], [
+  AS_LINENO_PUSH([$[]1])
+  AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS(./conftest$ac_exeext)],
+      [ac_retval=0],
       [AS_ECHO(["$as_me: program exited with status $ac_status"]) 
>&AS_MESSAGE_LOG_FD
-_AC_MSG_LOG_CONFTEST
-m4_ifvaln([$3],
-         [( exit $ac_status )
-$3])dnl])[]dnl
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext m4_ifval([$1],
-                                                    [conftest.$ac_ext])[]dnl
+       _AC_MSG_LOG_CONFTEST
+       ac_retval=$ac_status])
+  rm -rf conftest.dSYM
+  rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext 
conftest.$ac_objext conftest$ac_exeext
+  AS_LINENO_POP
+  return $ac_retval
+])dnl
+m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
+AS_IF([ac_func_[]_AC_LANG_ABBREV[]_try_run "$LINENO"], [$2], [$3])
+m4_ifvaln([$1], [rm -f conftest.$ac_ext])
 ])# _AC_RUN_IFELSE
 
-
 # AC_RUN_IFELSE(PROGRAM,
 #               [ACTION-IF-TRUE], [ACTION-IF-FALSE],
 #               [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR])
@@ -2636,15 +2658,24 @@ $2],
 # -------------------------------------------------------
 # Check whether SYMBOL (a function, variable, or constant) is declared.
 AC_DEFUN([AC_CHECK_DECL],
-[AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl
-AC_CACHE_CHECK([whether $1 is declared], [ac_Symbol],
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
-[#ifndef $1
-  (void) $1;
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_decl], [
+AS_LINENO_PUSH([$[]1])
+ac_symbol=[$]2
+ac_includes=[$]3
+AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$ac_symbol])dnl
+AC_CACHE_CHECK([whether $ac_symbol is declared], [ac_Symbol],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes],
+[#ifndef $ac_symbol
+  (void) $ac_symbol;
 #endif
 ])],
                   [AS_VAR_SET([ac_Symbol], [yes])],
                   [AS_VAR_SET([ac_Symbol], [no])])])
+AS_VAR_POPDEF([ac_Symbol])dnl
+AS_LINENO_POP
+])dnl
+ac_func_[]_AC_LANG_ABBREV[]_check_decl "$LINENO" "$1" 
"AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])"
+AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl
 AS_VAR_IF([ac_Symbol], [yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([ac_Symbol])dnl
 ])# AC_CHECK_DECL
@@ -2760,8 +2791,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],
@@ -2797,32 +2829,51 @@ 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
+AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_compute_int], [
+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])
 # -----------------------------------------------------------
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 16b2737..9c35516 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -103,47 +103,55 @@ AC_DEFUN([AC_CHECK_HEADER],
 # because it obfuscate the code to try to factor everything, in particular
 # because of the cache variables, and the `checking...' messages.
 m4_define([_AC_CHECK_HEADER_MONGREL],
-[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_mongrel], [
+AS_LINENO_PUSH([$[]1])
+ac_header=[$]2
+ac_includes=[$]3
+AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$ac_header])dnl
 AS_VAR_SET_IF([ac_Header],
-             [AC_CACHE_CHECK([for $1], [ac_Header], [])],
+             [AC_CACHE_CHECK([for $ac_header], [ac_Header], [])],
              [# Is the header compilable?
-AC_MSG_CHECKING([$1 usability])
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
address@hidden:@include <$1>])],
+AC_MSG_CHECKING([$ac_header usability])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([$ac_includes
address@hidden:@include <$ac_header>])],
                  [ac_header_compiler=yes],
                  [ac_header_compiler=no])
 AC_MSG_RESULT([$ac_header_compiler])
 
 # Is the header present?
-AC_MSG_CHECKING([$1 presence])
-AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <$1>])],
+AC_MSG_CHECKING([$ac_header presence])
+AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <$ac_header>])],
                  [ac_header_preproc=yes],
                  [ac_header_preproc=no])
 AC_MSG_RESULT([$ac_header_preproc])
 
 # So?  What about this header?
-case 
$ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag
 in
+case 
$ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag
 in #((
   yes:no: )
-    AC_MSG_WARN([$1: accepted by the compiler, rejected by the preprocessor!])
-    AC_MSG_WARN([$1: proceeding with the compiler's result])
+    AC_MSG_WARN([$ac_header: accepted by the compiler, rejected by the 
preprocessor!])
+    AC_MSG_WARN([$ac_header: proceeding with the compiler's result])
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    AC_MSG_WARN([$1: present but cannot be compiled])
-    AC_MSG_WARN([$1:     check for missing prerequisite headers?])
-    AC_MSG_WARN([$1: see the Autoconf documentation])
-    AC_MSG_WARN([$1:     section "Present But Cannot Be Compiled"])
-    AC_MSG_WARN([$1: proceeding with the preprocessor's result])
-    AC_MSG_WARN([$1: in the future, the compiler will take precedence])
+    AC_MSG_WARN([$ac_header: present but cannot be compiled])
+    AC_MSG_WARN([$ac_header:     check for missing prerequisite headers?])
+    AC_MSG_WARN([$ac_header: see the Autoconf documentation])
+    AC_MSG_WARN([$ac_header:     section "Present But Cannot Be Compiled"])
+    AC_MSG_WARN([$ac_header: proceeding with the preprocessor's result])
+    AC_MSG_WARN([$ac_header: in the future, the compiler will take precedence])
     m4_ifset([AC_PACKAGE_BUGREPORT],
     [( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
      ) | sed "s/^/$as_me: WARNING:     /" >&2])
     ;;
 esac
-AC_CACHE_CHECK([for $1], [ac_Header],
+AC_CACHE_CHECK([for $ac_header], [ac_Header],
               [AS_VAR_SET([ac_Header], [$ac_header_preproc])])
 ])dnl ! set ac_HEADER
-AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl
+AS_LINENO_POP
+])dnl
+ac_func_[]_AC_LANG_ABBREV[]_check_header_mongrel "$LINENO" "$1" 
"AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])"
+AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+AS_VAR_IF([ac_Header], [yes], [$2], [$3])dnl
 AS_VAR_POPDEF([ac_Header])dnl
 ])# _AC_CHECK_HEADER_MONGREL
 
@@ -153,13 +161,22 @@ AS_VAR_POPDEF([ac_Header])dnl
 #                     [INCLUDES = DEFAULT-INCLUDES])
 # --------------------------------------------------------------
 # Check the compiler accepts HEADER-FILE.  The INCLUDES are defaulted.
-m4_define([_AC_CHECK_HEADER_NEW],
-[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
-AC_CACHE_CHECK([for $1], [ac_Header],
-              [AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
address@hidden:@include <$1>])],
+AC_DEFUN([_AC_CHECK_HEADER_NEW],
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_new], [
+AS_LINENO_PUSH([$[]1])
+ac_header=[$]2
+ac_includes=[$]3
+AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$ac_header])dnl
+AC_CACHE_CHECK([for $ac_header], [ac_Header],
+              [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$ac_includes
address@hidden:@include <$ac_header>])],
                                  [AS_VAR_SET([ac_Header], [yes])],
                                  [AS_VAR_SET([ac_Header], [no])])])
+AS_VAR_POPDEF([ac_Header])
+AS_LINENO_POP
+])dnl
+ac_func_[]_AC_LANG_ABBREV[]_check_header_new "$LINENO" "$1" 
"AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])"
+AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
 AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([ac_Header])dnl
 ])# _AC_CHECK_HEADER_NEW
@@ -169,12 +186,18 @@ AS_VAR_POPDEF([ac_Header])dnl
 #                     [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # --------------------------------------------------------------
 # Check the preprocessor accepts HEADER-FILE.
-m4_define([_AC_CHECK_HEADER_OLD],
-[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
-AC_CACHE_CHECK([for $1], [ac_Header],
-              [AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include 
<$1>])],
-                                        [AS_VAR_SET([ac_Header], [yes])],
-                                        [AS_VAR_SET([ac_Header], [no])])])
+AC_DEFUN([_AC_CHECK_HEADER_OLD],
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_header_old], [
+ac_header=[$]1
+AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$ac_header])dnl
+AC_CACHE_CHECK([for $ac_header], [ac_Header],
+              [AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include 
<$ac_header>])],
+                                 [AS_VAR_SET([ac_Header], [yes])],
+                                 [AS_VAR_SET([ac_Header], [no])])])
+AS_VAR_POPDEF([ac_Header])
+])dnl
+ac_func_[]_AC_LANG_ABBREV[]_check_header_old "$1"
+AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
 AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([ac_Header])dnl
 ])# _AC_CHECK_HEADER_OLD
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index 0ab85a5..87794f2 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -146,20 +146,29 @@
 # C++ disallows defining types inside `sizeof ()', but that's OK,
 # since we don't want to consider unnamed structs to be types for C++,
 # precisely because they don't work in cases like that.
-m4_define([_AC_CHECK_TYPE_NEW],
-[AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
-AC_CACHE_CHECK([for $1], [ac_Type],
+AC_DEFUN([_AC_CHECK_TYPE_NEW],
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_type], [
+AS_LINENO_PUSH([$[]1])
+ac_type=[$]2
+ac_includes=[$]3
+AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$ac_type])dnl
+AC_CACHE_CHECK([for $ac_type], [ac_Type],
 [AS_VAR_SET([ac_Type], [no])
 AC_COMPILE_IFELSE(
-  [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
-     [if (sizeof ($1))
+  [AC_LANG_PROGRAM([$ac_includes],
+     [if (sizeof ($ac_type))
        return 0;])],
   [AC_COMPILE_IFELSE(
-     [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
-       [if (sizeof (($1)))
+     [AC_LANG_PROGRAM([$ac_includes],
+       [if (sizeof (($ac_type)))
          return 0;])],
      [],
      [AS_VAR_SET([ac_Type], [yes])])])])
+AS_VAR_POPDEF([ac_Type])dnl
+AS_LINENO_POP
+])dnl
+ac_func_[]_AC_LANG_ABBREV[]_check_type "$LINENO" "$1" 
"AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], ["])])"
+AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AS_VAR_IF([ac_Type], [yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([ac_Type])dnl
 ])# _AC_CHECK_TYPE_NEW
@@ -628,27 +637,36 @@ AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)])
 
 # _AC_TYPE_INT(NBITS)
 # -------------------
-AC_DEFUN([_AC_TYPE_INT],
-[
-  AC_CACHE_CHECK([for int$1_t], [ac_cv_c_int$1_t],
-    [ac_cv_c_int$1_t=no
-     for ac_type in 'int$1_t' 'int' 'long int' \
+AC_DEFUN([_AC_TYPE_INT_PREPARE],
+[AS_REQUIRE_SHELL_FN([ac_func_c_find_intX_t], [
+  AS_LINENO_PUSH([$[]1])
+  ac_width=[$]2
+  AS_VAR_PUSHDEF([ac_Type], [ac_cv_c_int${ac_width}_t])dnl
+  AC_CACHE_CHECK([for int${ac_width}_t], [ac_Type],
+    [AS_VAR_SET([ac_Type], [no])
+     for ac_type in 'int${ac_width}_t' 'int' 'long int' \
         'long long int' 'short int' 'signed char'; do
        AC_COMPILE_IFELSE(
         [AC_LANG_BOOL_COMPILE_TRY(
            [AC_INCLUDES_DEFAULT],
-           [[0 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)]])],
+           [[0 < ($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 
1)]])],
         [AC_COMPILE_IFELSE(
            [AC_LANG_BOOL_COMPILE_TRY(
               [AC_INCLUDES_DEFAULT],
-              [[($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)
-                < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 2)]])],
+              [[($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 1)
+                < ($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 
2)]])],
            [],
-           [AS_CASE([$ac_type], [int$1_t],
-              [ac_cv_c_int$1_t=yes],
-              [ac_cv_c_int$1_t=$ac_type])])])
-       test "$ac_cv_c_int$1_t" != no && break
+           [AS_CASE([$ac_type], [int${ac_width}_t],
+              [AS_VAR_SET([ac_Type], [yes])],
+              [AS_VAR_SET([ac_Type], [$ac_type])])])])
+       AS_VAR_IF([ac_Type], [no], [], [break])
      done])
+  AS_LINENO_POP
+])])
+
+AC_DEFUN([_AC_TYPE_INT],
+[AC_REQUIRE([_AC_TYPE_INT_PREPARE])
+  ac_func_c_find_intX_t "$LINENO" "$1"
   case $ac_cv_c_int$1_t in #(
   no|yes) ;; #(
   *)
@@ -660,21 +678,30 @@ AC_DEFUN([_AC_TYPE_INT],
 
 # _AC_TYPE_UNSIGNED_INT(NBITS)
 # ----------------------------
-AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
-[
-  AC_CACHE_CHECK([for uint$1_t], [ac_cv_c_uint$1_t],
-    [ac_cv_c_uint$1_t=no
-     for ac_type in 'uint$1_t' 'unsigned int' 'unsigned long int' \
+AC_DEFUN([_AC_TYPE_UNSIGNED_INT_PREPARE],
+[AS_REQUIRE_SHELL_FN([ac_func_c_find_uintX_t], [
+  AS_LINENO_PUSH([$[]1])
+  ac_width=[$]2
+  AS_VAR_PUSHDEF([ac_Type], [ac_cv_c_uint${ac_width}_t])dnl
+  AC_CACHE_CHECK([for uint${ac_width}_t], ac_Type,
+    [AS_VAR_SET([ac_Type], [no])
+     for ac_type in 'uint${ac_width}_t' 'unsigned int' 'unsigned long int' \
         'unsigned long long int' 'unsigned short int' 'unsigned char'; do
        AC_COMPILE_IFELSE(
         [AC_LANG_BOOL_COMPILE_TRY(
            [AC_INCLUDES_DEFAULT],
-           [[($ac_type) -1 >> ($1 - 1) == 1]])],
-        [AS_CASE([$ac_type], [uint$1_t],
-           [ac_cv_c_uint$1_t=yes],
-           [ac_cv_c_uint$1_t=$ac_type])])
-       test "$ac_cv_c_uint$1_t" != no && break
+           [[($ac_type) -1 >> ($ac_width - 1) == 1]])],
+        [AS_CASE([$ac_type], [uint${ac_width}_t],
+           [AS_VAR_SET([ac_Type], [yes])],
+           [AS_VAR_SET([ac_Type], [$ac_type])])])
+       AS_VAR_IF([ac_Type], [no], [], [break])
      done])
+  AS_LINENO_POP
+])])
+
+AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
+[AC_REQUIRE([_AC_TYPE_UNSIGNED_INT_PREPARE])
+  ac_func_c_find_uintX_t "$LINENO" "$1"
   case $ac_cv_c_uint$1_t in #(
   no|yes) ;; #(
   *)
@@ -812,29 +839,36 @@ you adjust the code.])
 # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
 # variables are not a valid argument.
 AC_DEFUN([AC_CHECK_MEMBER],
-[AS_LITERAL_IF([$1], [],
-              [AC_FATAL([$0: requires literal arguments])])dnl
-m4_bmatch([$1], [\.], ,
-        [m4_fatal([$0: Did not see any dot in `$1'])])dnl
-AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
+[AS_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_member], [
+AS_LINENO_PUSH([$[]1])
+ac_aggr=[$]2
+ac_member=[$]3
+ac_includes=[$]4
+AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_${ac_aggr}_${ac_member}])dnl
 dnl Extract the aggregate name, and the member name
-AC_CACHE_CHECK([for $1], [ac_Member],
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
-[dnl AGGREGATE ac_aggr;
-static m4_bpatsubst([$1], [\..*]) ac_aggr;
-dnl ac_aggr.MEMBER;
-if (ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
+AC_CACHE_CHECK([for $ac_aggr.$ac_member], [ac_Member],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes],
+[static $ac_aggr ac_aggr;
+if (ac_aggr.$ac_member)
 return 0;])],
                [AS_VAR_SET([ac_Member], [yes])],
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
-[dnl AGGREGATE ac_aggr;
-static m4_bpatsubst([$1], [\..*]) ac_aggr;
-dnl sizeof ac_aggr.MEMBER;
-if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes],
+[static $ac_aggr ac_aggr;
+if (sizeof ac_aggr.$ac_member)
 return 0;])],
                [AS_VAR_SET([ac_Member], [yes])],
                [AS_VAR_SET([ac_Member], [no])])])])
-AS_VAR_IF([ac_Member], [yes], [$2], [$3])dnl
+AS_VAR_POPDEF([ac_Member])dnl
+AS_LINENO_POP
+])dnl
+AS_LITERAL_IF([$1], [],
+              [AC_FATAL([$0: requires literal arguments])])dnl
+m4_bmatch([$1], [\.], ,
+        [m4_fatal([$0: Did not see any dot in `$1'])])dnl
+ac_func_[]_AC_LANG_ABBREV[]_check_member "$LINENO" "m4_bpatsubst([$1], 
[\..*])" \
+       "m4_bpatsubst([$1], [^[^.]*\.])" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4], 
["])])"
+AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
+AS_VAR_IF([ac_Member], [yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([ac_Member])dnl
 ])# AC_CHECK_MEMBER
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]