]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_CHECK_FUNCS_ONCE: hoist CPP name computation to m4 time
authorEric Blake <eblake@redhat.com>
Fri, 4 Nov 2016 01:03:06 +0000 (20:03 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 21 Dec 2016 14:32:36 +0000 (08:32 -0600)
Rather than perform a sed script on each element of the
$ac_func_c_list to compute the corresponding CPP name, we can
make the list store a series of pairs of function names and
CPP names all computed at m4 time.

The resulting configure script is slightly larger based on
how many function names are checked once, but also performs
slightly faster.

There is still a sed call in AC_CHECK_FUNC for computing the
cache variable name; that will be dealt with next.

* lib/autoconf/functions.m4 (_AC_CHECK_FUNC_ONCE): Track the CPP
name in the list...
(_AC_FUNCS_EXPANSION): ...and rewrite the list walk to parse off
pairs of arguments, for fewer sed calls.

Signed-off-by: Eric Blake <eblake@redhat.com>
lib/autoconf/functions.m4

index 7b98a0664a03ba5730f7ce20509b149dd0bfe198..b937b2ccbb802bb1c79619d7ad6cf93276130fd7 100644 (file)
@@ -97,8 +97,9 @@ AC_DEFUN([AC_CHECK_FUNCS],
 # 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_]]_AC_LANG_ABBREV[[_list], [" $1"])])
-_AC_FUNCS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE([_AC_Func_$1])])
+  [AS_VAR_APPEND([ac_func_]]_AC_LANG_ABBREV[[_list],
+  [" $1 ]AS_TR_CPP([HAVE_$1])["])])]dnl
+[_AC_FUNCS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE([_AC_Func_$1])])
 
 # AC_CHECK_FUNCS_ONCE(FUNCTION...)
 # --------------------------------
@@ -113,7 +114,16 @@ AC_DEFUN([AC_CHECK_FUNCS_ONCE],
 # AC_CHECK_FUNCS_ONCE while that language was active.
 m4_define([_AC_FUNCS_EXPANSION],
 [m4_ifndef([$0($1)], [m4_define([$0($1)])m4_divert_text([DEFAULTS],
-[ac_func_$1_list=])AC_CHECK_FUNCS([$ac_func_$1_list])])])
+[ac_func_$1_list=])ac_func=
+for ac_item in $ac_func_$1_list
+do
+  if test $ac_func; then
+    AC_CHECK_FUNC([$ac_func], [AC_DEFINE_UNQUOTED([$ac_item])])
+    ac_func=
+  else
+    ac_func=$ac_item
+  fi
+done])])
 
 
 # _AC_REPLACE_FUNC(FUNCTION)