2 dnl Copyright (C) 2011-2018 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_LOG],
9 m4_divert_text([DEFAULTS], [gl_log_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
12 dnl Determine LOG_LIBM.
13 gl_COMMON_DOUBLE_MATHFUNC([log])
16 LIBS="$LIBS $LOG_LIBM"
19 case "$gl_cv_func_log_works" in
24 m4_ifdef([gl_FUNC_LOG_IEEE], [
25 if test $gl_log_required = ieee && test $REPLACE_LOG = 0; then
26 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
27 AC_CACHE_CHECK([whether log works according to ISO C 99 with IEC 60559],
28 [gl_cv_func_log_ieee],
31 LIBS="$LIBS $LOG_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 (*my_log) (double) = argc ? log : dummy;
50 /* Test log(negative).
51 This test fails on NetBSD 5.1, Solaris 11.0. */
52 double y = my_log (-1.0);
53 if (numeric_equal (y, y))
58 [gl_cv_func_log_ieee=yes],
59 [gl_cv_func_log_ieee=no],
61 # Guess yes on glibc systems.
62 *-gnu* | gnu*) gl_cv_func_log_ieee="guessing yes" ;;
63 # Guess yes on native Windows.
64 mingw*) gl_cv_func_log_ieee="guessing yes" ;;
65 # If we don't know, assume the worst.
66 *) gl_cv_func_log_ieee="guessing no" ;;
71 case "$gl_cv_func_log_ieee" in
79 dnl Test whether log() works.
80 dnl On OSF/1 5.1, log(-0.0) is NaN.
81 AC_DEFUN([gl_FUNC_LOG_WORKS],
83 AC_REQUIRE([AC_PROG_CC])
84 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
85 AC_CACHE_CHECK([whether log works], [gl_cv_func_log_works],
101 [gl_cv_func_log_works=yes],
102 [gl_cv_func_log_works=no],
104 osf*) gl_cv_func_log_works="guessing no" ;;
105 # Guess yes on native Windows.
106 mingw*) gl_cv_func_log_works="guessing yes" ;;
107 *) gl_cv_func_log_works="guessing yes" ;;