]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
rintl: Override broken implementation on NetBSD.
authorBruno Haible <bruno@clisp.org>
Sun, 20 Jan 2019 23:33:28 +0000 (00:33 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 20 Jan 2019 23:33:28 +0000 (00:33 +0100)
* lib/math.in.h (rintl): Test also REPLACE_RINTL.
* m4/rintl.m4 (gl_FUNC_RINTL): Add test for negative arguments. Set
REPLACE_RINTL.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_RINTL.
* modules/math (Makefile.in): Substitute REPLACE_RINTL.
* modules/rintl (Depends-on, configure.ac): Test REPLACE_RINTL.
* doc/posix-functions/rintl.texi: Mention the NetBSD bug.

ChangeLog
doc/posix-functions/rintl.texi
lib/math.in.h
m4/math_h.m4
m4/rintl.m4
modules/math
modules/rintl

index 00516b2f85e2e2a08a87faefc4db190edfd7e173..3f40cc43ef4c7a3d688da4082ca8bdade90f39ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-01-20  Bruno Haible  <bruno@clisp.org>
+
+       rintl: Override broken implementation on NetBSD.
+       * lib/math.in.h (rintl): Test also REPLACE_RINTL.
+       * m4/rintl.m4 (gl_FUNC_RINTL): Add test for negative arguments. Set
+       REPLACE_RINTL.
+       * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_RINTL.
+       * modules/math (Makefile.in): Substitute REPLACE_RINTL.
+       * modules/rintl (Depends-on, configure.ac): Test REPLACE_RINTL.
+       * doc/posix-functions/rintl.texi: Mention the NetBSD bug.
+
 2019-01-20  Bruno Haible  <bruno@clisp.org>
 
        log10l: Work around inaccurate implementation on NetBSD.
index d843544bf91a14308d54f7d3a836f08facf7a4df..26f50f5b67f3cb1aa8b57b63cd90b91c2f1cf1aa 100644 (file)
@@ -11,6 +11,9 @@ Portability problems fixed by Gnulib:
 @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 1.5.x, MSVC 9, Interix 3.5, BeOS, Android 4.4.
+@item
+This function produces wrong results for negative numbers on some platforms:
+NetBSD 8.0.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 270caaf4c8ceea5ecc152392919274ee379dd314..aa03ea3a0468c307db84b6b8aa81267fdd906eed 100644 (file)
@@ -1845,10 +1845,19 @@ _GL_WARN_ON_USE (rint, "rint is unportable - "
 #endif
 
 #if @GNULIB_RINTL@
-# if !@HAVE_RINTL@
+# if @REPLACE_RINTL@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef rintl
+#   define rintl rpl_rintl
+#  endif
+_GL_FUNCDECL_RPL (rintl, long double, (long double x));
+_GL_CXXALIAS_RPL (rintl, long double, (long double x));
+# else
+#  if !@HAVE_RINTL@
 _GL_FUNCDECL_SYS (rintl, long double, (long double x));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (rintl, long double, (long double x));
+# endif
 _GL_CXXALIASWARN (rintl);
 #elif defined GNULIB_POSIXCHECK
 # undef rintl
index bbbe5d46b0e75a9d5d4f4edaf7bb062fc57a0180..3d5af84f518d2caa10230d718eef5eb22526a5cd 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 118
+# math_h.m4 serial 119
 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -320,6 +320,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   REPLACE_REMAINDER=0;         AC_SUBST([REPLACE_REMAINDER])
   REPLACE_REMAINDERF=0;        AC_SUBST([REPLACE_REMAINDERF])
   REPLACE_REMAINDERL=0;        AC_SUBST([REPLACE_REMAINDERL])
+  REPLACE_RINTL=0;             AC_SUBST([REPLACE_RINTL])
   REPLACE_ROUND=0;             AC_SUBST([REPLACE_ROUND])
   REPLACE_ROUNDF=0;            AC_SUBST([REPLACE_ROUNDF])
   REPLACE_ROUNDL=0;            AC_SUBST([REPLACE_ROUNDL])
index fc40a5bb1a1e8d52700e2f365e3243dcc74ef52e..66831191e47eeb179ad774e8bf7ac89194546bb9 100644 (file)
@@ -1,4 +1,4 @@
-# rintl.m4 serial 4
+# rintl.m4 serial 5
 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,9 +14,61 @@ AC_DEFUN([gl_FUNC_RINTL],
 
   dnl Determine RINTL_LIBM.
   gl_MATHFUNC([rintl], [long double], [(long double)])
-  if test $gl_cv_func_rintl_no_libm = no \
-     && test $gl_cv_func_rintl_in_libm = no; then
+  if test $gl_cv_func_rintl_no_libm = yes \
+     || test $gl_cv_func_rintl_in_libm = yes; then
+    if test $REPLACE_RINTL = 0; then
+      AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+      AC_CACHE_CHECK([whether rintl works],
+        [gl_cv_func_rintl_works],
+        [
+          save_LIBS="$LIBS"
+          LIBS="$LIBS $RINTL_LIBM"
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+#include <math.h>
+#undef rintl
+extern
+#ifdef __cplusplus
+"C"
+#endif
+long double rintl (long double);
+static long double dummy (long double x) { return 0; }
+int main (int argc, char *argv[])
+{
+  long double (* volatile my_rintl) (long double) = argc ? rintl : dummy;
+  int result = 0;
+  /* This test fails on NetBSD 8.0.  */
+  {
+    volatile long double x = -0.3L;
+    long double y = my_rintl (x);
+    if (!(y == 0.0L))
+      result |= 1;
+  }
+  return result;
+}
+            ]])],
+            [gl_cv_func_rintl_works=yes],
+            [gl_cv_func_rintl_works=no],
+            [case "$host_os" in
+                              # Guess yes on glibc systems.
+               *-gnu* | gnu*) gl_cv_func_rintl_works="guessing yes" ;;
+                              # Guess yes on native Windows.
+               mingw*)        gl_cv_func_rintl_works="guessing yes" ;;
+                              # If we don't know, assume the worst.
+               *)             gl_cv_func_rintl_works="guessing no" ;;
+             esac
+            ])
+          LIBS="$save_LIBS"
+        ])
+      case "$gl_cv_func_rintl_works" in
+        *yes) ;;
+        *) REPLACE_RINTL=1 ;;
+      esac
+    fi
+  else
     HAVE_RINTL=0
