2 dnl Copyright (C) 2011-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_LOGF],
9 m4_divert_text([DEFAULTS], [gl_logf_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([gl_FUNC_LOG])
13 dnl Persuade glibc <math.h> to declare logf().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 dnl Test whether logf() exists. Assume that logf(), if it exists, is
17 dnl defined in the same library as log().
19 LIBS="$LIBS $LOG_LIBM"
20 AC_CHECK_FUNCS([logf])
22 if test $ac_cv_func_logf = yes; then
26 LIBS="$LIBS $LOGF_LIBM"
29 case "$gl_cv_func_logf_works" in
34 m4_ifdef([gl_FUNC_LOGF_IEEE], [
35 if test $gl_logf_required = ieee && test $REPLACE_LOGF = 0; then
36 AC_CACHE_CHECK([whether logf works according to ISO C 99 with IEC 60559],
37 [gl_cv_func_logf_ieee],
40 LIBS="$LIBS $LOGF_LIBM"
43 #ifndef __NO_MATH_INLINES
44 # define __NO_MATH_INLINES 1 /* for glibc */
47 /* Compare two numbers with ==.
48 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
51 numeric_equal (float x, float y)
55 static float dummy (float x) { return 0; }
56 int main (int argc, char *argv[])
58 float (*my_logf) (float) = argc ? logf : dummy;
59 /* Test logf(negative).
60 This test fails on NetBSD 5.1. */
61 float y = my_logf (-1.0f);
62 if (numeric_equal (y, y))
67 [gl_cv_func_logf_ieee=yes],
68 [gl_cv_func_logf_ieee=no],
69 [gl_cv_func_logf_ieee="guessing no"])
72 case "$gl_cv_func_logf_ieee" in
81 if test $HAVE_LOGF = 0 || test $REPLACE_LOGF = 1; then
82 dnl Find libraries needed to link lib/logf.c.
83 if test $HAVE_LOGF = 0; then
90 dnl Test whether logf() works.
91 dnl On OSF/1 5.1, logf(-0.0f) is NaN.
92 AC_DEFUN([gl_FUNC_LOGF_WORKS],
94 AC_REQUIRE([AC_PROG_CC])
95 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
96 AC_CACHE_CHECK([whether logf works], [gl_cv_func_logf_works],
112 [gl_cv_func_logf_works=yes],
113 [gl_cv_func_logf_works=no],
115 osf*) gl_cv_func_logf_works="guessing no";;
116 *) gl_cv_func_logf_works="guessing yes";;