autoconf-patches
[Top][All Lists]
Advanced

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

Faster AC_CHECK_{HEADERS,FUNCS}


From: Eric Blake
Subject: Faster AC_CHECK_{HEADERS,FUNCS}
Date: Thu, 13 Nov 2008 21:17:50 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

It is amazing how often people use AC_CHECK_{HEADERS,FUNCS} with a single 
argument (because it provides an automatic AC_DEFINE not present with with 
singular version).  This low-hanging fruit makes autoconf run slightly faster, 
shaves off 10k of coreutils' configure size, and produces 4 fewer forks per 
single-argument loop in the output file; an all-around win.  I intentinally 
left the for loop still in place in the shell, so as not to cripple any 
existing users where ACTION-IF-PASS or ACTION-IF-FAIL used break or the 
undocumented $ac_{header,func}.  I'm pushing this now.

From: Eric Blake <address@hidden>
Date: Thu, 13 Nov 2008 14:02:51 -0700
Subject: [PATCH] Optimize single-argument loop.

* lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Avoid forks when
loop only has one argument.
* lib/autoconf/headers.m4 (AC_CHECK_HEADERS): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                 |    7 +++++++
 lib/autoconf/functions.m4 |    8 +++++---
 lib/autoconf/headers.m4   |    8 +++++---
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3e9a701..31dd4f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-11-13  Eric Blake  <address@hidden>
 
+       Optimize single-argument loop.
+       * lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Avoid forks when
+       loop only has one argument.
+       * lib/autoconf/headers.m4 (AC_CHECK_HEADERS): Likewise.
+
+2008-11-13  Eric Blake  <address@hidden>
+
        Fix AS_ESCAPE usage bugs.
        * lib/m4sugar/m4sh.m4 (_AS_VAR_APPEND_PREPARE)
        (_AS_VAR_ARITH_PREPARE): Expand macros prior to adding shell
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 23c6348..da39fb1 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -108,13 +108,15 @@ m4_define([_AH_CHECK_FUNC],
 # `break' to stop the search.
 AC_DEFUN([AC_CHECK_FUNCS],
 [m4_map_args_w([$1], [_AH_CHECK_FUNC(], [)])]dnl
+[m4_pushdef([AC_func], m4_if(m4_index(m4_translit([$1], [      ][
+$`], [    ]), [ ]), [-1], [[$1]], [[$ac_func]]))]dnl
 [for ac_func in $1
 do
-AC_CHECK_FUNC($ac_func,
-             [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2],
+AC_CHECK_FUNC(AC_func,
+             [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_func)) $2],
              [$3])dnl
 done
-])
+_m4_popdef([AC_func])])
 
 
 # _AC_CHECK_FUNC_ONCE(FUNCTION)
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index eb6bc01..b2f7a21 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -245,14 +245,16 @@ m4_define([_AH_CHECK_HEADER],
 # header.  Either ACTION may include `break' to stop the search.
 AC_DEFUN([AC_CHECK_HEADERS],
 [m4_map_args_w([$1], [_AH_CHECK_HEADER(], [)])]dnl
+[m4_pushdef([AC_header], m4_if(m4_index(m4_translit([$1], [    ][
+$`], [    ]), [ ]), [-1], [[$1]], [[$ac_header]]))]dnl
 [for ac_header in $1
 do
-AC_CHECK_HEADER($ac_header,
-               [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_header)) $2],
+AC_CHECK_HEADER(AC_header,
+               [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_header)) $2],
                [$3],
                [$4])dnl
 done
-])# AC_CHECK_HEADERS
+_m4_popdef([AC_header])])# AC_CHECK_HEADERS
 
 
 # _AC_CHECK_HEADER_ONCE(HEADER-FILE)
-- 
1.6.0.2







reply via email to

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