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_LOGF],
10 m4_divert_text([DEFAULTS], [gl_logf_required=plain])
11 AC_REQUIRE([gl_MATH_H_DEFAULTS])
12 AC_REQUIRE([gl_FUNC_LOG])
14 dnl Persuade glibc <math.h> to declare logf().
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 dnl Test whether logf() exists. Assume that logf(), if it exists, is
18 dnl defined in the same library as log().
20 LIBS="$LIBS $LOG_LIBM"
21 AC_CHECK_FUNCS([logf])
23 if test $ac_cv_func_logf = yes; then
27 LIBS="$LIBS $LOGF_LIBM"
30 case "$gl_cv_func_logf_works" in
35 m4_ifdef([gl_FUNC_LOGF_IEEE], [
36 if test $gl_logf_required = ieee && test $REPLACE_LOGF = 0; then
37 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
38 AC_CACHE_CHECK([whether logf works according to ISO C 99 with IEC 60559],
39 [gl_cv_func_logf_ieee],
42 LIBS="$LIBS $LOGF_LIBM"
45 #ifndef __NO_MATH_INLINES
46 # define __NO_MATH_INLINES 1 /* for glibc */
49 /* Compare two numbers with ==.
50 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
53 numeric_equal (float x, float y)
57 static float dummy (float x) { return 0; }
58 int main (int argc, char *argv[])
60 float (* volatile my_logf) (float) = argc ? logf : dummy;
61 /* Test logf(negative).
62 This test fails on NetBSD 5.1. */
63 float y = my_logf (-1.0f);
64 if (numeric_equal (y, y))
69 [gl_cv_func_logf_ieee=yes],
70 [gl_cv_func_logf_ieee=no],
72 # Guess yes on glibc systems.
73 *-gnu* | gnu*) gl_cv_func_logf_ieee="guessing yes" ;;
74 # Guess yes on musl systems.
75 *-musl* | midipix*) gl_cv_func_logf_ieee="guessing yes" ;;
76 # Guess yes on native Windows.
77 mingw* | windows*) gl_cv_func_logf_ieee="guessing yes" ;;
78 # If we don't know, obey --enable-cross-guesses.
79 *) gl_cv_func_logf_ieee="$gl_cross_guess_normal" ;;
84 case "$gl_cv_func_logf_ieee" in
92 dnl If the function is declared but does not appear to exist, it may be
93 dnl defined as an inline function. In order to avoid a conflict, we have
94 dnl to define rpl_logf, not logf.
95 AC_CHECK_DECLS([logf], [REPLACE_LOGF=1], , [[#include <math.h>]])
97 if test $HAVE_LOGF = 0 || test $REPLACE_LOGF = 1; then
98 dnl Find libraries needed to link lib/logf.c.
99 if test $HAVE_LOGF = 0; then
100 LOGF_LIBM="$LOG_LIBM"
103 AC_SUBST([LOGF_LIBM])
106 dnl Test whether logf() works.
107 dnl On OSF/1 5.1, logf(-0.0f) is NaN.
108 AC_DEFUN([gl_FUNC_LOGF_WORKS],
110 AC_REQUIRE([AC_PROG_CC])
111 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
112 AC_CACHE_CHECK([whether logf works], [gl_cv_func_logf_works],
128 [gl_cv_func_logf_works=yes],
129 [gl_cv_func_logf_works=no],
131 osf*) gl_cv_func_logf_works="guessing no" ;;
132 # Guess yes on native Windows.
133 mingw* | windows*) gl_cv_func_logf_works="guessing yes" ;;
134 *) gl_cv_func_logf_works="guessing yes" ;;