[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] autoconf: prefer an unrolled loop for trivial AC_CHECK_HEADE
From: |
Paolo Bonzini |
Subject: |
[PATCH 2/3] autoconf: prefer an unrolled loop for trivial AC_CHECK_HEADERS |
Date: |
Mon, 31 Oct 2016 12:39:12 +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_HEADERS and the first argument is a literal.
Modify AC_CHECK_HEADERS_ONCE to avoid the variable indirection too.
* lib/autoconf/headers.m4 (AC_CHECK_HEADERS): Unroll loop if safe.
(_AC_CHECK_HEADERS): Move basic implementation here.
(_AC_CHECK_HEADER_ONCE): Expand AC_CHECK_HEADERS here...
(_AC_HEADERS_EXPANSION): ... and not here, so remove.
(AC_CHECK_INCLUDES_DEFAULT): Remove unnecessary arguments after the first.
Signed-off-by: Paolo Bonzini <address@hidden>
---
lib/autoconf/headers.m4 | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 72262c1..e855025 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -182,22 +182,25 @@ m4_define([AH_CHECK_HEADERS],
# header. Either ACTION may include `break' to stop the search.
AC_DEFUN([AC_CHECK_HEADERS],
[m4_map_args_w([$1], [_AH_CHECK_HEADER(], [)])]dnl
-[AS_FOR([AC_header], [ac_header], [$1],
-[AC_CHECK_HEADER(AC_header,
- [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_header)) $2],
- [$3], [$4])dnl])
+[m4_if([$2$3]AS_LITERAL_IF([$1], [yes], [no]), []yes,
+ [m4_map_args_w([$1], [_$0(], [, [], [], [$4])])],
+ [AS_FOR([AC_header], [ac_header], [$1], [_$0(AC_header, [$2], [$3],
[$4])])])
])# AC_CHECK_HEADERS
+m4_define([_AC_CHECK_HEADERS],
+[AC_CHECK_HEADER([$1],
+ [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]$1)) $2],
+ [$3], [$4])
+])
+
# _AC_CHECK_HEADER_ONCE(HEADER-FILE)
# ----------------------------------
# Check for a single HEADER-FILE once.
m4_define([_AC_CHECK_HEADER_ONCE],
-[_AH_CHECK_HEADER([$1])AC_DEFUN([_AC_Header_]m4_translit([[$1]],
- [./-], [___]),
- [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_header_list], [" $1"])])
-_AC_HEADERS_EXPANSION])AC_REQUIRE([_AC_Header_]m4_translit([[$1]],
- [./-], [___]))])
+[AC_DEFUN([_AC_Header_]m4_translit([[$1]], [./-], [___]),
+ [AC_CHECK_HEADERS([$1], [], [], [$ac_includes_default])])
+AC_REQUIRE([_AC_Header_]m4_translit([[$1]], [./-], [___]))])
# AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
@@ -213,12 +216,6 @@ AC_DEFUN([AC_CHECK_HEADERS_ONCE],
AC_DEFUN([_AC_CHECK_HEADERS_ONCE],
[m4_map_args_w([$1], [_AC_CHECK_HEADER_ONCE(], [)])])
-m4_define([_AC_HEADERS_EXPANSION],
- [m4_divert_text([DEFAULTS], [ac_header_list=])]dnl
- [AC_CHECK_HEADERS([$ac_header_list], [], [], [$ac_includes_default])]dnl
- [m4_define([_AC_HEADERS_EXPANSION], [])])
-
-
## --------------------- ##
@@ -261,8 +258,7 @@ ac_includes_default="\
#endif"
])]dnl
[_AC_CHECK_HEADERS_ONCE(
- [sys/types.h sys/stat.h strings.h inttypes.h stdint.h unistd.h],
- [], [], [$ac_includes_default])]dnl
+ [sys/types.h sys/stat.h strings.h inttypes.h stdint.h unistd.h])]dnl
dnl For backward compatibility, provide unconditional AC_DEFINEs of
dnl HAVE_STDLIB_H, HAVE_STRING_H, and STDC_HEADERS.
[AC_DEFINE([HAVE_STDLIB_H], [1],
--
2.7.4