From 76183791a41bf8777cbce94e1b899529dc98e124 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 21 Dec 2016 08:32:39 -0600 Subject: [PATCH] AC_CHECK_HEADERS_ONCE: hoist CPP name computation to m4 time Rather than perform a sed script on each element of the $ac_header_c_list to compute the corresponding CPP name, we can make the list store a series of triples of header names, shell-safe names, and CPP names all computed at m4 time. The resulting configure script is slightly larger based on how many headers are checked once, but also performs slightly faster. There is still a sed call in AC_CHECK_HEADER for computing the cache variable name; that will be dealt with next. That patch will also be the one that takes advantage of the shell-safe name. * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_ONCE): Track the shell and CPP name in the list... (_AC_HEADERS_EXPANSION): ...and rewrite the list walk to parse off triples of arguments, for fewer sed calls. Signed-off-by: Eric Blake --- lib/autoconf/headers.m4 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index f6264df2..98bfa809 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -195,8 +195,9 @@ AC_DEFUN([AC_CHECK_HEADERS], 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_]]_AC_LANG_ABBREV[[_list], [" $1"])]) -_AC_HEADERS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE( + [AS_VAR_APPEND([ac_header_]]_AC_LANG_ABBREV[[_list], + [" $1 ]AS_TR_SH([$1]) AS_TR_CPP([HAVE_$1])["])])]dnl +[_AC_HEADERS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE( [_AC_Header_]m4_translit([[$1]], [./-], [___]))]) @@ -219,8 +220,19 @@ AC_DEFUN([_AC_CHECK_HEADERS_ONCE], # AC_CHECK_HEADERS_ONCE while that language was active. m4_define([_AC_HEADERS_EXPANSION], [m4_ifndef([$0($1)], [m4_define([$0($1)])m4_divert_text([DEFAULTS], -[ac_header_$1_list=])AC_CHECK_HEADERS([$ac_header_$1_list], [], [], - [$ac_includes_default])])]) +[ac_header_$1_list=])ac_header= ac_cache= +for ac_item in $ac_header_$1_list +do + if test $ac_cache; then + AC_CHECK_HEADER([$ac_header], [AC_DEFINE_UNQUOTED([$ac_item])], + [], [$ac_includes_default]) + ac_header= ac_cache= + elif test $ac_header; then + ac_cache=$ac_item + else + ac_header=$ac_item + fi +done])]) -- 2.47.2