autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH v3 4/4] autoconf: prefer an unrolled loop for trivial AC_CHECK_FU


From: Eric Blake
Subject: [PATCH v3 4/4] autoconf: prefer an unrolled loop for trivial AC_CHECK_FUNCS
Date: Thu, 3 Nov 2016 21:37:47 -0500

From: Paolo Bonzini <address@hidden>

An unrolled loop avoids the cost of spawning sed in AS_TR_SH and
AS_TR_CPP.  Prefer it if there is nothing in the second and third
argument of AC_CHECK_FUNCS and the first argument is a literal.

* lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Unroll loop if safe.
(_AC_CHECK_FUNCS): Move basic implementation here.

Signed-off-by: Paolo Bonzini <address@hidden>
Message-Id: <address@hidden>
[eblake: perform AC_CHECK_FUNCS_ONCE changes separately, use
dnl to reduce generated blank lines]
Signed-off-by: Eric Blake <address@hidden>
---
 lib/autoconf/functions.m4 | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 76824a2..a227cd4 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -88,12 +88,17 @@ m4_define([_AH_CHECK_FUNC],
 # `break' to stop the search.
 AC_DEFUN([AC_CHECK_FUNCS],
 [m4_map_args_w([$1], [_AH_CHECK_FUNC(], [)])]dnl
-[AS_FOR([AC_func], [ac_func], [$1],
-[AC_CHECK_FUNC(AC_func,
-              [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_func)) $2],
-              [$3])dnl])
+[m4_if([$2$3]AS_LITERAL_IF([$1], [[yes]], [[no]]), [yes],
+       [m4_map_args_w([$1], [_$0(], [)])],
+       [AS_FOR([AC_func], [ac_func], [$1], [_$0(AC_func, [$2], [$3])])])dnl
 ])# AC_CHECK_FUNCS

+m4_define([_AC_CHECK_FUNCS],
+[AC_CHECK_FUNC([$1],
+              [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]$1)) $2],
+              [$3])dnl
+])
+

 # _AC_CHECK_FUNC_ONCE(FUNCTION)
 # -----------------------------
-- 
2.7.4




reply via email to

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