autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH v3 2/4] AC_CHECK_FUNCS_ONCE: hoist CPP name computation to m4 tim


From: Eric Blake
Subject: [PATCH v3 2/4] AC_CHECK_FUNCS_ONCE: hoist CPP name computation to m4 time
Date: Thu, 3 Nov 2016 21:37:45 -0500

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 <address@hidden>
---
 lib/autoconf/functions.m4 | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 7b98a06..b937b2c 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -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)
-- 
2.7.4




reply via email to

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