autoconf-patches
[Top][All Lists]
Advanced

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

Use newer m4_map_args_{w,sep}


From: Eric Blake
Subject: Use newer m4_map_args_{w,sep}
Date: Fri, 7 Nov 2008 18:39:45 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

This patch series squeezes another 4% performance improvement out of autoconf 
(8.8 to 8.4 seconds on coreutils).  It also made coreutils' configure about 
2500 bytes smaller, and based on this diffstat:

 configure | 1944 ++++++++++++--------------------------------------------------
 1 file changed, 387 insertions(+), 1557 deletions(-)

most of that was in blank line removal and the condensed AC_CHECK_DECLS logic 
(expanding AC_DEFINE_UNQUOTED once instead of twice per DECL).  A lot of the 
series is just rewriting m4_foreach* into m4_map_args*, which avoides some 
m4_pushdef/m4_define/m4_popdef overhead while performing identical iteration, 
as well as providing some added safety against eating [] or $ in places that 
were previously expanding macros rather than using m4_defn.  Also, I did some 
rearranging of dnl to prune blank lines or occur outside macro definitions.

One of the cuter things in the last patch is the fact that:

m4_bpatsubst([$1], [:.*])

can be replaced by the more efficient

m4_format([[%.*s]], m4_index([$1], [:]), [$1])

as a way to truncate a string at the first :, if one is present.

This also fixes some typos in config.h.in; AC_CHECK_MEMBERS changed "is member 
of" to "is a member of", and AC_CHECK_FILE prints out the file name rather than 
AC_File.

Eric Blake (7):
      Use more efficient macro in AT_INIT.
      Use more efficient macros in AC_CHECK_FUNCS.
      Use more efficient macros in AC_CHECK_HEADERS.
      Use more efficient macros in AC_CHECK_TYPES.
      Use more efficient macros in AC_CHECK_FILES and AC_CHECK_DECLS.
      Use more efficient macros in AC_CONFIG_FILES.
      Avoid some regex uses.

Right now, this series is sitting on my curry branch (as it continues the work 
I started with m4_curry in making iteration more efficient).  I'll apply it in 
another day or so, unless I get comments first.

git fetch git://repo.or.cz/autoconf/ericb.git curry

>From 7f737e9a3e0de5e6a00349134ebc35f1d12b069b Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 6 Nov 2008 14:32:23 -0700
Subject: [PATCH] Use more efficient macro in AT_INIT.

* lib/autotest/general.m4 (AT_INIT): Use m4_map_args_sep.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |    5 +++++
 lib/autotest/general.m4 |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4f8bdd8..2a6c12e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-11-07  Eric Blake  <address@hidden>
 
+       Use more efficient macro in AT_INIT.
+       * lib/autotest/general.m4 (AT_INIT): Use m4_map_args_sep.
+
+2008-11-07  Eric Blake  <address@hidden>
+
        Further doc updates for AC_CHECK_HEADER change.
        * doc/autoconf.texi (Generic Headers) <AC_CHECK_HEADER>: Mention
        new default, and make it more obvious that using [-] is generally
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index d9e7089..db4b038 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -213,7 +213,7 @@ m4_define([AT_ordinal], 0)
 m4_define([AT_banner_ordinal], 0)
 m4_define([AT_groups_all], [])
 m4_define([AT_help_all], [])
-m4_foreach([AT_name], [_AT_DEFINE_INIT_LIST], [m4_popdef(m4_defn([AT_name]))])
+m4_map_args_sep([_m4_popdef(], [)], [], _AT_DEFINE_INIT_LIST)
 m4_wrap([_AT_FINISH])
 AS_INIT[]dnl
 dnl We don't use m4sh's BODY diversion, but AS_INIT sticks a banner there.
-- 
1.6.0.2


>From 93e3e8ba65edb1250647fe2c30498fa37b6bf747 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 6 Nov 2008 11:33:04 -0700
Subject: [PATCH] Use more efficient macros in AC_CHECK_FUNCS.

* lib/autoconf/functions.m4 (_AH_CHECK_FUNCS): Rename...
(_AH_CHECK_FUNC): ...and take only one argument, rather than a
list.
(AC_CHECK_FUNCS, AC_CHECK_FUNCS_ONCE): Adjust callers to use
m4_map_args_w.
(_AC_CHECK_FUNC_ONCE): New helper macro.
(AC_REPLACE_FUNCS): Use m4_map_args_w.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                 |    9 ++++++++
 lib/autoconf/functions.m4 |   46 ++++++++++++++++++++++++++------------------
 2 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a6c12e..c267bb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-11-07  Eric Blake  <address@hidden>
 
+       Use more efficient macros in AC_CHECK_FUNCS.
+       * lib/autoconf/functions.m4 (_AH_CHECK_FUNCS): Rename...
+       (_AH_CHECK_FUNC): ...and take only one argument, rather than a
+       list.
+       (AC_CHECK_FUNCS, AC_CHECK_FUNCS_ONCE): Adjust callers to use
+       m4_map_args_w.
+       (_AC_CHECK_FUNC_ONCE): New helper macro.
+       (AC_REPLACE_FUNCS): Use m4_map_args_w.
+
        Use more efficient macro in AT_INIT.
        * lib/autotest/general.m4 (AT_INIT): Use m4_map_args_sep.
 
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 0bc9299..23c6348 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -91,19 +91,24 @@ AS_VAR_IF([ac_var], [yes], [$2], [$3])
 AS_VAR_POPDEF([ac_var])])# AC_CHECK_FUNC
 
 
-# _AH_CHECK_FUNCS(FUNCTION...)
-# ----------------------------
-m4_define([_AH_CHECK_FUNCS],
-[m4_foreach_w([AC_Func], [$1],
-   [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Func])),
-      [Define to 1 if you have the `]m4_defn([AC_Func])[' function.])])])
+# _AH_CHECK_FUNC(FUNCTION)
+# ------------------------
+# Prepare the autoheader snippet for FUNCTION.
+m4_define([_AH_CHECK_FUNC],
+[AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
+  [Define to 1 if you have the `$1' function.])])
 
 
 # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # ---------------------------------------------------------------------
+# Check for each whitespace-separated FUNCTION, and perform
+# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND for each function.
+# Additionally, make the preprocessor definition HAVE_FUNCTION
+# available for each found function.  Either ACTION may include
+# `break' to stop the search.
 AC_DEFUN([AC_CHECK_FUNCS],
-[_AH_CHECK_FUNCS([$1])dnl
-for ac_func in $1
+[m4_map_args_w([$1], [_AH_CHECK_FUNC(], [)])]dnl
+[for ac_func in $1
 do
 AC_CHECK_FUNC($ac_func,
              [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2],
@@ -112,18 +117,21 @@ done
 ])
 
 
+# _AC_CHECK_FUNC_ONCE(FUNCTION)
+# -----------------------------
+# Check for a single FUNCTION once.
+m4_define([_AC_CHECK_FUNC_ONCE],
+[_AH_CHECK_FUNC([$1])AC_DEFUN([_AC_Func_$1],
+  [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_func_list], [" $1"])])
+_AC_FUNCS_EXPANSION])AC_REQUIRE([_AC_Func_$1])])
+
 # AC_CHECK_FUNCS_ONCE(FUNCTION...)
 # --------------------------------
+# Add each whitespace-separated name in FUNCTION to the list of functions
+# to check once.
 AC_DEFUN([AC_CHECK_FUNCS_ONCE],
-[
-  _AH_CHECK_FUNCS([$1])
-  m4_foreach_w([AC_Func], [$1],
-    [AC_DEFUN([_AC_Func_]m4_defn([AC_Func]),
-       [m4_divert_text([INIT_PREPARE],
-         [AS_VAR_APPEND([ac_func_list], [" AC_Func"])])
-       _AC_FUNCS_EXPANSION])
-     AC_REQUIRE([_AC_Func_]m4_defn([AC_Func]))])
-])
+[m4_map_args_w([$1], [_AC_CHECK_FUNC_ONCE(], [)])])
+
 m4_define([_AC_FUNCS_EXPANSION],
 [
   m4_divert_text([DEFAULTS], [ac_func_list=])
@@ -135,8 +143,8 @@ m4_define([_AC_FUNCS_EXPANSION],
 # AC_REPLACE_FUNCS(FUNCTION...)
 # -----------------------------
 AC_DEFUN([AC_REPLACE_FUNCS],
-[m4_foreach_w([AC_Func], [$1], [AC_LIBSOURCE(AC_Func.c)])dnl
-AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
+[m4_map_args_w([$1], [AC_LIBSOURCE(], [.c)])]dnl
+[AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
 ])
 
 
-- 
1.6.0.2


>From 742af4efd4813020a2fd319131a8b2f23198b068 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 6 Nov 2008 14:04:55 -0700
Subject: [PATCH] Use more efficient macros in AC_CHECK_HEADERS.

* lib/autoconf/headers.m4 (AH_CHECK_HEADERS)
(AH_CHECK_HEADERS_DIRENT): Rename...
(_AH_CHECK_HEADER, _AH_CHECK_HEADER_DIRENT): ...and take only one
argument, rather than a list.
(AC_CHECK_HEADERS, AC_CHECK_HEADERS_ONCE):
Adjust callers to use m4_map_args_w.
(AC_HEADER_DIRENT): Adjust caller to use m4_map_args.
(_AC_CHECK_HEADER_ONCE): New helper macro.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   10 +++++++
 lib/autoconf/headers.m4 |   63 +++++++++++++++++++++++++++-------------------
 2 files changed, 47 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c267bb3..c49146f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2008-11-07  Eric Blake  <address@hidden>
 
+       Use more efficient macros in AC_CHECK_HEADERS.
+       * lib/autoconf/headers.m4 (AH_CHECK_HEADERS)
+       (AH_CHECK_HEADERS_DIRENT): Rename...
+       (_AH_CHECK_HEADER, _AH_CHECK_HEADER_DIRENT): ...and take only one
+       argument, rather than a list.
+       (AC_CHECK_HEADERS, AC_CHECK_HEADERS_ONCE):
+       Adjust callers to use m4_map_args_w.
+       (AC_HEADER_DIRENT): Adjust caller to use m4_map_args.
+       (_AC_CHECK_HEADER_ONCE): New helper macro.
+
        Use more efficient macros in AC_CHECK_FUNCS.
        * lib/autoconf/functions.m4 (_AH_CHECK_FUNCS): Rename...
        (_AH_CHECK_FUNC): ...and take only one argument, rather than a
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 6802c38..eb6bc01 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -226,21 +226,26 @@ AS_VAR_POPDEF([ac_Header])dnl
 ])# _AC_CHECK_HEADER_PREPROC
 
 
-# AH_CHECK_HEADERS(HEADER-FILE...)
-# --------------------------------
-m4_define([AH_CHECK_HEADERS],
-[m4_foreach_w([AC_Header], [$1],
-  [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Header])),
-     [Define to 1 if you have the <]m4_defn([AC_Header])[> header file.])])])
+# _AH_CHECK_HEADER(HEADER-FILE)
+# -----------------------------
+# Prepare the autoheader snippet for HEADER-FILE.
+m4_define([_AH_CHECK_HEADER],
+[AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
+  [Define to 1 if you have the <$1> header file.])])
 
 
 # AC_CHECK_HEADERS(HEADER-FILE...,
 #                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                 [INCLUDES])
 # ----------------------------------------------------------
+# Check for each whitespace-separated HEADER-FILE (omitting the <> or
+# ""), and perform ACTION-IF-FOUND or ACTION-IF-NOT-FOUND for each
+# header.  INCLUDES is as for AC_CHECK_HEADER.  Additionally, make the
+# preprocessor definition HAVE_HEADER_FILE available for each found
+# header.  Either ACTION may include `break' to stop the search.
 AC_DEFUN([AC_CHECK_HEADERS],
-[AH_CHECK_HEADERS([$1])dnl
-for ac_header in $1
+[m4_map_args_w([$1], [_AH_CHECK_HEADER(], [)])]dnl
+[for ac_header in $1
 do
 AC_CHECK_HEADER($ac_header,
                [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_header)) $2],
@@ -250,18 +255,24 @@ done
 ])# AC_CHECK_HEADERS
 
 
+# _AC_CHECK_HEADER_ONCE(HEADER-FILE)
+# ----------------------------------
+# Check for a single HEADER-FILE once.
+m4_define([_AC_CHECK_HEADER_ONCE],
+[_AH_CHECK_HEADER([$1])AC_DEFUN([_AC_Header_]m4_translit([[$1]],
+    [./-], [___]),
+  [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_header_list], [" $1"])])
+_AC_HEADERS_EXPANSION])AC_REQUIRE([_AC_Header_]m4_translit([[$1]],
+    [./-], [___]))])
+
+
 # AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
 # -------------------------------------
+# Add each whitespace-separated name in HEADER-FILE to the list of
+# headers to check once.
 AC_DEFUN([AC_CHECK_HEADERS_ONCE],
-[
-  AH_CHECK_HEADERS([$1])
-  m4_foreach_w([AC_Header], [$1],
-    [AC_DEFUN([_AC_Header_]m4_quote(m4_translit(AC_Header, [./-], [___])),
-       [m4_divert_text([INIT_PREPARE],
-         [AS_VAR_APPEND([ac_header_list], [" AC_Header"])])
-       _AC_HEADERS_EXPANSION])
-     AC_REQUIRE([_AC_Header_]m4_quote(m4_translit(AC_Header, [./-], [___])))])
-])
+[m4_map_args_w([$1], [_AC_CHECK_HEADER_ONCE(], [)])])
+
 m4_define([_AC_HEADERS_EXPANSION],
 [
   m4_divert_text([DEFAULTS], [ac_header_list=])
@@ -454,20 +465,20 @@ AS_VAR_POPDEF([ac_Header])dnl
 ])# _AC_CHECK_HEADER_DIRENT
 
 
-# AH_CHECK_HEADERS_DIRENT(HEADERS...)
-# -----------------------------------
-m4_define([AH_CHECK_HEADERS_DIRENT],
-[m4_foreach_w([AC_Header], [$1],
-  [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Header])),
-              [Define to 1 if you have the <]m4_defn([AC_Header])[> header 
file, and
-               it defines `DIR'.])])])
+# _AH_CHECK_HEADER_DIRENT(HEADERS)
+# --------------------------------
+# Like _AH_CHECK_HEADER, but tuned to a dirent provider.
+m4_define([_AH_CHECK_HEADER_DIRENT],
+[AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
+  [Define to 1 if you have the <$1> header file, and it defines `DIR'.])])
 
 
 # AC_HEADER_DIRENT
 # ----------------
 AC_DEFUN([AC_HEADER_DIRENT],
-[AH_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h)
-ac_header_dirent=no
+[m4_map_args([_AH_CHECK_HEADER_DIRENT], [dirent.h], [sys/ndir.h],
+            [sys/dir.h], [ndir.h])]dnl
+[ac_header_dirent=no
 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
   _AC_CHECK_HEADER_DIRENT($ac_hdr,
                          [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_hdr), 1)
-- 
1.6.0.2


>From 98e06eb90aab3ced120157a0b32f3b44c8b8dd7e Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 6 Nov 2008 17:18:35 -0700
Subject: [PATCH] Use more efficient macros in AC_CHECK_TYPES.

* lib/autoconf/types.m4 (AC_CHECK_TYPES, AC_CHECK_MEMBERS): Use
m4_map_args_sep.
(_AC_CHECK_TYPES, _AC_CHECK_MEMBERS): New helper macros.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog             |    5 +++++
 lib/autoconf/types.m4 |   39 ++++++++++++++++++++++-----------------
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c49146f..fbc9f93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-11-07  Eric Blake  <address@hidden>
 
+       Use more efficient macros in AC_CHECK_TYPES.
+       * lib/autoconf/types.m4 (AC_CHECK_TYPES, AC_CHECK_MEMBERS): Use
+       m4_map_args_sep.
+       (_AC_CHECK_TYPES, _AC_CHECK_MEMBERS): New helper macros.
+
        Use more efficient macros in AC_CHECK_HEADERS.
        * lib/autoconf/headers.m4 (AH_CHECK_HEADERS)
        (AH_CHECK_HEADERS_DIRENT): Rename...
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index b8fc81a..b233591 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -181,6 +181,15 @@ AS_VAR_POPDEF([ac_Type])dnl
 ])# _AC_CHECK_TYPE_NEW
 
 
+# _AC_CHECK_TYPES(TYPE)
+# ---------------------
+# Helper to AC_CHECK_TYPES, which generates two of the four arguments
+# to _AC_CHECK_TYPE_NEW that are based on TYPE.
+m4_define([_AC_CHECK_TYPES],
+[[$1], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1],
+  [Define to 1 if the system has the type `$1'.])]])
+
+
 # AC_CHECK_TYPES(TYPES,
 #               [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #               [INCLUDES = DEFAULT-INCLUDES])
@@ -188,14 +197,8 @@ AS_VAR_POPDEF([ac_Type])dnl
 # TYPES is an m4 list.  There are no ambiguities here, we mean the newer
 # AC_CHECK_TYPE.
 AC_DEFUN([AC_CHECK_TYPES],
-[m4_foreach([AC_Type], [$1],
-  [_AC_CHECK_TYPE_NEW(AC_Type,
-                     [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Type), 1,
-                                         [Define to 1 if the system has the
-                                          type `]AC_Type['.])
-$2],
-                     [$3],
-                     [$4])])])
+[m4_map_args_sep([_AC_CHECK_TYPE_NEW(_$0(], [)[
+$2], [$3], [$4])], [], $1)])
 
 
 # _AC_CHECK_TYPE_OLD(TYPE, DEFAULT)
@@ -901,21 +904,23 @@ AS_VAR_POPDEF([ac_Member])dnl
 ])# AC_CHECK_MEMBER
 
 
+# _AC_CHECK_MEMBERS(AGGREGATE.MEMBER)
+# -----------------------------------
+# Helper to AC_CHECK_MEMBERS, which generates two of the four
+# arguments to AC_CHECK_MEMBER that are based on AGGREGATE and MEMBER.
+m4_define([_AC_CHECK_MEMBERS],
+[[$1], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1],
+  [Define to 1 if `]m4_bpatsubst([$1],
+    [^\([^.]*\)\.\(.*\)], [[\1' is a member of `\2]])['.])]])
+
 # AC_CHECK_MEMBERS([AGGREGATE.MEMBER, ...],
 #                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
 #                 [INCLUDES = DEFAULT-INCLUDES])
 # ---------------------------------------------------------
 # The first argument is an m4 list.
 AC_DEFUN([AC_CHECK_MEMBERS],
-[m4_foreach([AC_Member], [$1],
-  [AC_CHECK_MEMBER(AC_Member,
-        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1,
-                           [Define to 1 if `]m4_bpatsubst(AC_Member,
-                                                    [^[^.]*\.])[' is
-                            member of `]m4_bpatsubst(AC_Member, [\..*])['.])
-$2],
-                [$3],
-                [$4])])])
+[m4_map_args_sep([AC_CHECK_MEMBER(_$0(], [)[
+$2], [$3], [$4])], [], $1)])
 
 
 
-- 
1.6.0.2


>From 01ac36d251fa5293d0f0989beeec3ef1cac6b2d3 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 6 Nov 2008 21:40:18 -0700
Subject: [PATCH] Use more efficient macros in AC_CHECK_FILES and AC_CHECK_DECLS.

* lib/autoconf/general.m4 (AC_CHECK_FILES): Use m4_map_args_w,
and avoid typo.
(AC_CHECK_DECLS, AC_CHECK_DECLS_ONCE): Use m4_map_args_sep.
(_AC_CHECK_FILES, _AC_CHECK_DECLS, _AC_CHECK_DECL_ONCE): New
helper macros.
(AC_LIBSOURCES): Use m4_map_args.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |    8 ++++++
 lib/autoconf/general.m4 |   62 ++++++++++++++++++++++++++++-------------------
 2 files changed, 45 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fbc9f93..1c7f203 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2008-11-07  Eric Blake  <address@hidden>
 
+       Use more efficient macros in AC_CHECK_FILES and AC_CHECK_DECLS.
+       * lib/autoconf/general.m4 (AC_CHECK_FILES): Use m4_map_args_w,
+       and avoid typo.
+       (AC_CHECK_DECLS, AC_CHECK_DECLS_ONCE): Use m4_map_args_sep.
+       (_AC_CHECK_FILES, _AC_CHECK_DECLS, _AC_CHECK_DECL_ONCE): New
+       helper macros.
+       (AC_LIBSOURCES): Use m4_map_args.
+
        Use more efficient macros in AC_CHECK_TYPES.
        * lib/autoconf/types.m4 (AC_CHECK_TYPES, AC_CHECK_MEMBERS): Use
        m4_map_args_sep.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 4ae4d47..7911767 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2701,16 +2701,23 @@ AS_VAR_POPDEF([ac_File])dnl
 ])# AC_CHECK_FILE
 
 
