2 dnl Copyright (C) 2011-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_LOG10],
9 m4_divert_text([DEFAULTS], [gl_log10_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
12 dnl Determine LOG10_LIBM.
13 gl_COMMON_DOUBLE_MATHFUNC([log10])
16 LIBS="$LIBS $LOG10_LIBM"
19 case "$gl_cv_func_log10_works" in
24 m4_ifdef([gl_FUNC_LOG10_IEEE], [
25 if test $gl_log10_required = ieee && test $REPLACE_LOG10 = 0; then
26 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
27 AC_CACHE_CHECK([whether log10 works according to ISO C 99 with IEC 60559],
28 [gl_cv_func_log10_ieee],
31 LIBS="$LIBS $LOG10_LIBM"
34 #ifndef __NO_MATH_INLINES
35 # define __NO_MATH_INLINES 1 /* for glibc */
38 /* Compare two numbers with ==.
39 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
42 numeric_equal (double x, double y)
46 static double dummy (double x) { return 0; }
47 int main (int argc, char *argv[])
49 double (* volatile my_log10) (double) = argc ? log10 : dummy;
50 /* Test log10(negative).
51 This test fails on NetBSD 5.1, Solaris 11.4. */
52 double y = my_log10 (-1.0);
53 if (numeric_equal (y, y))
58 [gl_cv_func_log10_ieee=yes],
59 [gl_cv_func_log10_ieee=no],
61 # Guess yes on glibc systems.
62 *-gnu* | gnu*) gl_cv_func_log10_ieee="guessing yes" ;;
63 # Guess yes on musl systems.
64 *-musl*) gl_cv_func_log10_ieee="guessing yes" ;;
65 # Guess yes on native Windows.
66 mingw*) gl_cv_func_log10_ieee="guessing yes" ;;
67 # If we don't know, obey --enable-cross-guesses.
68 *) gl_cv_func_log10_ieee="$gl_cross_guess_normal" ;;
73 case "$gl_cv_func_log10_ieee" in
81 dnl Test whether log10() works.
82 dnl On OSF/1 5.1, log10(-0.0) is NaN.
83 AC_DEFUN([gl_FUNC_LOG10_WORKS],
85 AC_REQUIRE([AC_PROG_CC])
86 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
87 AC_CACHE_CHECK([whether log10 works], [gl_cv_func_log10_works],
103 [gl_cv_func_log10_works=yes],
104 [gl_cv_func_log10_works=no],
106 osf*) gl_cv_func_log10_works="guessing no" ;;
107 # Guess yes on native Windows.
108 mingw*) gl_cv_func_log10_works="guessing yes" ;;
109 *) gl_cv_func_log10_works="guessing yes" ;;