From 4e2d5fa77b00e2a921673a48df58ec3add1a3c72 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 27 Feb 2012 21:06:30 +0100 Subject: [PATCH] remainderl-ieee: Work around test failure on OSF/1. * m4/remainderl-ieee.m4: New file. * m4/remainderl.m4 (gl_FUNC_REMAINDERL): If gl_FUNC_REMAINDERL_IEEE is present, test whether remainderl works with a zero second argument. Replace it if not. * lib/math.in.h (remainderl): Override if REPLACE_REMAINDERL is 1. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_REMAINDERL. * modules/math (Makefile.am): Substitute REPLACE_REMAINDERL. * modules/remainderl (configure.ac): Consider REPLACE_REMAINDERL. (Depends-on): Update conditions. * modules/remainderl-ieee (Files): Add m4/remainderl-ieee.m4. (Depends-on): Add remainder-ieee. (configure.ac): Invoke gl_FUNC_REMAINDERL_IEEE. * doc/posix-functions/remainderl.texi: Mention the remainderl-ieee module. --- ChangeLog | 16 ++++++++++++ doc/posix-functions/remainderl.texi | 11 ++++++-- lib/math.in.h | 13 ++++++++-- m4/math_h.m4 | 3 ++- m4/remainderl-ieee.m4 | 15 +++++++++++ m4/remainderl.m4 | 51 ++++++++++++++++++++++++++++++++++++- modules/math | 1 + modules/remainderl | 8 +++--- modules/remainderl-ieee | 3 +++ 9 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 m4/remainderl-ieee.m4 diff --git a/ChangeLog b/ChangeLog index 63dc9df28..a5da2d077 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2012-02-27 Bruno Haible + remainderl-ieee: Work around test failure on OSF/1. + * m4/remainderl-ieee.m4: New file. + * m4/remainderl.m4 (gl_FUNC_REMAINDERL): If gl_FUNC_REMAINDERL_IEEE is + present, test whether remainderl works with a zero second argument. + Replace it if not. + * lib/math.in.h (remainderl): Override if REPLACE_REMAINDERL is 1. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_REMAINDERL. + * modules/math (Makefile.am): Substitute REPLACE_REMAINDERL. + * modules/remainderl (configure.ac): Consider REPLACE_REMAINDERL. + (Depends-on): Update conditions. + * modules/remainderl-ieee (Files): Add m4/remainderl-ieee.m4. + (Depends-on): Add remainder-ieee. + (configure.ac): Invoke gl_FUNC_REMAINDERL_IEEE. + * doc/posix-functions/remainderl.texi: Mention the remainderl-ieee + module. + remainderf-ieee: Work around test failure on OSF/1. * m4/remainderf-ieee.m4: New file. * m4/remainderf.m4 (gl_FUNC_REMAINDERF): If gl_FUNC_REMAINDERF_IEEE is diff --git a/doc/posix-functions/remainderl.texi b/doc/posix-functions/remainderl.texi index bd05a6029..c0109881b 100644 --- a/doc/posix-functions/remainderl.texi +++ b/doc/posix-functions/remainderl.texi @@ -4,15 +4,22 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/remainderl.html} -Gnulib module: remainderl +Gnulib module: remainderl or remainderl-ieee -Portability problems fixed by Gnulib: +Portability problems fixed by either Gnulib module @code{remainderl} or @code{remainderl-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, OSF/1 4.0, Solaris 9, Cygwin, MSVC 9, Interix 3.5, BeOS. @end itemize +Portability problems fixed by Gnulib module @code{remainderl-ieee}: +@itemize +@item +This function has problems when the second argument is zero on some platforms: +OSF/1 5.1. +@end itemize + Portability problems not fixed by Gnulib: @itemize @end itemize diff --git a/lib/math.in.h b/lib/math.in.h index afd1b0a7d..ce527102d 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -1028,10 +1028,19 @@ _GL_WARN_ON_USE (remainder, "remainder is unportable - " #endif #if @GNULIB_REMAINDERL@ -# if !@HAVE_REMAINDERL@ +# if @REPLACE_REMAINDERL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef remainderl +# define remainderl rpl_remainderl +# endif +_GL_FUNCDECL_RPL (remainderl, long double, (long double x, long double y)); +_GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y)); +# else +# if !@HAVE_REMAINDERL@ _GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y)); -# endif +# endif _GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y)); +# endif _GL_CXXALIASWARN (remainderl); #elif defined GNULIB_POSIXCHECK # undef remainderl diff --git a/m4/math_h.m4 b/m4/math_h.m4 index e598ee132..6f9389dc1 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 70 +# math_h.m4 serial 71 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, @@ -230,6 +230,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER]) REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF]) + REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL]) REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) diff --git a/m4/remainderl-ieee.m4 b/m4/remainderl-ieee.m4 new file mode 100644 index 000000000..0715b236b --- /dev/null +++ b/m4/remainderl-ieee.m4 @@ -0,0 +1,15 @@ +# remainderl-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 remainderl.m4 and not inlined in the +dnl module description), so that gl_FUNC_REMAINDER can test whether 'aclocal' +dnl has found uses of this macro. + +AC_DEFUN([gl_FUNC_REMAINDERL_IEEE], +[ + m4_divert_text([INIT_PREPARE], [gl_remainderl_required=ieee]) + AC_REQUIRE([gl_FUNC_REMAINDERL]) +]) diff --git a/m4/remainderl.m4 b/m4/remainderl.m4 index 35f578c41..9bd2f3808 100644 --- a/m4/remainderl.m4 +++ b/m4/remainderl.m4 @@ -1,4 +1,4 @@ -# remainderl.m4 serial 1 +# remainderl.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_REMAINDERL], [ + m4_divert_text([DEFAULTS], [gl_remainderl_required=plain]) AC_REQUIRE([gl_MATH_H_DEFAULTS]) AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) AC_REQUIRE([gl_FUNC_REMAINDER]) @@ -34,8 +35,56 @@ AC_DEFUN([gl_FUNC_REMAINDERL], LIBS="$save_LIBS" if test $gl_cv_func_remainderl = yes; then REMAINDERL_LIBM="$REMAINDER_LIBM" + m4_ifdef([gl_FUNC_REMAINDERL_IEEE], [ + if test $gl_remainderl_required = ieee && test $REPLACE_REMAINDERL = 0; then + AC_CACHE_CHECK([whether remainderl works according to ISO C 99 with IEC 60559], + [gl_cv_func_remainderl_ieee], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $REMAINDERL_LIBM" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __NO_MATH_INLINES +# define __NO_MATH_INLINES 1 /* for glibc */ +#endif +#include +/* Compare two numbers with ==. + This is a separate function because IRIX 6.5 "cc -O" miscompiles an + 'x == x' test. */ +static int +numeric_equal (long double x, long double y) +{ + return x == y; +} +static long double dummy (long double x, long double y) { return 0; } +int main (int argc, char *argv[]) +{ + long double (*my_remainderl) (long double, long double) = argc ? remainderl : dummy; + long double i; + long double f; + /* Test remainderl(...,0.0L). + This test fails on OSF/1 5.1. */ + f = my_remainderl (2.0L, 0.0L); + if (numeric_equal (f, f)) + return 1; + return 0; +} + ]])], + [gl_cv_func_remainderl_ieee=yes], + [gl_cv_func_remainderl_ieee=no], + [gl_cv_func_remainderl_ieee="guessing no"]) + LIBS="$save_LIBS" + ]) + case "$gl_cv_func_remainderl_ieee" in + *yes) ;; + *) REPLACE_REMAINDERL=1 ;; + esac + fi + ]) else HAVE_REMAINDERL=0 + fi + if test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; then dnl Find libraries needed to link lib/remainderl.c. if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then REMAINDERL_LIBM="$REMAINDER_LIBM" diff --git a/modules/math b/modules/math index 0f498242a..6ffbe1982 100644 --- a/modules/math +++ b/modules/math @@ -200,6 +200,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \ -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \ -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \ + -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \ -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ diff --git a/modules/remainderl b/modules/remainderl index 20daae73d..20e249840 100644 --- a/modules/remainderl +++ b/modules/remainderl @@ -8,13 +8,13 @@ m4/mathfunc.m4 Depends-on: math -remainder [test $HAVE_REMAINDERL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] -roundl [test $HAVE_REMAINDERL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] -fmal [test $HAVE_REMAINDERL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +remainder [{ test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] +roundl [{ test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +fmal [{ test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] configure.ac: gl_FUNC_REMAINDERL -if test $HAVE_REMAINDERL = 0; then +if test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; then AC_LIBOBJ([remainderl]) fi gl_MATH_MODULE_INDICATOR([remainderl]) diff --git a/modules/remainderl-ieee b/modules/remainderl-ieee index 00f226c43..8b6d00d74 100644 --- a/modules/remainderl-ieee +++ b/modules/remainderl-ieee @@ -2,12 +2,15 @@ Description: remainderl() function according to ISO C 99 with IEC 60559. Files: +m4/remainderl-ieee.m4 Depends-on: remainderl fpieee +remainder-ieee [{ test $HAVE_REMAINDERL = 0 || test $REPLACE_REMAINDERL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] configure.ac: +gl_FUNC_REMAINDERL_IEEE Makefile.am: -- 2.11.0