3 dnl Copyright (C) 2012-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.
7 dnl This file is offered as-is, without any warranty.
9 AC_DEFUN([gl_FUNC_LOG1PF],
11 m4_divert_text([DEFAULTS], [gl_log1pf_required=plain])
12 AC_REQUIRE([gl_MATH_H_DEFAULTS])
13 AC_REQUIRE([gl_FUNC_LOG1P])
15 dnl Persuade glibc <math.h> to declare log1pf().
16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
18 dnl Test whether log1pf() exists. Assume that log1pf(), if it exists, is
19 dnl defined in the same library as log1p().
21 LIBS="$LIBS $LOG1P_LIBM"
22 AC_CHECK_FUNCS([log1pf])
24 if test $ac_cv_func_log1pf = yes; then
25 LOG1PF_LIBM="$LOG1P_LIBM"
28 LIBS="$LIBS $LOG1PF_LIBM"
31 case "$gl_cv_func_log1pf_works" in
33 *) REPLACE_LOG1PF=1 ;;
36 m4_ifdef([gl_FUNC_LOG1PF_IEEE], [
37 if test $gl_log1pf_required = ieee && test $REPLACE_LOG1PF = 0; then
38 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
39 AC_CACHE_CHECK([whether log1pf works according to ISO C 99 with IEC 60559],
40 [gl_cv_func_log1pf_ieee],
43 LIBS="$LIBS $LOG1PF_LIBM"
46 #ifndef __NO_MATH_INLINES
47 # define __NO_MATH_INLINES 1 /* for glibc */
50 ]gl_FLOAT_MINUS_ZERO_CODE[
51 ]gl_FLOAT_SIGNBIT_CODE[
52 static float dummy (float x) { return 0; }
53 int main (int argc, char *argv[])
55 float (* volatile my_log1pf) (float) = argc ? log1pf : dummy;
56 /* This test fails on OpenBSD 4.9, AIX 7.1. */
57 float y = my_log1pf (minus_zerof);
58 if (!(y == 0.0f) || (signbitf (minus_zerof) && !signbitf (y)))
63 [gl_cv_func_log1pf_ieee=yes],
64 [gl_cv_func_log1pf_ieee=no],
66 # Guess yes on glibc systems.
67 *-gnu* | gnu*) gl_cv_func_log1pf_ieee="guessing yes" ;;
68 # Guess yes on musl systems.
69 *-musl* | midipix*) gl_cv_func_log1pf_ieee="guessing yes" ;;
70 # Guess yes on native Windows.
71 mingw* | windows*) gl_cv_func_log1pf_ieee="guessing yes" ;;
72 # If we don't know, obey --enable-cross-guesses.
73 *) gl_cv_func_log1pf_ieee="$gl_cross_guess_normal" ;;
78 case "$gl_cv_func_log1pf_ieee" in
80 *) REPLACE_LOG1PF=1 ;;
87 if test $HAVE_LOG1PF = 0 || test $REPLACE_LOG1PF = 1; then
88 dnl Find libraries needed to link lib/log1pf.c.
89 LOG1PF_LIBM="$LOG1P_LIBM"
91 AC_SUBST([LOG1PF_LIBM])
94 dnl Test whether log1pf() works.
95 dnl On IRIX 6.5, log1pf(-1.0f) returns +Infinity instead of -Infinity.
96 AC_DEFUN([gl_FUNC_LOG1PF_WORKS],
98 AC_REQUIRE([AC_PROG_CC])
99 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
100 AC_CACHE_CHECK([whether log1pf works], [gl_cv_func_log1pf_works],
111 if (!(y + y == y && y < 0.0f))
116 [gl_cv_func_log1pf_works=yes],
117 [gl_cv_func_log1pf_works=no],
119 irix*) gl_cv_func_log1pf_works="guessing no" ;;
120 # Guess yes on native Windows.
121 mingw* | windows*) gl_cv_func_log1pf_works="guessing yes" ;;
122 *) gl_cv_func_log1pf_works="guessing yes" ;;