[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/3] autoconf: prefer an unrolled loop for trivial AC_CHECK_FU
From: |
Paolo Bonzini |
Subject: |
[PATCH v2 1/3] autoconf: prefer an unrolled loop for trivial AC_CHECK_FUNCS |
Date: |
Mon, 31 Oct 2016 18:08:06 +0100 |
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.
Modify AC_CHECK_FUNCS_ONCE to avoid the variable indirection too.
* lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Unroll loop if safe.
(_AC_CHECK_FUNCS): Move basic implementation here.
(_AC_CHECK_FUNC_ONCE): Expand AC_CHECK_FUNCS here...
(_AC_FUNCS_EXPANSION): ... and not here, so remove.
Signed-off-by: Paolo Bonzini <address@hidden>
---
lib/autoconf/functions.m4 | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 66abe29..ccfb053 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -85,20 +85,24 @@ 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])])])
])# AC_CHECK_FUNCS
+m4_define([_AC_CHECK_FUNCS],
+[AC_CHECK_FUNC([$1],
+ [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]$1)) $2],
+ [$3])
+])
+
# _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_DEFUN([_AC_Func_$1], [AC_CHECK_FUNCS([$1])])
+AC_REQUIRE([_AC_Func_$1])])
# AC_CHECK_FUNCS_ONCE(FUNCTION...)
# --------------------------------
@@ -107,13 +111,6 @@ _AC_FUNCS_EXPANSION])AC_REQUIRE([_AC_Func_$1])])
AC_DEFUN([AC_CHECK_FUNCS_ONCE],
[m4_map_args_w([$1], [_AC_CHECK_FUNC_ONCE(], [)])])
-m4_define([_AC_FUNCS_EXPANSION],
-[
- m4_divert_text([DEFAULTS], [ac_func_list=])
- AC_CHECK_FUNCS([$ac_func_list])
- m4_define([_AC_FUNCS_EXPANSION], [])
-])
-
# _AC_REPLACE_FUNC(FUNCTION)
# --------------------------
--
2.7.4