]> Savannah Git Hosting - gnulib.git/commitdiff
remainderl-ieee: Work around test failure on OSF/1.
authorBruno Haible <bruno@clisp.org>
Mon, 27 Feb 2012 20:06:30 +0000 (21:06 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 27 Feb 2012 20:06:30 +0000 (21:06 +0100)
* 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
doc/posix-functions/remainderl.texi
lib/math.in.h
m4/math_h.m4
m4/remainderl-ieee.m4 [new file with mode: 0644]
m4/remainderl.m4
modules/math
modules/remainderl
modules/remainderl-ieee

index 63dc9df28b230f3c77cdb2ffc92ede92ea80e500..a5da2d0777d72c0205e05415b12e894506ec311d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2012-02-27  Bruno Haible  <bruno@clisp.org>
 
+       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
index bd05a6029c2fd5cafac9c0b04ec291a11a0d25fd..c0109881b5a6b8704e4b15c744fec1e9f15da1d3 100644 (file)
@@ -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
index afd1b0a7d3e8a8868307e2011cf1e0f1d04a2969..ce527102d9fe45a1871bb19d59f847d32c25f012 100644 (file)
@@ -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
index e598ee1327ce67a74719ac5c7fc39e656863a167..6f9389dc1864baec51b7a8d025a4e2c98e0d2980 100644 (file)
@@ -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 (file)
index 0000000..0715b23
--- /dev/null
@@ -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])
+])
index 35f578c41db70e3589e33782ed24187ebd6ca817..9bd2f3808b7c6fdb7a14556045bce5e937defcc7 100644 (file)
@@ -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 <math.h>
+/* 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"
index 0f498242aa229bfd1abaa4771336b68205aef3aa..6ffbe1982a2d03541a74651c3a83ec72807b70e7 100644 (file)
@@ -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' \
index 20daae73dfdad60b75a9efc98d03cca5632e3712..20e249840128b79785aaa2c435c3245e010d9518 100644 (file)
@@ -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])
index 00f226c43f962c1e4a9329fafa693bb8c0833b23..8b6d00d744973526a702882210e51a408692b139 100644 (file)
@@ -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: