Mercurial > hg > octave-lojdl > gnulib-hg
changeset 16667:f691c5744fcb
log1p-ieee: Work around test failure on AIX 7.1 and HP-UX 11.
* m4/log1p-ieee.m4: New file.
* m4/log1p.m4 (gl_FUNC_LOG1P): If gl_FUNC_LOG1P_IEEE is present, test
whether log1p works with a minus zero argument. Replace it if not.
* lib/math.in.h (log1p): Override if REPLACE_LOG1P is 1.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG1P.
* modules/math (Makefile.am): Substitute REPLACE_LOG1P.
* modules/log1p (configure.ac): Consider REPLACE_LOG1P.
(Depends-on): Update conditions.
* modules/log1p-ieee (Files): Add m4/log1p-ieee.m4, m4/minus-zero.m4,
m4/signbit.m4.
(configure.ac): Invoke gl_FUNC_LOG1P_IEEE.
* doc/posix-functions/log1p.texi: Mention the log1p-ieee module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 11 Mar 2012 01:27:59 +0100 |
parents | 7e7add399ccd |
children | e5cdf9cb718e |
files | ChangeLog doc/posix-functions/log1p.texi lib/math.in.h m4/log1p-ieee.m4 m4/log1p.m4 m4/math_h.m4 modules/log1p modules/log1p-ieee modules/math |
diffstat | 9 files changed, 104 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2012-03-10 Bruno Haible <bruno@clisp.org> + log1p-ieee: Work around test failure on AIX 7.1 and HP-UX 11. + * m4/log1p-ieee.m4: New file. + * m4/log1p.m4 (gl_FUNC_LOG1P): If gl_FUNC_LOG1P_IEEE is present, test + whether log1p works with a minus zero argument. Replace it if not. + * lib/math.in.h (log1p): Override if REPLACE_LOG1P is 1. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG1P. + * modules/math (Makefile.am): Substitute REPLACE_LOG1P. + * modules/log1p (configure.ac): Consider REPLACE_LOG1P. + (Depends-on): Update conditions. + * modules/log1p-ieee (Files): Add m4/log1p-ieee.m4, m4/minus-zero.m4, + m4/signbit.m4. + (configure.ac): Invoke gl_FUNC_LOG1P_IEEE. + * doc/posix-functions/log1p.texi: Mention the log1p-ieee module. + Tests for module 'log1pl-ieee'. * modules/log1pl-ieee-tests: New file. * tests/test-log1pl-ieee.c: New file.
--- a/doc/posix-functions/log1p.texi +++ b/doc/posix-functions/log1p.texi @@ -4,15 +4,22 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log1p.html} -Gnulib module: log1p +Gnulib module: log1p or log1p-ieee -Portability problems fixed by Gnulib: +Portability problems fixed by either Gnulib module @code{log1p} or @code{log1p-ieee}: @itemize @item This function is missing on some platforms: Minix 3.1.8, MSVC 9. @end itemize +Portability problems fixed by Gnulib module @code{log1p-ieee}: +@itemize +@item +This function has problems when the argument is minus zero on some platforms: +AIX 7.1, HP-UX 11. +@end itemize + Portability problems not fixed by Gnulib: @itemize @end itemize
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -1245,10 +1245,19 @@ #endif #if @GNULIB_LOG1P@ -# if !@HAVE_LOG1P@ +# if @REPLACE_LOG1P@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log1p +# define log1p rpl_log1p +# endif +_GL_FUNCDECL_RPL (log1p, double, (double x)); +_GL_CXXALIAS_RPL (log1p, double, (double x)); +# else +# if !@HAVE_LOG1P@ _GL_FUNCDECL_SYS (log1p, double, (double x)); +# endif +_GL_CXXALIAS_SYS (log1p, double, (double x)); # endif -_GL_CXXALIAS_SYS (log1p, double, (double x)); _GL_CXXALIASWARN (log1p); #elif defined GNULIB_POSIXCHECK # undef log1p
new file mode 100644 --- /dev/null +++ b/m4/log1p-ieee.m4 @@ -0,0 +1,15 @@ +# log1p-ieee.m4 serial 1 +dnl Copyright (C) 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, +dnl with or without modifications, as long as this notice is preserved. + +dnl This macro is in a separate file (not in remainder.m4 and not inlined in the +dnl module description), so that gl_FUNC_LOG1P can test whether 'aclocal' has +dnl found uses of this macro. + +AC_DEFUN([gl_FUNC_LOG1P_IEEE], +[ + m4_divert_text([INIT_PREPARE], [gl_log1p_required=ieee]) + AC_REQUIRE([gl_FUNC_LOG1P]) +])
--- a/m4/log1p.m4 +++ b/m4/log1p.m4 @@ -1,4 +1,4 @@ -# log1p.m4 serial 1 +# log1p.m4 serial 2 dnl Copyright (C) 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, @@ -6,6 +6,7 @@ AC_DEFUN([gl_FUNC_LOG1P], [ + m4_divert_text([DEFAULTS], [gl_log1p_required=plain]) AC_REQUIRE([gl_MATH_H_DEFAULTS]) dnl Persuade glibc <math.h> to declare log1p(). @@ -19,8 +20,49 @@ LIBS="$LIBS $LOG1P_LIBM" AC_CHECK_FUNCS([log1p]) LIBS="$save_LIBS" - if test $ac_cv_func_log1p = no; then + if test $ac_cv_func_log1p = yes; then + : + m4_ifdef([gl_FUNC_LOG1P_IEEE], [ + if test $gl_log1p_required = ieee && test $REPLACE_LOG1P = 0; then + AC_CACHE_CHECK([whether log1p works according to ISO C 99 with IEC 60559], + [gl_cv_func_log1p_ieee], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $LOG1P_LIBM" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __NO_MATH_INLINES +# define __NO_MATH_INLINES 1 /* for glibc */ +#endif +#include <math.h> +]gl_DOUBLE_MINUS_ZERO_CODE[ +]gl_DOUBLE_SIGNBIT_CODE[ +static double dummy (double x) { return 0; } +int main (int argc, char *argv[]) +{ + double (*my_log1p) (double) = argc ? log1p : dummy; + /* This test fails on AIX, HP-UX 11. */ + double y = my_log1p (minus_zerod); + if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y))) + return 1; + return 0; +} + ]])], + [gl_cv_func_log1p_ieee=yes], + [gl_cv_func_log1p_ieee=no], + [gl_cv_func_log1p_ieee="guessing no"]) + LIBS="$save_LIBS" + ]) + case "$gl_cv_func_log1p_ieee" in + *yes) ;; + *) REPLACE_LOG1P=1 ;; + esac + fi + ]) + else HAVE_LOG1P=0 + fi + if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then dnl Find libraries needed to link lib/log1p.c. AC_REQUIRE([gl_FUNC_ISNAND]) AC_REQUIRE([gl_FUNC_LOG])
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 98 +# math_h.m4 serial 99 dnl Copyright (C) 2007-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, @@ -270,6 +270,7 @@ REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) + REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P]) REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF])
--- a/modules/log1p +++ b/modules/log1p @@ -9,13 +9,13 @@ Depends-on: math extensions -isnand [test $HAVE_LOG1P = 0] -log [test $HAVE_LOG1P = 0] -round [test $HAVE_LOG1P = 0] +isnand [test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1] +log [test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1] +round [test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1] configure.ac: gl_FUNC_LOG1P -if test $HAVE_LOG1P = 0; then +if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then AC_LIBOBJ([log1p]) fi gl_MATH_MODULE_INDICATOR([log1p])
--- a/modules/log1p-ieee +++ b/modules/log1p-ieee @@ -2,12 +2,16 @@ log1p() function according to ISO C 99 with IEC 60559. Files: +m4/log1p-ieee.m4 +m4/minus-zero.m4 +m4/signbit.m4 Depends-on: log1p fpieee configure.ac: +gl_FUNC_LOG1P_IEEE Makefile.am:
--- a/modules/math +++ b/modules/math @@ -238,6 +238,7 @@ -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \ -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \ -e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \ + -e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \ -e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \ -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \ -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \