2 dnl Copyright (C) 2011-2017 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 2011-11. */
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*) gl_cv_func_log_ieee="guessing yes" ;;
63 # If we don't know, assume the worst.
64 *) gl_cv_func_log_ieee="guessing no" ;;
69 case "$gl_cv_func_log_ieee" in
77 dnl Test whether log() works.
78 dnl On OSF/1 5.1, log(-0.0) is NaN.
79 AC_DEFUN([gl_FUNC_LOG_WORKS],
81 AC_REQUIRE([AC_PROG_CC])
82 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
83 AC_CACHE_CHECK([whether log works], [gl_cv_func_log_works],
99 [gl_cv_func_log_works=yes],
100 [gl_cv_func_log_works=no],
102 osf*) gl_cv_func_log_works="guessing no";;
103 *) gl_cv_func_log_works="guessing yes";;