3 dnl Check whether -lm is available. This is a pre-requisite for
4 dnl GCC_CHECK_MATH_FUNC so that it will link with -lm.
5 AC_DEFUN([GCC_CHECK_LIBM],
6 [AC_CHECK_LIB([m],[sin])])
8 dnl GCC_CHECK_MATH_HEADERS
10 dnl Check for math.h and complex.h. This is a pre-requisite for
11 dnl GCC_CHECK_MATH_FUNC so that it includes the right headers.
12 dnl (Some systems, such as AIX or OpenVMS may define macro for math
14 AC_DEFUN([GCC_CHECK_MATH_HEADERS],
15 [AC_CHECK_HEADERS_ONCE(math.h complex.h)])
17 dnl GCC_CHECK_MATH_FUNC([name])
19 dnl Check whether math function NAME is available on the system (by compiling
20 dnl and linking a C program) and run define HAVE_name on success.
22 dnl Note that OpenVMS system insists on including complex.h before math.h
23 AC_DEFUN([GCC_CHECK_MATH_FUNC],
25 AC_REQUIRE([GCC_CHECK_LIBM])
26 AC_REQUIRE([GCC_CHECK_MATH_HEADERS])
27 AC_CACHE_CHECK([for $1], [gcc_cv_math_func_$1],
28 [AC_LINK_IFELSE([AC_LANG_SOURCE([
36 int (*ptr)() = (int (*)())$1;
44 [gcc_cv_math_func_$1=yes],
45 [gcc_cv_math_func_$1=no])])
46 if test $gcc_cv_math_func_$1 = yes; then
47 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1),[1],
48 [Define to 1 if you have the `$1' function.])
52 dnl GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1([name], [type])
54 dnl Check if math function NAME fallback for function with single
55 dnl TYPE argument and TYPE result can be implemented using
56 dnl __builtin_NAME expanded inline without needing unavailable math
58 AC_DEFUN([GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1],
60 AC_REQUIRE([GCC_CHECK_LIBM])
61 if test $gcc_cv_math_func_$1 = no; then
62 AC_CACHE_CHECK([for inline __builtin_$1], [gcc_cv_math_inline_builtin_$1],
63 [AC_LINK_IFELSE([AC_LANG_SOURCE([
67 return __builtin_$1 (x);
76 [gcc_cv_math_inline_builtin_$1=yes],
77 [gcc_cv_math_inline_builtin_$1=no])])
78 if test $gcc_cv_math_inline_builtin_$1 = yes; then
79 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_INLINE_BUILTIN_$1),[1],
80 [Define to 1 if `__builtin_$1' is expanded inline.])
84 dnl GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2([name], [type])
86 dnl Check if math function NAME fallback for function with two
87 dnl TYPE arguments and TYPE result can be implemented using
88 dnl __builtin_NAME expanded inline without needing unavailable math
90 AC_DEFUN([GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2],
92 AC_REQUIRE([GCC_CHECK_LIBM])
93 if test $gcc_cv_math_func_$1 = no; then
94 AC_CACHE_CHECK([for inline __builtin_$1], [gcc_cv_math_inline_builtin_$1],
95 [AC_LINK_IFELSE([AC_LANG_SOURCE([
97 $1_fallback ($2 x, $2 y)
99 return __builtin_$1 (x, y);
108 [gcc_cv_math_inline_builtin_$1=yes],
109 [gcc_cv_math_inline_builtin_$1=no])])
110 if test $gcc_cv_math_inline_builtin_$1 = yes; then
111 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_INLINE_BUILTIN_$1),[1],
112 [Define to 1 if `__builtin_$1' is expanded inline.])