2 dnl Copyright (C) 2010-2012 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_LOG2F],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_LOG2])
12 dnl Persuade glibc <math.h> to declare log2f().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 dnl Determine LOG2F_LIBM.
16 gl_COMMON_DOUBLE_MATHFUNC([log2f])
18 dnl Test whether log2f() exists.
20 LIBS="$LIBS $LOG2F_LIBM"
21 AC_CHECK_FUNCS([log2f])
23 if test $ac_cv_func_log2f = yes; then
25 dnl Also check whether it's declared.
26 dnl IRIX 6.5 has log2f() in libm but doesn't declare it in <math.h>.
27 AC_CHECK_DECL([log2f], , [HAVE_DECL_LOG2F=0], [[#include <math.h>]])
30 LIBS="$LIBS $LOG2F_LIBM"
33 case "$gl_cv_func_log2f_works" in
41 if test $HAVE_LOG2F = 0 || test $REPLACE_LOG2F = 1; then
42 dnl Find libraries needed to link lib/log2f.c.
43 if test $ac_cv_func_log2 = yes; then
44 AC_DEFINE([HAVE_LOG2], [1],
45 [Define to 1 if the log2() function is available in libc or libm.])
46 LOG2F_LIBM="$LOG2_LIBM"
48 AC_REQUIRE([gl_FUNC_ISNANF])
49 AC_REQUIRE([gl_FUNC_FREXPF])
50 AC_REQUIRE([gl_FUNC_LOGF])
52 dnl Append $ISNANF_LIBM to LOG2F_LIBM, avoiding gratuitous duplicates.
53 case " $LOG2F_LIBM " in
54 *" $ISNANF_LIBM "*) ;;
55 *) LOG2F_LIBM="$LOG2F_LIBM $ISNANF_LIBM" ;;
57 dnl Append $FREXPF_LIBM to LOG2F_LIBM, avoiding gratuitous duplicates.
58 case " $LOG2F_LIBM " in
59 *" $FREXPF_LIBM "*) ;;
60 *) LOG2F_LIBM="$LOG2F_LIBM $FREXPF_LIBM" ;;
62 dnl Append $LOGF_LIBM to LOG2F_LIBM, avoiding gratuitous duplicates.
63 case " $LOG2F_LIBM " in
65 *) LOG2F_LIBM="$LOG2F_LIBM $LOGF_LIBM" ;;
71 dnl Test whether log2() works.
72 dnl On OSF/1 5.1, log2f(-0.0f) is NaN.
73 dnl On Cygwin 1.7.9, log2f(2^13) is not exactly 13.
74 AC_DEFUN([gl_FUNC_LOG2F_WORKS],
76 AC_REQUIRE([AC_PROG_CC])
77 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
78 AC_CACHE_CHECK([whether log2f works], [gl_cv_func_log2f_works],
83 #ifndef log2f /* for Cygwin 1.7.x */
95 /* This test fails on OSF/1 5.1. */
100 /* This test fails on Cygwin 1.7.9. */
108 [gl_cv_func_log2f_works=yes],
109 [gl_cv_func_log2f_works=no],
111 cygwin* | osf*) gl_cv_func_log2f_works="guessing no";;
112 *) gl_cv_func_log2f_works="guessing yes";;