+  fi
+  if test $HAVE_RINTL = 0 || test $REPLACE_RINTL = 1; then
     dnl Find libraries needed to link lib/rintl.c.
     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
       AC_REQUIRE([gl_FUNC_RINT])
index 1f23a1787651a43b978f27e080bf43d3064fd779..0cdf8852cc24d0237ba6c942fb2c5cadf5b0df42 100644 (file)
@@ -290,6 +290,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \
              -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \
              -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \
+             -e 's|@''REPLACE_RINTL''@|$(REPLACE_RINTL)|g' \
              -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \
              -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \
              -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
index 0ca3f4429ec9769ae135bf5ba81092853ef1642a..cedabfdb79b4c8d29c7f35087b32e91b8f39a323 100644 (file)
@@ -10,11 +10,11 @@ m4/mathfunc.m4
 Depends-on:
 math
 extensions
-rint            [test $HAVE_RINTL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+rint            [{ test $HAVE_RINTL = 0 || test $REPLACE_RINTL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
 
 configure.ac:
 gl_FUNC_RINTL
-if test $HAVE_RINTL = 0; then
+if test $HAVE_RINTL = 0 || test $REPLACE_RINTL = 1; then
   AC_LIBOBJ([rintl])
 fi
 gl_MATH_MODULE_INDICATOR([rintl])