+# _AC_CHECK_FILES(FILE)
+# ---------------------
+# Helper to AC_CHECK_FILES, which generates two of the three arguments
+# to AC_CHECK_FILE based on FILE.
+m4_define([_AC_CHECK_FILES],
+[[$1], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1],
+  [Define to 1 if you have the file `$1'.])]])
+
+
 # AC_CHECK_FILES(FILE..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # -----------------------------------------------------------------
+# For each word in the whitespace-separated FILE list, perform either
+# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.  For files that exist, also
+# provide the preprocessor variable HAVE_FILE.
 AC_DEFUN([AC_CHECK_FILES],
-[m4_foreach_w([AC_FILE_NAME], [$1],
-  [AC_CHECK_FILE(AC_FILE_NAME,
-                [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
-                                   [Define to 1 if you have the
-                                    file `]AC_File['.])
-$2],
-                [$3])])])
+[m4_map_args_w([$1], [AC_CHECK_FILE(_$0(], [)[
+$2], [$3])])])
 
 
 ## ------------------------------- ##
@@ -2753,6 +2760,19 @@ AS_VAR_POPDEF([ac_Symbol])dnl
 ])# AC_CHECK_DECL
 
 
+# _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
+#                 INCLUDES)
+# -------------------------------------------------------------
+# Helper to AC_CHECK_DECLS, which generates the check for a single
+# SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
+# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
+m4_define([_AC_CHECK_DECLS],
+[AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
+[AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_DECL_$1]), [$ac_have_decl],
+  [Define to 1 if you have the declaration of `$1',
+   and to 0 if you don't.])]dnl
+[m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])])
+
 # AC_CHECK_DECLS(SYMBOLS,
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                [INCLUDES = DEFAULT-INCLUDES])
@@ -2761,28 +2781,21 @@ AS_VAR_POPDEF([ac_Symbol])dnl
 # documentation for a detailed explanation of this difference with
 # other AC_CHECK_*S macros.  SYMBOLS is an m4 list.
 AC_DEFUN([AC_CHECK_DECLS],
-[m4_foreach([AC_Symbol], [$1],
-  [AC_CHECK_DECL(AC_Symbol,
-                [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_DECL_]AC_Symbol), 1,
-                                    [Define to 1 if you have the declaration
-                                    of `]AC_Symbol[', and to 0 if you don't.])
-$2],
-                [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_DECL_]AC_Symbol), 0)
-$3],
-                [$4])])
-])# AC_CHECK_DECLS
+[m4_map_args_sep([_$0(], [, [$2], [$3], [$4])], [], $1)])
 
 
+# _AC_CHECK_DECL_ONCE(SYMBOL)
+# ---------------------------
+# Check for a single SYMBOL once.
+m4_define([_AC_CHECK_DECL_ONCE],
+[AC_DEFUN([_AC_Check_Decl_$1], [_AC_CHECK_DECLS([$1])])]dnl
+[AC_REQUIRE([_AC_Check_Decl_$1])])
+
 # AC_CHECK_DECLS_ONCE(SYMBOLS)
 # ----------------------------
 # Like AC_CHECK_DECLS(SYMBOLS), but do it at most once.
 AC_DEFUN([AC_CHECK_DECLS_ONCE],
-[
-  m4_foreach([AC_Symbol], [$1],
-    [AC_DEFUN([_AC_Check_Decl_]m4_defn([AC_Symbol]),
-       [AC_CHECK_DECLS(m4_defn([AC_Symbol]))])
-     AC_REQUIRE([_AC_Check_Decl_]m4_defn([AC_Symbol]))])
-])
+[m4_map_args_sep([_AC_CHECK_DECL_ONCE(], [)], [], $1)])
 
 
 
@@ -2808,8 +2821,7 @@ m4_define([AC_LIBSOURCE], [])
 # -------------------------------
 # Announce we might need these files.
 AC_DEFUN([AC_LIBSOURCES],
-[m4_foreach([_AC_FILE_NAME], [$1],
-           [AC_LIBSOURCE(_AC_FILE_NAME)])])
+[m4_map_args([AC_LIBSOURCE], $1)])
 
 
 # _AC_LIBOBJ(FILE-NAME-NOEXT, ACTION-IF-INDIR)
-- 
1.6.0.2


>From 0bfd199b0b2419b4d05e948d7cb6a84687d1a003 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 7 Nov 2008 06:20:12 -0700
Subject: [PATCH] Use more efficient macros in AC_CONFIG_FILES.

* lib/autoconf/status.m4 (_AC_CONFIG_FOOS, AC_CONFIG_SUBDIRS): Use
m4_map_args_w.
(_AC_OUTPUT_FILE): Use m4_map_args_sep and m4_map_args.
(_AC_OUTPUT_FILE_ADJUST_DIR): New helper macro.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |    6 ++++
 lib/autoconf/status.m4 |   65 +++++++++++++++++++++++++-----------------------
 2 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1c7f203..3d0b4dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-11-07  Eric Blake  <address@hidden>
 
