Mercurial > hg > octave-shane > gnulib-hg
diff m4/log.m4 @ 16631:45443deebb7d
log: Work around OSF/1 5.1 bug.
* lib/math.in.h (log): New declaration.
* lib/log.c: New file.
* m4/log.m4 (gl_FUNC_LOG_WORKS): New macro.
(gl_FUNC_LOG): Invoke it. Set REPLACE_LOG.
* m4/math_h.m4 (gl_MATH_H): Test whether log is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG, REPLACE_LOG.
* modules/math (Makefile.am): Substitute GNULIB_LOG, REPLACE_LOG.
* modules/log (Files): Add lib/log.c.
(Depends-on): Add math.
(configure.ac): If REPLACE_LOG is 1, compile an override.
* tests/test-math-c++.cc: Check the declaration of log.
* doc/posix-functions/log.texi: Mention the OSF/1 5.1 problem.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 09 Mar 2012 23:55:13 +0100 |
parents | 8250f2777afc |
children | 521c2cde0e31 |
line wrap: on
line diff
--- a/m4/log.m4 +++ b/m4/log.m4 @@ -1,4 +1,4 @@ -# log.m4 serial 1 +# log.m4 serial 2 dnl Copyright (C) 2011-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,4 +8,45 @@ [ dnl Determine LOG_LIBM. gl_COMMON_DOUBLE_MATHFUNC([log]) + + save_LIBS="$LIBS" + LIBS="$LIBS $LOG_LIBM" + gl_FUNC_LOG_WORKS + LIBS="$save_LIBS" + case "$gl_cv_func_log_works" in + *yes) ;; + *) REPLACE_LOG=1 ;; + esac ]) + +dnl Test whether log() works. +dnl On OSF/1 5.1, log(-0.0) is NaN. +AC_DEFUN([gl_FUNC_LOG_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether log works], [gl_cv_func_log_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <math.h> +volatile double x; +double y; +int main () +{ + x = -0.0; + y = log (x); + if (!(y + y == y)) + return 1; + return 0; +} +]])], + [gl_cv_func_log_works=yes], + [gl_cv_func_log_works=no], + [case "$host_os" in + osf*) gl_cv_func_log_works="guessing no";; + *) gl_cv_func_log_works="guessing yes";; + esac + ]) + ]) +])