autoconf-patches
[Top][All Lists]
Advanced

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

Re: Use newer m4_map_args_{w,sep}


From: Eric Blake
Subject: Re: Use newer m4_map_args_{w,sep}
Date: Tue, 11 Nov 2008 00:23:21 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Paolo Bonzini <bonzini <at> gnu.org> writes:

> 
> 
> > I'm also debating about improving AC_DEFINE (always) and AC_DEFINE_UNQUOTED 
> > (when there are no ") to use AS_ECHO rather than a here-doc, to avoid the 
> > forking of cat processes while building confdefs.h.
> 
> Just benchmark it and you'll know if it is worthwhile...

            'autoconf -f'  './config.status --recheck'   size
Pre-patch:  9.984s         8m42.414s                     977990
Post-patch: 10.081s        8m3.106s                      973966

In my mind, the small slowdown in autoconf is tolerable in comparison to the 
speedup in configure.  Thoughts before I apply this?



From: Eric Blake <address@hidden>
Date: Mon, 10 Nov 2008 17:14:37 -0700
Subject: [PATCH] Reduce forks in AC_DEFINE.

* lib/autoconf/general.m4 (_AC_DEFINE_Q_PRINT): New macro.
(_AC_DEFINE_Q): Use it to avoid forks for all AC_DEFINE and most
AC_DEFINE_UNQUOTED.
* tests/torture.at (Substitute and define special characters):
Enhance test to cover AC_DEFINE_UNQUOTED.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |    9 +++++++++
 lib/autoconf/general.m4 |   21 +++++++++++++++++----
 tests/torture.at        |   16 +++++++++++++---
 3 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8a06cbf..f7a6871 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-11-10  Eric Blake  <address@hidden>
 
+       Reduce forks in AC_DEFINE.
+       * lib/autoconf/general.m4 (_AC_DEFINE_Q_PRINT): New macro.
+       (_AC_DEFINE_Q): Use it to avoid forks for all AC_DEFINE and most
+       AC_DEFINE_UNQUOTED.
+       * tests/torture.at (Substitute and define special characters):
+       Enhance test to cover AC_DEFINE_UNQUOTED.
+
+2008-11-10  Eric Blake  <address@hidden>
+
        Yet more FDL 1.3 fallout.
        * NEWS: Mention manual license change.
 
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 2c184fc..8c561ce 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2088,13 +2088,26 @@ m4_define([_AC_DEFINE_Q],
 [: `$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
+[$0_PRINT([$1],
address@hidden:@define] $2 ]m4_if([$#], 2, 1, [$3], [], [/**/], [[$3]]))])
+
+# _AC_DEFINE_Q_PRINT(QUOTE, STRING)
+# ---------------------------------
+# Append STRING and a trailing newline to confdefs.h, as if by a
+# here-doc with QUOTE determining whether the here-doc is quoted.
+# However, since using cat on a here-doc involves forking, try to use
+# AS_ECHO when possible.
+m4_define([_AC_DEFINE_Q_PRINT],
+[m4_cond([[$1]], [\],
+  [AS_ECHO(["AS_ESCAPE(m4_expand([$2]))"]) >> confdefs.h],
+        [m4_index(m4_quote($2), ["])], [-1],]dnl "
+[[AS_ECHO(["$2"]) >> confdefs.h],
+  [cat >>confdefs.h <<$1_ACEOF
+$2
+_ACEOF])
 ])
 
 
-
 ## -------------------------- ##
 ## Setting output variables.  ##
 ## -------------------------- ##
diff --git a/tests/torture.at b/tests/torture.at
index 586d0f8..329493f 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -756,16 +756,19 @@ AT_CLEANUP
 ## ------------------------------ ##
 
 AT_SETUP([Define to a 2000-byte string])
+AT_KEYWORDS([AC@&address@hidden AC@&address@hidden)
 
 AT_CONFIGURE_AC(
 [[
-AC_DEFINE([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
+AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
+AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
 ]])
 
 AT_CHECK_AUTOCONF
 AT_CHECK_AUTOHEADER
 AT_CHECK_CONFIGURE
 AT_CHECK_DEFINES(address@hidden:@define foo m4_for([n], 1, 100,, 
....................)
address@hidden:@define fooq m4_for([n], 1, 100,, ....................)
 ])
 AT_CLEANUP
 
@@ -777,6 +780,7 @@ AT_CLEANUP
 # Use characters special to the shell, sed, awk, and M4.
 
 AT_SETUP([Substitute and define special characters])
+AT_KEYWORDS([AC@&address@hidden AC@&address@hidden)
 
 AT_DATA([Foo.in], address@hidden@
 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
@@ -801,6 +805,7 @@ AT_DATA([Zardoz.in], address@hidden@
 
 AT_CONFIGURE_AC(
 [[foo="AS@&address@hidden([[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ 
!]])"
+#"
 bar="@foo@ @baz@"
 baz=bla
 ( for i in 0 1 2 3; do
@@ -824,8 +829,10 @@ AC_SUBST([baz])
 AC_SUBST([zardoz])
 file=File
 AC_SUBST_FILE([file])
-AC_DEFINE([foo], [[X*'[]+ ",& &`\($foo !]], [Awful value.])
-AC_DEFINE([bar], [[%!_!# X]], [Value that is used as special delimiter.])
+AC_DEFINE([fooq], [[X*'[]+ ",& &`\($foo !]], [Awful value.])
+AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
+AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ",& &\`\\(\$foo !]], [Awful value.])
+AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special 
delimiter.])
 AC_PROG_AWK
 AC_CONFIG_FILES([Foo Zardoz])]])
 
@@ -849,7 +856,9 @@ address@hidden@
 ]])
   AT_CHECK([cmp allowed-chars Zardoz])
   AT_CHECK_DEFINES([[#define bar %!_!# X
+#define barq %!_!# X
 #define foo X*'[]+ ",& &`\($foo !
+#define fooq X*'[]+ ",& &`\($foo !
 ]])
 done
 AT_CLEANUP
@@ -900,6 +909,7 @@ AT_CLEANUP
 ## ------------------ ##
 
 AT_SETUP([Define a newline])
+AT_KEYWORDS([AC@&address@hidden AC@&address@hidden)
 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
 two], [This spans two lines.])
 ]])
-- 
1.6.0.2







reply via email to

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