log: Work around OSF/1 5.1 bug.
[gnulib.git] / m4 / log.m4
1 # log.m4 serial 2
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.
6
7 AC_DEFUN([gl_FUNC_LOG],
8 [
9   dnl Determine LOG_LIBM.
10   gl_COMMON_DOUBLE_MATHFUNC([log])
11
12   save_LIBS="$LIBS"
13   LIBS="$LIBS $LOG_LIBM"
14   gl_FUNC_LOG_WORKS
15   LIBS="$save_LIBS"
16   case "$gl_cv_func_log_works" in
17     *yes) ;;
18     *) REPLACE_LOG=1 ;;
19   esac
20 ])
21
22 dnl Test whether log() works.
23 dnl On OSF/1 5.1, log(-0.0) is NaN.
24 AC_DEFUN([gl_FUNC_LOG_WORKS],
25 [
26   AC_REQUIRE([AC_PROG_CC])
27   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
28   AC_CACHE_CHECK([whether log works], [gl_cv_func_log_works],
29     [
30       AC_RUN_IFELSE(
31         [AC_LANG_SOURCE([[
32 #include <math.h>
33 volatile double x;
34 double y;
35 int main ()
36 {
37   x = -0.0;
38   y = log (x);
39   if (!(y + y == y))
40     return 1;
41   return 0;
42 }
43 ]])],
44         [gl_cv_func_log_works=yes],
45         [gl_cv_func_log_works=no],
46         [case "$host_os" in
47            osf*) gl_cv_func_log_works="guessing no";;
48            *)    gl_cv_func_log_works="guessing yes";;
49          esac
50         ])
51     ])
52 ])