2 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_EXPM1F],
9 m4_divert_text([DEFAULTS], [gl_expm1f_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([gl_FUNC_EXPM1])
13 dnl Persuade glibc <math.h> to declare expm1f().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 dnl Test whether expm1f() exists. Assume that expm1f(), if it exists, is
17 dnl defined in the same library as expm1().
19 LIBS="$LIBS $EXPM1_LIBM"
20 AC_CHECK_FUNCS([expm1f])
22 if test $ac_cv_func_expm1f = yes; then
23 EXPM1F_LIBM="$EXPM1_LIBM"
26 LIBS="$LIBS $EXPM1F_LIBM"
29 case "$gl_cv_func_expm1f_works" in
31 *) REPLACE_EXPM1F=1 ;;
34 m4_ifdef([gl_FUNC_EXPM1F_IEEE], [
35 if test $gl_expm1f_required = ieee && test $REPLACE_EXPM1F = 0; then
36 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
37 AC_CACHE_CHECK([whether expm1f works according to ISO C 99 with IEC 60559],
38 [gl_cv_func_expm1f_ieee],
41 LIBS="$LIBS $EXPM1F_LIBM"
44 #ifndef __NO_MATH_INLINES
45 # define __NO_MATH_INLINES 1 /* for glibc */
48 ]gl_FLOAT_MINUS_ZERO_CODE[
49 ]gl_FLOAT_SIGNBIT_CODE[
57 /* Compare two numbers with ==.
58 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
61 numeric_equal (float x, float y)
65 static float dummy (float x) { return 0; }
66 int main (int argc, char *argv[])
68 float (* volatile my_expm1f) (float) = argc ? expm1f : dummy;
69 /* Test expm1f(-0.0f).
70 This test fails on AIX 7.2. */
71 float y = my_expm1f (minus_zerof);
72 if (signbitf (minus_zerof) && !signbitf (y))
77 [gl_cv_func_expm1f_ieee=yes],
78 [gl_cv_func_expm1f_ieee=no],
80 # Guess yes on glibc systems.
81 *-gnu* | gnu*) gl_cv_func_expm1f_ieee="guessing yes" ;;
82 # Guess yes on musl systems.
83 *-musl*) gl_cv_func_expm1f_ieee="guessing yes" ;;
84 # Guess yes on native Windows.
85 mingw*) gl_cv_func_expm1f_ieee="guessing yes" ;;
87 aix*) gl_cv_func_expm1f_ieee="guessing no" ;;
88 # If we don't know, obey --enable-cross-guesses.
89 *) gl_cv_func_expm1f_ieee="$gl_cross_guess_normal" ;;
94 case "$gl_cv_func_expm1f_ieee" in
96 *) REPLACE_EXPM1F=1 ;;
103 if test $HAVE_EXPM1F = 0 || test $REPLACE_EXPM1F = 1; then
104 dnl Find libraries needed to link lib/expm1f.c.
105 EXPM1F_LIBM="$EXPM1_LIBM"
107 AC_SUBST([EXPM1F_LIBM])
110 dnl Test whether expm1f() works.
111 dnl On IRIX 6.5, for arguments <= -17.32868, it returns -5.6295e14.
112 AC_DEFUN([gl_FUNC_EXPM1F_WORKS],
114 AC_REQUIRE([AC_PROG_CC])
115 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
116 AC_CACHE_CHECK([whether expm1f works], [gl_cv_func_expm1f_works],
132 [gl_cv_func_expm1f_works=yes],
133 [gl_cv_func_expm1f_works=no],
135 irix*) gl_cv_func_expm1f_works="guessing no" ;;
136 # Guess yes on native Windows.
137 mingw*) gl_cv_func_expm1f_works="guessing yes" ;;
138 *) gl_cv_func_expm1f_works="guessing yes" ;;