autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 09/12] use a shell function for AC_CHECK_TYPE


From: Eric Blake
Subject: Re: [PATCH 09/12] use a shell function for AC_CHECK_TYPE
Date: Sat, 01 Nov 2008 10:55:26 -0600
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 Eric Blake on 11/1/2008 10:51 AM:
> What do you think of this patch?  It doesn't reduce the size of configure
> much (now that a single shell function body is the only place where this
> is expanded), but does remove two cat processes.  On the other hand, it
> adds an rm process, so I only see a net drop of one process per type
> check.  Maybe we can still figure out a slicker way to reduce the number
> of rm processes.

(aargh - twice this week I hit send before save)

- --
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

iEYEARECAAYFAkkMif4ACgkQ84KuGfSFAYDEhQCgo8JkU9m66bswRbUdRDVPR1wm
wlwAoKGjlRGCSeLGRX3sg+1zbA0mjGMK
=yvYi
-----END PGP SIGNATURE-----
>From 4ee7ab33b507774472f6a96ffb61c9b6975eb8a1 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Sat, 1 Nov 2008 10:50:39 -0600
Subject: [PATCH] Reduce forks in AC_CHECK_TYPE.

* lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW_BODY): Only build one
test program, by manipulating compile flags.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog             |    6 ++++++
 lib/autoconf/types.m4 |   26 ++++++++++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1b34e3e..ba51617 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-01  Eric Blake  <address@hidden>
+
+       Reduce forks in AC_CHECK_TYPE.
+       * lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW_BODY): Only build one
+       test program, by manipulating compile flags.
+
 2008-10-31  Paolo Bonzini  <address@hidden>
 
        Rename _AC_CHECK_HEADER_OLD and _AC_CHECK_HEADER_NEW.
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index 6360d40..d02e174 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -143,20 +143,30 @@
 # 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.
+#
+# It costs fewer forks to build one program that gets compiled twice,
+# with different CFLAGS.
 m4_define([_AC_CHECK_TYPE_NEW_BODY],
 [  AS_LINENO_PUSH([$[]1])
   AC_CACHE_CHECK([for $[]2], [$[]3],
   [AS_VAR_SET([$[]3], [no])
-  AC_COMPILE_IFELSE(
+  AC_LANG_CONFTEST(
     [AC_LANG_PROGRAM([$[]4],
-       [if (sizeof ($[]2))
-        return 0;])],
-    [AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM([$[]4],
-         [if (sizeof (($[]2)))
-           return 0;])],
address@hidden:@ifndef ac_type_check2
+  if (sizeof ($[]2))
+    return 0;
address@hidden:@else
+  if (sizeof (($[]2)))
+    return 0;
address@hidden:@endif])])
+  AC_COMPILE_IFELSE([],
+    [ac_save_[]_AC_LANG_PREFIX[]FLAGS=$_AC_LANG_PREFIX[]FLAGS
+     _AC_LANG_PREFIX[]FLAGS="$_AC_LANG_PREFIX[]FLAGS -Dac_type_check2"
+     AC_COMPILE_IFELSE([],
        [],
-       [AS_VAR_SET([$[]3], [yes])])])])
+       [AS_VAR_SET([$[]3], [yes])])
+     _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX])
+  rm -f conftest.$ac_ext])
   AS_LINENO_POP
 ])dnl
 
-- 
1.6.0.2


reply via email to

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