From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: modfl: Work around bug on NetBSD 9.3/arm64
Date: Thu, 18 Jan 2024 15:44:59 +0100 [thread overview]
Message-ID: <65601940.3F2A3RajZp@nimes> (raw)
On NetBSD 9.3/arm64, I see this test failure:
$ ./test-modfl
../../gltests/test-modfl.c:48: assertion 'y >= 0.972406759L && y <= 0.972406761L' failed
Here x=5.97241, y=1.97241, z=4
instead of the expected x=5.97241, y=0.97241, z=5.
This patch provides a workaround.
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.
diff --git a/doc/posix-functions/modfl.texi b/doc/posix-functions/modfl.texi
index e789de26af..6a8a3ef476 100644
--- a/doc/posix-functions/modfl.texi
+++ b/doc/posix-functions/modfl.texi
@@ -14,6 +14,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}:
diff --git a/m4/modfl.m4 b/m4/modfl.m4
index b205f9f5a5..b22ecf178b 100644
--- a/m4/modfl.m4
+++ b/m4/modfl.m4
@@ -1,4 +1,4 @@
-# modfl.m4 serial 12
+# modfl.m4 serial 13
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
reply other threads:[~2024-01-18 14:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=65601940.3F2A3RajZp@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).