3 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_LOG],
10 m4_divert_text([DEFAULTS], [gl_log_required=plain])
11 AC_REQUIRE([gl_MATH_H_DEFAULTS])
13 dnl Determine LOG_LIBM.
14 gl_COMMON_DOUBLE_MATHFUNC([log])
17 LIBS="$LIBS $LOG_LIBM"
20 case "$gl_cv_func_log_works" in
25 m4_ifdef([gl_FUNC_LOG_IEEE], [
26 if test $gl_log_required = ieee && test $REPLACE_LOG = 0; then
27 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
28 AC_CACHE_CHECK([whether log works according to ISO C 99 with IEC 60559],
29 [gl_cv_func_log_ieee],
32 LIBS="$LIBS $LOG_LIBM"
35 #ifndef __NO_MATH_INLINES
36 # define __NO_MATH_INLINES 1 /* for glibc */
39 /* Compare two numbers with ==.
40 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
43 numeric_equal (double x, double y)
47 static double dummy (double x) { return 0; }
48 int main (int argc, char *argv[])
50 double (* volatile my_log) (double) = argc ? log : dummy;
51 /* Test log(negative).
52 This test fails on NetBSD 5.1, Solaris 11.4. */
53 double y = my_log (-1.0);
54 if (numeric_equal (y, y))
59 [gl_cv_func_log_ieee=yes],
60 [gl_cv_func_log_ieee=no],
62 # Guess yes on glibc systems.
63 *-gnu* | gnu*) gl_cv_func_log_ieee="guessing yes" ;;
64 # Guess yes on musl systems.
65 *-musl* | midipix*) gl_cv_func_log_ieee="guessing yes" ;;
66 # Guess yes on native Windows.
67 mingw* | windows*) gl_cv_func_log_ieee="guessing yes" ;;
68 # If we don't know, obey --enable-cross-guesses.
69 *) gl_cv_func_log_ieee="$gl_cross_guess_normal" ;;
74 case "$gl_cv_func_log_ieee" in
82 dnl Test whether log() works.
83 dnl On OSF/1 5.1, log(-0.0) is NaN.
84 AC_DEFUN([gl_FUNC_LOG_WORKS],
86 AC_REQUIRE([AC_PROG_CC])
87 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
88 AC_CACHE_CHECK([whether log works], [gl_cv_func_log_works],
104 [gl_cv_func_log_works=yes],
105 [gl_cv_func_log_works=no],
107 osf*) gl_cv_func_log_works="guessing no" ;;
108 # Guess yes on native Windows.
109 mingw* | windows*) gl_cv_func_log_works="guessing yes" ;;
110 *) gl_cv_func_log_works="guessing yes" ;;