+       Use more efficient macros in AC_CONFIG_FILES.
+       * lib/autoconf/status.m4 (_AC_CONFIG_FOOS, AC_CONFIG_SUBDIRS): Use
+       m4_map_args_w.
+       (_AC_OUTPUT_FILE): Use m4_map_args_sep and m4_map_args.
+       (_AC_OUTPUT_FILE_ADJUST_DIR): New helper macro.
+
        Use more efficient macros in AC_CHECK_FILES and AC_CHECK_DECLS.
        * lib/autoconf/general.m4 (AC_CHECK_FILES): Use m4_map_args_w,
        and avoid typo.
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 2f6276a..f8e046f 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -238,13 +238,12 @@ m4_define([_AC_CONFIG_UNIQUE],
 # This historical difference allows macro calls in TAGS.
 #
 m4_define([_AC_CONFIG_FOOS],
-[m4_foreach_w([AC_File], [$2],
-             [_AC_CONFIG_REGISTER([$1], m4_defn([AC_File]), [$3])])dnl
-m4_define([_AC_SEEN_CONFIG(ANY)])dnl
-m4_define([_AC_SEEN_CONFIG($1)])dnl
-_AC_CONFIG_COMMANDS_INIT([$4])dnl
-ac_config_[]m4_tolower([$1])="$ac_config_[]m4_tolower([$1]) dnl
-m4_if([$1], [COMMANDS], [$2], [m4_normalize([$2])])"
+[m4_map_args_w([$2], [_AC_CONFIG_REGISTER([$1],], [, [$3])])]dnl
+[m4_define([_AC_SEEN_CONFIG(ANY)])]dnl
+[m4_define([_AC_SEEN_CONFIG($1)])]dnl
+[_AC_CONFIG_COMMANDS_INIT([$4])]dnl
+[ac_config_[]m4_tolower([$1])="$ac_config_[]m4_tolower([$1]) ]dnl
+[m4_if([$1], [COMMANDS], [$2], [m4_normalize([$2])])"
 ])
 
 
@@ -583,6 +582,13 @@ fi # test -n "$CONFIG_FILES"
 
 ])# _AC_OUTPUT_FILES_PREPARE
 
+# _AC_OUTPUT_FILE_ADJUST_DIR(VAR)
+# -------------------------------
+# Generate the sed snippet needed to output VAR relative to the
+# top-level directory.
+m4_define([_AC_OUTPUT_FILE_ADJUST_DIR],
+[s&@$1@&$ac_$1&;t t[]AC_SUBST_TRACE([$1])])
+
 
 # _AC_OUTPUT_FILE
 # ---------------
@@ -619,15 +625,15 @@ m4_ifndef([AC_DATAROOTDIR_CHECKED],
 # FIXME: This hack should be removed a few years after 2.60.
 ac_datarootdir_hack=; ac_datarootdir_seen=
 m4_define([_AC_datarootdir_vars],
-         [datadir, docdir, infodir, localedir, mandir])
-ac_sed_dataroot='
+         [datadir, docdir, infodir, localedir, mandir])]dnl
+[m4_define([_AC_datarootdir_subst], [  s&@$][1@&$$][1&g])]dnl
+[ac_sed_dataroot='
 /datarootdir/ {
   p
   q
 }
-m4_foreach([_AC_Var], m4_defn([_AC_datarootdir_vars]),
-          [/@_AC_Var@/p
-])'
+m4_map_args_sep([/@], [@/p], [
+], _AC_datarootdir_vars)'
 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
 *datarootdir*) ac_datarootdir_seen=yes;;
 address@hidden(address@hidden|address@hidden, _AC_datarootdir_vars)@*)
