]> Savannah Git Hosting - gnulib.git/commitdiff
modfl: Work around bug on NetBSD 9.3/arm64.
authorBruno Haible <bruno@clisp.org>
Thu, 18 Jan 2024 14:41:39 +0000 (15:41 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 31 Jan 2024 16:39:51 +0000 (17:39 +0100)
* m4/modfl.m4 (gl_FUNC_MODFL): Add test whether modfl basically works.
* doc/posix-functions/modfl.texi: Mention the NetBSD bug.

ChangeLog
doc/posix-functions/modfl.texi
m4/modfl.m4

index 70defaf6f7ec6028d4fda473cd9e8e2b6ae117a8..ccd67c1bb7e867bac32b83fbb978e38d30dda541 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-01-18  Bruno Haible  <bruno@clisp.org>
+
+       modfl: Work around bug on NetBSD 9.3/arm64.
+       * m4/modfl.m4 (gl_FUNC_MODFL): Add test whether modfl basically works.
+       * doc/posix-functions/modfl.texi: Mention the NetBSD bug.
+
 2024-01-18  Bruno Haible  <bruno@clisp.org>
 
        fmaf, fma, fmal: Work around bugs on OpenBSD 7.4/arm64.
index e789de26af908c1aa70bdba8727e0c38a2fa35d0..6a8a3ef47650b1ccdef126f528e6350ded6897ff 100644 (file)
@@ -14,6 +14,9 @@ FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 9
 @item
 This function is only defined as a macro with arguments on some platforms:
 MSVC 14.
+@item
+This function produces wrong results on some platforms:
+NetBSD 9.3/arm64.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{modfl-ieee}:
index 13116aaa92a66427d02674a61dafd5c9aed7f6ec..11b85cb38aad1df981fadd573f1914a79addbd89 100644 (file)
@@ -1,4 +1,4 @@
-# modfl.m4 serial 11
+# modfl.m4 serial 11.1
 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,51 @@ AC_DEFUN([gl_FUNC_MODFL],
   gl_MATHFUNC([modfl], [long double], [(long double, long double *)])
   if test $gl_cv_func_modfl_no_libm = yes \
      || test $gl_cv_func_modfl_in_libm = yes; then
-    :
+    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+    AC_CACHE_CHECK([whether modfl works],
+      [gl_cv_func_modfl_works],
+      [
+        saved_LIBS="$LIBS"
+        LIBS="$LIBS $MODFL_LIBM"
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+static long double dummy (long double x, long double *iptr) { return 0; }
+int main (int argc, char *argv[])
+{
+  long double (* volatile my_modfl) (long double, long double *) = argc ? modfl : dummy;
+  long double i;
+  long double f;
+  /* Test modfl(5.972406760L,...).
+     This test fails on NetBSD 9.3/arm64.  */
+  f = my_modfl (5.972406760L, &i);
+  if (!(f < 1.0L && i == 5.0L))
+    return 1;
+  return 0;
+}
+          ]])],
+          [gl_cv_func_modfl_works=yes],
+          [gl_cv_func_modfl_works=no],
+          [case "$host_os" in
+                                 # Guess yes on glibc systems.
+             *-gnu* | gnu*)      gl_cv_func_modfl_works="guessing yes" ;;
+                                 # Guess yes on musl systems.
+             *-musl* | midipix*) gl_cv_func_modfl_works="guessing yes" ;;
+                                 # Guess yes on native Windows.
+             mingw* | windows*)  gl_cv_func_modfl_works="guessing yes" ;;
+                                 # If we don't know, obey --enable-cross-guesses.
+             *)                  gl_cv_func_modfl_works="$gl_cross_guess_normal" ;;
+           esac
+          ])
+        LIBS="$saved_LIBS"
+      ])
+    case "$gl_cv_func_modfl_works" in
+      *yes) ;;
+      *) REPLACE_MODFL=1 ;;
+    esac
     m4_ifdef([gl_FUNC_MODFL_IEEE], [
       if test $gl_modfl_required = ieee && test $REPLACE_MODFL = 0; then
         AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles