From: Bruno Haible Date: Sun, 11 Mar 2012 00:27:59 +0000 (+0100) Subject: log1p-ieee: Work around test failure on AIX 7.1 and HP-UX 11. X-Git-Tag: v0.1~859 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=55b49420fc3ae8860ed66a85645b2b4d171646dc;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index e42a13427..874af82fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2012-03-10 Bruno Haible + 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. diff --git a/doc/posix-functions/log1p.texi b/doc/posix-functions/log1p.texi index a63b75b19..0e1f3aac8 100644 --- 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 diff --git a/lib/math.in.h b/lib/math.in.h index 9d8159070..5128dccc1 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -1245,10 +1245,19 @@ _GL_WARN_ON_USE (log1pf, "log1pf is unportable - " #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 +# endif _GL_CXXALIAS_SYS (log1p, double, (double x)); +# endif _GL_CXXALIASWARN (log1p); #elif defined GNULIB_POSIXCHECK # undef log1p diff --git a/m4/log1p-ieee.m4 b/m4/log1p-ieee.m4 new file mode 100644 index 000000000..2391af8f9 --- /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]) +]) diff --git a/m4/log1p.m4 b/m4/log1p.m4 index f692ca023..8d2b15ca0 100644 --- 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 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_LOG1P], [ + m4_divert_text([DEFAULTS], [gl_log1p_required=plain]) AC_REQUIRE([gl_MATH_H_DEFAULTS]) dnl Persuade glibc to declare log1p(). @@ -19,8 +20,49 @@ AC_DEFUN([gl_FUNC_LOG1P], 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 +]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]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 522be0b2d..d832e588b 100644 --- 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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], 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]) diff --git a/modules/log1p b/modules/log1p index e055026aa..57f8ff547 100644 --- a/modules/log1p +++ b/modules/log1p @@ -9,13 +9,13 @@ m4/mathfunc.m4 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]) diff --git a/modules/log1p-ieee b/modules/log1p-ieee index b76096e67..7a0aa9bb8 100644 --- a/modules/log1p-ieee +++ b/modules/log1p-ieee @@ -2,12 +2,16 @@ Description: 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: diff --git a/modules/math b/modules/math index 16950da40..cbd86cd77 100644 --- a/modules/math +++ b/modules/math @@ -238,6 +238,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -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' \