@@ -635,9 +641,8 @@ case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` 
in
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
   ac_datarootdir_hack='
-  m4_foreach([_AC_Var], m4_defn([_AC_datarootdir_vars]),
-              [s&@_AC_Var@&$_AC_Var&g
-  ])dnl
+m4_map_args_sep([_AC_datarootdir_subst(], [)], [
+], _AC_datarootdir_vars)
   s&\\\${datarootdir}&$datarootdir&g' ;;
 esac
 _ACEOF
@@ -662,11 +667,11 @@ dnl During the transition period, this is a special case:
 s&@top_builddir@&$ac_top_builddir_sub&;t t[]AC_SUBST_TRACE([top_builddir])
 dnl For this substitution see the witness macro _AC_HAVE_TOP_BUILD_PREFIX 
above.
 s&@top_build_prefix@&$ac_top_build_prefix&;t t[]AC_SUBST_TRACE
([top_build_prefix])
-m4_foreach([_AC_Var], [srcdir, abs_srcdir, top_srcdir, abs_top_srcdir,
-                       builddir, abs_builddir,
-                       abs_top_builddir]AC_PROVIDE_IFELSE([AC_PROG_INSTALL], 
[[, INSTALL]])AC_PROVIDE_IFELSE([AC_PROG_MKDIR_P], [[, MKDIR_P]]),
-          [s&@_AC_Var@&$ac_[]_AC_Var&;t t[]AC_SUBST_TRACE(_AC_Var)
-])dnl
+m4_map_args_sep([$0_ADJUST_DIR(], [)], [
+], [srcdir], [abs_srcdir], [top_srcdir], [abs_top_srcdir],
+   [builddir], [abs_builddir],
+   [abs_top_builddir]AC_PROVIDE_IFELSE([AC_PROG_INSTALL],
+     [, [INSTALL]])AC_PROVIDE_IFELSE([AC_PROG_MKDIR_P], [, [MKDIR_P]]))
 m4_ifndef([AC_DATAROOTDIR_CHECKED], [$ac_datarootdir_hack
 ])dnl
 "
@@ -1093,17 +1098,15 @@ m4_define([AC_OUTPUT_COMMANDS_POST])
 #   included, if for instance the user refused a part of the tree.
 #   This is used in _AC_OUTPUT_SUBDIRS.
 AC_DEFUN([AC_CONFIG_SUBDIRS],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])dnl
-m4_foreach_w([_AC_Sub], [$1],
-            [_AC_CONFIG_UNIQUE([SUBDIRS],
-                               m4_bpatsubst(m4_defn([_AC_Sub]), [:.*]))])dnl
-m4_append([_AC_LIST_SUBDIRS], [$1], [
-])dnl
-AS_LITERAL_IF([$1], [],
-             [AC_DIAGNOSE([syntax], [$0: you should use literals])])dnl
-AC_SUBST([subdirs], ["$subdirs m4_normalize([$1])"])dnl
-])
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])]dnl
+[AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])]dnl
+[m4_map_args_w([$1], [_AC_CONFIG_UNIQUE([SUBDIRS],
+  m4_bpatsubst(], [, [:.*]))])]dnl
+[m4_append([_AC_LIST_SUBDIRS], [$1], [
+])]dnl
+[AS_LITERAL_IF([$1], [],
+              [AC_DIAGNOSE([syntax], [$0: you should use literals])])]dnl
+[AC_SUBST([subdirs], ["$subdirs m4_normalize([$1])"])])
 
 
 # _AC_OUTPUT_SUBDIRS
-- 
1.6.0.2


>From f12026d8223ebd0bf2aa6b893c823e43b040984b Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 7 Nov 2008 07:11:01 -0700
Subject: [PATCH] Avoid some regex uses.

* lib/autoconf/general.m4 (_AC_DEFINE_Q): Use m4_format rather
than m4_bpatsubst to grab string prefix.
* lib/autoconf/status.m4 (_AC_CONFIG_REGISTER)
(_AC_CONFIG_REGISTER_DEST, AC_CONFIG_SUBDIRS): Likewise.
(_AC_FILE_DEPENDENCY_TRACE_COLON): Use m4_translit instead of
m4_bpatsubst to change bytes.
(_AC_CONFIG_DEPENDENCY_DEFAULT): Use m4_index rather than
m4_bmatch to find byte.
(_AC_CONFIG_COMPUTE_DEST): New helper macro.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   11 +++++++++++
 lib/autoconf/general.m4 |   22 +++++++++++-----------
 lib/autoconf/status.m4  |   31 +++++++++++++++++--------------
 3 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3d0b4dc..bbd4832 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2008-11-07  Eric Blake  <address@hidden>
 
+       Avoid some regex uses.
+       * lib/autoconf/general.m4 (_AC_DEFINE_Q): Use m4_format rather
+       than m4_bpatsubst to grab string prefix.
+       * lib/autoconf/status.m4 (_AC_CONFIG_REGISTER)
+       (_AC_CONFIG_REGISTER_DEST, AC_CONFIG_SUBDIRS): Likewise.
+       (_AC_FILE_DEPENDENCY_TRACE_COLON): Use m4_translit instead of
+       m4_bpatsubst to change bytes.
+       (_AC_CONFIG_DEPENDENCY_DEFAULT): Use m4_index rather than
+       m4_bmatch to find byte.
+       (_AC_CONFIG_COMPUTE_DEST): New helper macro.
+
        Use more efficient macros in AC_CONFIG_FILES.
        * lib/autoconf/status.m4 (_AC_CONFIG_FOOS, AC_CONFIG_SUBDIRS): Use
        m4_map_args_w.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 7911767..d7c48f5 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2073,22 +2073,22 @@ m4_define([AC_DEFINE_UNQUOTED], [_AC_DEFINE_Q([], $@)])
 # -----------------------------------------------------
 # Internal function that performs common elements of AC_DEFINE{,_UNQUOTED}.
 #
-# m4_index is roughly 5 to 8 times faster than m4_bpatsubst, so only
-# use the regex when necessary.  AC_name is defined with over-quotation,
-# so that we can avoid m4_defn.
+# m4_index is roughly 5 to 8 times faster than m4_bpatsubst, so we use
+# m4_format rather than regex to grab prefix up to first ().  AC_name
+# is defined with over-quotation, so that we can avoid m4_defn; this
+# is only safe because the name should not contain $.
 m4_define([_AC_DEFINE_Q],
-[m4_pushdef([AC_name], m4_if(m4_index([$2], [(]), [-1], [[[$2]]],
-                            [m4_bpatsubst([[[$2]]], [(.*)])]))dnl
-AC_DEFINE_TRACE(AC_name)dnl
-m4_cond([m4_index([$3], [
+[m4_pushdef([AC_name], m4_format([[[%.*s]]], m4_index([$2], [(]), [$2]))]dnl
+[AC_DEFINE_TRACE(AC_name)]dnl
+[m4_cond([m4_index([$3], [
 ])], [-1], [],
        [AS_LITERAL_IF([$3], [m4_bregexp([[$3]], [[^\\]
 ], [-])])], [], [],
        [m4_warn([syntax], [AC_DEFINE]m4_ifval([$1], [], [[_UNQUOTED]])dnl
-[: `$3' is not a valid preprocessor define value])])dnl
-m4_ifval([$4], [AH_TEMPLATE(AC_name, [$4])])dnl
-m4_popdef([AC_name])dnl
-cat >>confdefs.h <<$1_ACEOF
+[: `$3' is not a valid preprocessor define value])])]dnl
+[m4_ifval([$4], [AH_TEMPLATE(AC_name, [$4])])]dnl
+[_m4_popdef([AC_name])]dnl
+[cat >>confdefs.h <<$1_ACEOF
 address@hidden:@define] $2 m4_if([$#], 2, 1, [$3], [], [/**/], [$3])
 _ACEOF
 ])
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index f8e046f..388b90f 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -176,8 +176,7 @@ m4_define([AC_FILE_DEPENDENCY_TRACE], [])
 # Declare that DEST depends upon SOURCE1 etc.
 #
 m4_define([_AC_FILE_DEPENDENCY_TRACE_COLON],
-[AC_FILE_DEPENDENCY_TRACE(m4_bpatsubst([$1], [:], [,]))dnl
-])
+[AC_FILE_DEPENDENCY_TRACE(m4_translit([$1], [:], [,]))])
 
 
 # _AC_CONFIG_DEPENDENCY(MODE, DEST[:SOURCE1...])
@@ -205,12 +204,11 @@ m4_define([_AC_CONFIG_DEPENDENCY],
 #    (We get to this case from the obsolete AC_LINK_FILES, for example.)
 #
 m4_define([_AC_CONFIG_DEPENDENCY_DEFAULT],
-[m4_bmatch([$2], [:], [],
+[m4_if(m4_index([$2], [:]), [-1],
           [m4_if([$1], [LINKS],
                  [AS_LITERAL_IF([$2],
                    [m4_fatal([Invalid AC_CONFIG_LINKS tag: `$2'])])],
-                 [:$2.in])])dnl
-])
+                 [:$2.in])])])
 
 
 # _AC_CONFIG_UNIQUE(MODE, DEST)
@@ -246,6 +244,12 @@ m4_define([_AC_CONFIG_FOOS],
 [m4_if([$1], [COMMANDS], [$2], [m4_normalize([$2])])"
 ])
 
+# _AC_CONFIG_COMPUTE_DEST(STRING)
+# -------------------------------
+# Compute the DEST from STRING by stripping any : and following
+# characters.
+m4_define([_AC_CONFIG_COMPUTE_DEST],
+[m4_format([[%.*s]], m4_index([$1], [:]), [$1])])
 
 # _AC_CONFIG_REGISTER(MODE, TAG, [COMMANDS])
 # ------------------------------------------
@@ -254,9 +258,9 @@ m4_define([_AC_CONFIG_FOOS],
 m4_define([_AC_CONFIG_REGISTER],
 [m4_if([$1], [COMMANDS],
        [],
-       [_AC_CONFIG_DEPENDENCY([$1], [$2])])dnl
-_AC_CONFIG_REGISTER_DEST([$1], [$2], m4_bpatsubst([[$2]], [:.*\(.\)$], [\1]), 
[$3])dnl
-])
+       [_AC_CONFIG_DEPENDENCY([$1], [$2])])]dnl
+[_AC_CONFIG_REGISTER_DEST([$1], [$2],
+  _AC_CONFIG_COMPUTE_DEST([$2]), [$3])])
 
 
 # _AC_CONFIG_REGISTER_DEST(MODE, TAG, DEST, [COMMANDS])
@@ -281,15 +285,14 @@ dnl Recognize TAG as an argument to config.status:
 dnl
 [m4_append([_AC_LIST_TAGS],
 [    "$3") CONFIG_$1="$CONFIG_$1 $2" ;;
-])dnl
+])]dnl
 dnl
 dnl Register the associated commands, if any:
 dnl
-m4_ifval([$4],
+[m4_ifval([$4],
 [m4_append([_AC_LIST_TAG_COMMANDS],
-[    "$3":]m4_bpatsubst([$1], [^\(.\).*$], [\1])[) $4 ;;
-])])dnl
-])# _AC_CONFIG_REGISTER_DEST
+[    "$3":]m4_format([[%.1s]], [$1])[) $4 ;;
+])])])# _AC_CONFIG_REGISTER_DEST
 
 
 
@@ -1101,7 +1104,7 @@ AC_DEFUN([AC_CONFIG_SUBDIRS],
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])]dnl
 [AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])]dnl
 [m4_map_args_w([$1], [_AC_CONFIG_UNIQUE([SUBDIRS],
-  m4_bpatsubst(], [, [:.*]))])]dnl
+  _AC_CONFIG_COMPUTE_DEST(], [))])]dnl
 [m4_append([_AC_LIST_SUBDIRS], [$1], [
 ])]dnl
 [AS_LITERAL_IF([$1], [],
-- 
1.6.0.2







reply via email to

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