[Top][All Lists]
[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 07:04:27 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Paolo Bonzini on 11/11/2008 2:55 AM:
>> '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.
>
> Yeah, we have accumulated enough Autoconf speedup that we can definitely
> trade it for faster and more readable configure. BTW, if there is no \
> in the AC_DEFINE_UNQUOTED argument you could still use AS_ECHO with a
> different second argument, can't you?
Hmm, you have a point. First, consider:
AC_DEFINE_UNQUOTED([var], ["${foo-"bar blah"}"])
To preserve semantics in the conversion from unquoted here-doc to an echo,
that would have to be written:
AS_ECHO(["\"${foo-"bar blah"}\""])
So a simple AS_ESCAPE won't do the trick, and my original patch stuck with
a here-doc merely based on ". On the other hand, " can only have
non-AS_ESCAPE semantics if there is also '${', '$(', or '`' (not that '$('
will appear in any portable script), but there are also other problematic
sequences without " in those three cases:
AS_DEFINE_UNQUOTED([var], [${foo-`echo oops`}])
which AS_ESCAPE would render as:
AS_ECHO(["${foo-\`echo oops\`}"])
So I altered the filter to look for those three patterns rather than ",
with the nice side-effect that one case missed by my original patch:
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
is now converted to AS_ECHO. And while reviewing, I noticed some other
simplifications (rather than choosing between m4_expand or m4_quote based
on $1 in the second macro, I blindly call m4_expand in the first macro),
so here's the updated patch I'm planning on installing, after I run the
full testsuite:
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkkZkOoACgkQ84KuGfSFAYAPwACg2WaCufqZabMX48eQdN5DaX6W
W2IAn0tJ5aJVuV/QJv09Py4DzBYio3qC
=AGUZ
-----END PGP SIGNATURE-----
>From 33071fb4a77d4d062845107fd35d39524deb0122 Mon Sep 17 00:00:00 2001
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):
(Define to a 2000-byte string): Enhance tests to cover
AC_DEFINE_UNQUOTED.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 10 ++++++++++
lib/autoconf/general.m4 | 21 +++++++++++++++++----
tests/torture.at | 22 ++++++++++++++++------
3 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b28abcd..fc611ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-11-11 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):
+ (Define to a 2000-byte string): Enhance tests to cover
+ AC_DEFINE_UNQUOTED.
+
2008-11-10 Eric Blake <address@hidden>
Work around <=m4-1.4.9 bug in m4_format.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 15377cb..7c8fe6b 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2090,13 +2090,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], m4_expand(address@hidden:@define] $2 ]m4_if([$#], 2, 1,
+ [$3], [], [/**/], [[$3]])))])
+
+# _AC_DEFINE_Q_PRINT(QUOTE, STRING)
+# ---------------------------------
+# Append the pre-expanded 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([[$2]])"]) >>confdefs.h],
+ [m4_bregexp([$2], [\$(\|\${\|`])], [-1],
+ [AS_ECHO(["AS_ESCAPE([$2], [""])"]) >>confdefs.h],
+ [cat >>confdefs.h <<_ACEOF
+[$2]
+_ACEOF])
])
-
## -------------------------- ##
## Setting output variables. ##
## -------------------------- ##
diff --git a/tests/torture.at b/tests/torture.at
index 586d0f8..a68657f 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@
@@ -800,7 +804,8 @@ AT_DATA([Zardoz.in], address@hidden@
])
AT_CONFIGURE_AC(
-[[foo="AS@&address@hidden([[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\
!]])"
+[[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])]])
@@ -834,7 +841,7 @@ AT_CHECK_AUTOHEADER
# Check both awk and the result of AC_PROG_AWK
for awk_arg in FOO= AWK=awk; do
AT_CHECK_CONFIGURE([$awk_arg])
- AT_CHECK([cat Foo], 0, [[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
+ AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
@foo@ @baz@@address@hidden stray @ and more@@bla
address@hidden@ @address@hidden@baz
address@hidden@ @address@hidden
@@ -849,7 +856,9 @@ address@hidden@
]])
AT_CHECK([cmp allowed-chars Zardoz])
AT_CHECK_DEFINES([[#define bar %!_!# X
-#define foo X*'[]+ ",& &`\($foo !
+#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
- Use newer m4_map_args_{w,sep}, Eric Blake, 2008/11/07
- Re: Use newer m4_map_args_{w,sep}, Eric Blake, 2008/11/10
- Re: Use newer m4_map_args_{w,sep}, Paolo Bonzini, 2008/11/10
- Re: Use newer m4_map_args_{w,sep}, Eric Blake, 2008/11/10
- Re: Use newer m4_map_args_{w,sep}, Paolo Bonzini, 2008/11/11
- Re: Use newer m4_map_args_{w,sep},
Eric Blake <=
- Re: Use newer m4_map_args_{w,sep}, Paolo Bonzini, 2008/11/11
- Re: Use newer m4_map_args_{w,sep}, Eric Blake, 2008/11/11
- Re: Use newer m4_map_args_{w,sep}, Eric Blake, 2008/11/11
- Re: Use newer m4_map_args_{w,sep}, Ralf Wildenhues, 2008/11/12
- Re: Use newer m4_map_args_{w,sep}, Paolo Bonzini, 2008/11/12
- Re: Use newer m4_map_args_{w,sep}, Eric Blake, 2008/11/12
- Re: Use newer m4_map_args_{w,sep}, Paolo Bonzini, 2008/11/12
- Re: Use newer m4_map_args_{w,sep}, Ben Pfaff, 2008/11/13
- Re: Use newer m4_map_args_{w,sep}, Paolo Bonzini, 2008/11/13
- m4_chomp [was: Use newer m4_map_args_{w,sep}], Eric Blake, 2008/11/13