From: Bruno Haible Date: Sun, 11 Mar 2012 01:36:40 +0000 (+0100) Subject: log1pl-ieee: Work around test failure on IRIX 6.5. X-Git-Tag: v0.1~856 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=6f9fd2e95ca3b10f066bac142903f9b81f4b9dc8;p=gnulib.git log1pl-ieee: Work around test failure on IRIX 6.5. * m4/log1pl-ieee.m4: New file. * m4/log1pl.m4 (gl_FUNC_LOG1PL): If gl_FUNC_LOG1PL_IEEE is present, test whether log1pl works with a minus zero argument. Replace it if not. * lib/math.in.h (log1pl): Override if REPLACE_LOG1PL is 1. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG1PL. * modules/math (Makefile.am): Substitute REPLACE_LOG1PL. * modules/log1pl (configure.ac): Consider REPLACE_LOG1PL. (Depends-on): Update conditions. * modules/log1pl-ieee (Files): Add m4/log1p-ieee.m4, m4/minus-zero.m4, m4/signbit.m4. (configure.ac): Invoke gl_FUNC_LOG1PL_IEEE. * doc/posix-functions/log1pl.texi: Mention the log1pl-ieee module. --- diff --git a/ChangeLog b/ChangeLog index 41e1da09c..18c473693 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2012-03-10 Bruno Haible + log1pl-ieee: Work around test failure on IRIX 6.5. + * m4/log1pl-ieee.m4: New file. + * m4/log1pl.m4 (gl_FUNC_LOG1PL): If gl_FUNC_LOG1PL_IEEE is present, + test whether log1pl works with a minus zero argument. Replace it if + not. + * lib/math.in.h (log1pl): Override if REPLACE_LOG1PL is 1. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG1PL. + * modules/math (Makefile.am): Substitute REPLACE_LOG1PL. + * modules/log1pl (configure.ac): Consider REPLACE_LOG1PL. + (Depends-on): Update conditions. + * modules/log1pl-ieee (Files): Add m4/log1p-ieee.m4, m4/minus-zero.m4, + m4/signbit.m4. + (configure.ac): Invoke gl_FUNC_LOG1PL_IEEE. + * doc/posix-functions/log1pl.texi: Mention the log1pl-ieee module. + log1pf-ieee: Work around test failure on OpenBSD 4.9 and AIX 7.1. * m4/log1pf-ieee.m4: New file. * m4/log1pf.m4 (gl_FUNC_LOG1PF): If gl_FUNC_LOG1PF_IEEE is present, diff --git a/doc/posix-functions/log1pl.texi b/doc/posix-functions/log1pl.texi index 0d2f2fa8d..dfcb3c3ed 100644 --- a/doc/posix-functions/log1pl.texi +++ b/doc/posix-functions/log1pl.texi @@ -4,15 +4,22 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log1pl.html} -Gnulib module: log1pl +Gnulib module: log1pl or log1pl-ieee -Portability problems fixed by Gnulib: +Portability problems fixed by either Gnulib module @code{log1pl} or @code{log1pl-ieee}: @itemize @item This function is missing on some platforms: FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, MSVC 9, Interix 3.5, BeOS. @end itemize +Portability problems fixed by Gnulib module @code{log1pl-ieee}: +@itemize +@item +This function has problems when the argument is minus zero on some platforms: +AIX 7.1, IRIX 6.5. +@end itemize + Portability problems not fixed by Gnulib: @itemize @end itemize diff --git a/lib/math.in.h b/lib/math.in.h index 5128dccc1..54e7caa83 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -1268,10 +1268,19 @@ _GL_WARN_ON_USE (log1p, "log1p has portability problems - " #endif #if @GNULIB_LOG1PL@ -# if !@HAVE_LOG1PL@ +# if @REPLACE_LOG1PL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log1pl +# define log1pl rpl_log1pl +# endif +_GL_FUNCDECL_RPL (log1pl, long double, (long double x)); +_GL_CXXALIAS_RPL (log1pl, long double, (long double x)); +# else +# if !@HAVE_LOG1PL@ _GL_FUNCDECL_SYS (log1pl, long double, (long double x)); -# endif +# endif _GL_CXXALIAS_SYS (log1pl, long double, (long double x)); +# endif _GL_CXXALIASWARN (log1pl); #elif defined GNULIB_POSIXCHECK # undef log1pl diff --git a/m4/log1pl-ieee.m4 b/m4/log1pl-ieee.m4 new file mode 100644 index 000000000..b0da89135 --- /dev/null +++ b/m4/log1pl-ieee.m4 @@ -0,0 +1,15 @@ +# log1pl-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_LOG1PL can test whether 'aclocal' has +dnl found uses of this macro. + +AC_DEFUN([gl_FUNC_LOG1PL_IEEE], +[ + m4_divert_text([INIT_PREPARE], [gl_log1pl_required=ieee]) + AC_REQUIRE([gl_FUNC_LOG1PL]) +]) diff --git a/m4/log1pl.m4 b/m4/log1pl.m4 index b981b827a..5a72299f4 100644 --- a/m4/log1pl.m4 +++ b/m4/log1pl.m4 @@ -1,4 +1,4 @@ -# log1pl.m4 serial 1 +# log1pl.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_LOG1PL], [ + m4_divert_text([DEFAULTS], [gl_log1pl_required=plain]) AC_REQUIRE([gl_MATH_H_DEFAULTS]) AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) AC_REQUIRE([gl_FUNC_LOG1P]) @@ -21,6 +22,43 @@ AC_DEFUN([gl_FUNC_LOG1PL], LIBS="$save_LIBS" if test $ac_cv_func_log1pl = yes; then LOG1PL_LIBM="$LOG1P_LIBM" + m4_ifdef([gl_FUNC_LOG1PL_IEEE], [ + if test $gl_log1pl_required = ieee && test $REPLACE_LOG1PL = 0; then + AC_CACHE_CHECK([whether log1pl works according to ISO C 99 with IEC 60559], + [gl_cv_func_log1pl_ieee], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $LOG1PL_LIBM" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __NO_MATH_INLINES +# define __NO_MATH_INLINES 1 /* for glibc */ +#endif +#include +]gl_LONG_DOUBLE_MINUS_ZERO_CODE[ +]gl_LONG_DOUBLE_SIGNBIT_CODE[ +static long double dummy (long double x) { return 0; } +int main (int argc, char *argv[]) +{ + long double (*my_log1pl) (long double) = argc ? log1pl : dummy; + /* This test fails on AIX 7.1, IRIX 6.5. */ + long double y = my_log1pl (minus_zerol); + if (!(y == 0.0L) || (signbitl (minus_zerol) && !signbitl (y))) + return 1; + return 0; +} + ]])], + [gl_cv_func_log1pl_ieee=yes], + [gl_cv_func_log1pl_ieee=no], + [gl_cv_func_log1pl_ieee="guessing no"]) + LIBS="$save_LIBS" + ]) + case "$gl_cv_func_log1pl_ieee" in + *yes) ;; + *) REPLACE_LOG1PL=1 ;; + esac + fi + ]) else HAVE_LOG1PL=0 dnl Find libraries needed to link lib/log1pl.c. diff --git a/m4/math_h.m4 b/m4/math_h.m4 index d832e588b..2c43edb17 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 99 +# math_h.m4 serial 100 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, @@ -272,6 +272,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P]) REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) + REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL]) REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL]) diff --git a/modules/log1pl b/modules/log1pl index beb4dd50d..7a47d4d03 100644 --- a/modules/log1pl +++ b/modules/log1pl @@ -8,14 +8,14 @@ m4/log1pl.m4 Depends-on: math extensions -log1p [test $HAVE_LOG1PL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] -isnanl [test $HAVE_LOG1PL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] -logl [test $HAVE_LOG1PL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] -roundl [test $HAVE_LOG1PL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +log1p [{ test $HAVE_LOG1PL = 0 || test $REPLACE_LOG1PL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] +isnanl [{ test $HAVE_LOG1PL = 0 || test $REPLACE_LOG1PL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +logl [{ test $HAVE_LOG1PL = 0 || test $REPLACE_LOG1PL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +roundl [{ test $HAVE_LOG1PL = 0 || test $REPLACE_LOG1PL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] configure.ac: gl_FUNC_LOG1PL -if test $HAVE_LOG1PL = 0; then +if test $HAVE_LOG1PL = 0 || test $REPLACE_LOG1PL = 1; then AC_LIBOBJ([log1pl]) fi gl_MATH_MODULE_INDICATOR([log1pl]) diff --git a/modules/log1pl-ieee b/modules/log1pl-ieee index f2904975e..32c937d19 100644 --- a/modules/log1pl-ieee +++ b/modules/log1pl-ieee @@ -2,12 +2,16 @@ Description: log1pl() function according to ISO C 99 with IEC 60559. Files: +m4/log1pl-ieee.m4 +m4/minus-zero.m4 +m4/signbit.m4 Depends-on: log1pl fpieee configure.ac: +gl_FUNC_LOG1PL_IEEE Makefile.am: diff --git a/modules/math b/modules/math index cbd86cd77..4f66c4d47 100644 --- a/modules/math +++ b/modules/math @@ -240,6 +240,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \ -e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \ -e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \ + -e 's|@''REPLACE_LOG1PL''@|$(REPLACE_LOG1PL)|g' \ -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \ -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \ -e 's|@''REPLACE_MODFL''@|$(REPLACE_MODFL)|g' \