2 dnl Copyright (C) 2012-2020 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_LOGBF],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 dnl Persuade glibc <math.h> to declare logbf().
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 dnl Determine LOGBF_LIBM.
15 gl_MATHFUNC([logbf], [float], [(float)])
16 if test $gl_cv_func_logbf_no_libm = yes \
17 || test $gl_cv_func_logbf_in_libm = yes; then
19 LIBS="$LIBS $LOGBF_LIBM"
22 case "$gl_cv_func_logbf_works" in
29 if test $HAVE_LOGBF = 0 || test $REPLACE_LOGBF = 1; then
30 dnl Find libraries needed to link lib/logbf.c.
31 AC_REQUIRE([gl_FUNC_FREXPF])
32 AC_REQUIRE([gl_FUNC_ISNANF])
34 dnl Append $FREXPF_LIBM to LOGBF_LIBM, avoiding gratuitous duplicates.
35 case " $LOGBF_LIBM " in
36 *" $FREXPF_LIBM "*) ;;
37 *) LOGBF_LIBM="$LOGBF_LIBM $FREXPF_LIBM" ;;
39 dnl Append $ISNANF_LIBM to LOGBF_LIBM, avoiding gratuitous duplicates.
40 case " $LOGBF_LIBM " in
41 *" $ISNANF_LIBM "*) ;;
42 *) LOGBF_LIBM="$LOGBF_LIBM $ISNANF_LIBM" ;;
45 AC_SUBST([LOGBF_LIBM])
48 dnl Test whether logbf() works.
49 dnl On glibc 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 10/SPARC,
50 dnl Solaris 11.4/x86_64, the return value for subnormal (denormalized) arguments
52 AC_DEFUN([gl_FUNC_LOGBF_WORKS],
54 AC_REQUIRE([AC_PROG_CC])
55 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
56 AC_CACHE_CHECK([whether logbf works], [gl_cv_func_logbf_works],
66 for (i = 1, x = 1.0f; i >= FLT_MIN_EXP; i--, x *= 0.5f)
68 /* Here i = FLT_MIN_EXP - 1. Either x = 2^(i-1) is subnormal or x = 0.0. */
69 if (x > 0.0f && !(logbf (x) == (float)(i - 1)))
74 [gl_cv_func_logbf_works=yes],
75 [gl_cv_func_logbf_works=no],
77 *gnu* | solaris*) gl_cv_func_logbf_works="guessing no" ;;
78 mingw*) # Guess yes on MSVC, no on mingw.
79 AC_EGREP_CPP([Known], [
84 [gl_cv_func_logbf_works="guessing yes"],
85 [gl_cv_func_logbf_works="guessing no"])
87 *) gl_cv_func_logbf_works="guessing yes" ;;