From: Bruno Haible Date: Thu, 18 Jan 2024 14:41:39 +0000 (+0100) Subject: modfl: Work around bug on NetBSD 9.3/arm64. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e1a77ac1938cd8458f409a771c9fd58eed0b1e2c;p=gnulib.git 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/ChangeLog b/ChangeLog index 70defaf6f7..ccd67c1bb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-01-18 Bruno Haible + + 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 fmaf, fma, fmal: Work around bugs on OpenBSD 7.4/arm64. 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 @@ 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}: diff --git a/m4/modfl.m4 b/m4/modfl.m4 index 13116aaa92..11b85cb38a 100644 --- a/m4/modfl.m4 +++ b/m4/modfl.m4 @@ -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 +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