2 dnl Copyright (C) 2012-2020 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_LOG1P],
9 m4_divert_text([DEFAULTS], [gl_log1p_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
12 dnl Persuade glibc <math.h> to declare log1p().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 dnl Determine LOG1P_LIBM.
16 gl_COMMON_DOUBLE_MATHFUNC([log1p])
18 dnl Test whether log1p() exists.
20 LIBS="$LIBS $LOG1P_LIBM"
21 AC_CHECK_FUNCS([log1p])
23 if test $ac_cv_func_log1p = yes; then
25 m4_ifdef([gl_FUNC_LOG1P_IEEE], [
26 if test $gl_log1p_required = ieee && test $REPLACE_LOG1P = 0; then
27 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
28 AC_CACHE_CHECK([whether log1p works according to ISO C 99 with IEC 60559],
29 [gl_cv_func_log1p_ieee],
32 LIBS="$LIBS $LOG1P_LIBM"
35 #ifndef __NO_MATH_INLINES
36 # define __NO_MATH_INLINES 1 /* for glibc */
39 ]gl_DOUBLE_MINUS_ZERO_CODE[
40 ]gl_DOUBLE_SIGNBIT_CODE[
41 static double dummy (double x) { return 0; }
42 int main (int argc, char *argv[])
44 double (* volatile my_log1p) (double) = argc ? log1p : dummy;
45 /* This test fails on AIX, HP-UX 11. */
46 double y = my_log1p (minus_zerod);
47 if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y)))
52 [gl_cv_func_log1p_ieee=yes],
53 [gl_cv_func_log1p_ieee=no],
55 # Guess yes on glibc systems.
56 *-gnu* | gnu*) gl_cv_func_log1p_ieee="guessing yes" ;;
57 # Guess yes on musl systems.
58 *-musl*) gl_cv_func_log1p_ieee="guessing yes" ;;
59 # Guess yes on native Windows.
60 mingw*) gl_cv_func_log1p_ieee="guessing yes" ;;
61 # If we don't know, obey --enable-cross-guesses.
62 *) gl_cv_func_log1p_ieee="$gl_cross_guess_normal" ;;
67 case "$gl_cv_func_log1p_ieee" in
76 if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then
77 dnl Find libraries needed to link lib/log1p.c.
78 AC_REQUIRE([gl_FUNC_ISNAND])
79 AC_REQUIRE([gl_FUNC_LOG])
80 AC_REQUIRE([gl_FUNC_ROUND])
82 dnl Append $ISNAND_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
83 case " $LOG1P_LIBM " in
84 *" $ISNAND_LIBM "*) ;;
85 *) LOG1P_LIBM="$LOG1P_LIBM $ISNAND_LIBM" ;;
87 dnl Append $LOG_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
88 case " $LOG1P_LIBM " in
90 *) LOG1P_LIBM="$LOG1P_LIBM $LOG_LIBM" ;;
92 dnl Append $ROUND_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
93 case " $LOG1P_LIBM " in
95 *) LOG1P_LIBM="$LOG1P_LIBM $ROUND_LIBM" ;;