2 dnl Copyright (C) 2010-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_ILOGBF],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 dnl Persuade glibc <math.h> to declare ilogbf().
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 dnl Determine ILOGBF_LIBM.
15 gl_MATHFUNC([ilogbf], [int], [(float)])
16 if test $gl_cv_func_ilogbf_no_libm = yes \
17 || test $gl_cv_func_ilogbf_in_libm = yes; then
19 LIBS="$LIBS $ILOGBF_LIBM"
22 case "$gl_cv_func_ilogbf_works" in
24 *) REPLACE_ILOGBF=1 ;;
29 if test $HAVE_ILOGBF = 0 || test $REPLACE_ILOGBF = 1; then
30 dnl Find libraries needed to link lib/ilogbf.c.
31 AC_REQUIRE([gl_FUNC_FREXPF])
32 AC_REQUIRE([gl_FUNC_ISNANF])
34 dnl Append $FREXPF_LIBM to ILOGBF_LIBM, avoiding gratuitous duplicates.
35 case " $ILOGBF_LIBM " in
36 *" $FREXPF_LIBM "*) ;;
37 *) ILOGBF_LIBM="$ILOGBF_LIBM $FREXPF_LIBM" ;;
39 dnl Append $ISNANF_LIBM to ILOGBF_LIBM, avoiding gratuitous duplicates.
40 case " $ILOGBF_LIBM " in
41 *" $ISNANF_LIBM "*) ;;
42 *) ILOGBF_LIBM="$ILOGBF_LIBM $ISNANF_LIBM" ;;
45 AC_SUBST([ILOGBF_LIBM])
48 dnl Test whether ilogbf() works.
49 dnl On OpenBSD 4.9, ilogbf(0.0) is wrong.
50 dnl On NetBSD 5.1, OpenBSD 4.9, ilogbf(Infinity) is wrong.
51 AC_DEFUN([gl_FUNC_ILOGBF_WORKS],
53 AC_REQUIRE([AC_PROG_CC])
54 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
55 AC_CACHE_CHECK([whether ilogbf works], [gl_cv_func_ilogbf_works],
61 /* Provide FP_ILOGB0, FP_ILOGBNAN, like in math.in.h. */
62 #if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
63 # if defined __NetBSD__ || defined __sgi
64 /* NetBSD, IRIX 6.5: match what ilogbf() does */
65 # define FP_ILOGB0 INT_MIN
66 # define FP_ILOGBNAN INT_MIN
68 /* AIX 5.1: match what ilogbf() does in AIX >= 5.2 */
69 # define FP_ILOGB0 INT_MIN
70 # define FP_ILOGBNAN INT_MAX
72 /* Solaris 9: match what ilogbf() does */
73 # define FP_ILOGB0 (- INT_MAX)
74 # define FP_ILOGBNAN INT_MAX
79 static int dummy (float x) { return 0; }
80 int main (int argc, char *argv[])
82 int (*my_ilogbf) (float) = argc ? ilogbf : dummy;
84 /* This test fails on OpenBSD 4.9. */
87 if (my_ilogbf (x) != FP_ILOGB0)
90 /* This test fails on NetBSD 5.1, OpenBSD 4.9. */
93 if (my_ilogbf (x) != INT_MAX)
99 [gl_cv_func_ilogbf_works=yes],
100 [gl_cv_func_ilogbf_works=no],
103 gl_cv_func_ilogbf_works="guessing no" ;;
104 # Guess yes on native Windows.
105 mingw*) gl_cv_func_ilogbf_works="guessing yes" ;;
106 *) gl_cv_func_ilogbf_works="guessing yes" ;;