From: Bruno Haible Date: Wed, 9 Dec 2020 23:15:42 +0000 (+0100) Subject: fmaf: Work around a bug on FreeBSD 12.2/arm. X-Git-Tag: v1.0~3394 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=658d3920dd6d1e41efe8d1f3b7e22a356e3d709d;p=gnulib.git fmaf: Work around a bug on FreeBSD 12.2/arm. * m4/fmaf.m4 (gl_FUNC_FMAF_WORKS): Add one more test. * doc/posix-functions/fmaf.texi: Mention the FreeBSD bug. --- diff --git a/ChangeLog b/ChangeLog index 45aa98528b..8c05ee6e9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-12-09 Bruno Haible + + fmaf: Work around a bug on FreeBSD 12.2/arm. + * m4/fmaf.m4 (gl_FUNC_FMAF_WORKS): Add one more test. + * doc/posix-functions/fmaf.texi: Mention the FreeBSD bug. + 2020-12-09 Bruno Haible threadlib: Fix test-fstrcmp failure on FreeBSD 11. diff --git a/doc/posix-functions/fmaf.texi b/doc/posix-functions/fmaf.texi index 0515acd365..1e0d34a11d 100644 --- a/doc/posix-functions/fmaf.texi +++ b/doc/posix-functions/fmaf.texi @@ -13,7 +13,7 @@ This function is missing on some platforms: FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, MSVC 9. @item This function produces wrong results on some platforms: -glibc 2.11, Mac OS X 10.5, FreeBSD 6.4/x86, Cygwin 1.5, mingw. +glibc 2.11, Mac OS X 10.5, FreeBSD 6.4/x86, FreeBSD 12.2/arm, Cygwin 1.5, mingw. @end itemize Portability problems not fixed by Gnulib: diff --git a/m4/fmaf.m4 b/m4/fmaf.m4 index bad747ebc6..4387d574cb 100644 --- a/m4/fmaf.m4 +++ b/m4/fmaf.m4 @@ -1,4 +1,4 @@ -# fmaf.m4 serial 5 +# fmaf.m4 serial 6 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -167,6 +167,21 @@ int main() if (!(result == minus_inf)) failed_tests |= 64; } + /* This test fails on FreeBSD 12.2/arm. */ + if ((FLT_MANT_DIG % 2) == 0) + { + volatile float x = 1.0f + ldexpf (1.0f, - FLT_MANT_DIG / 2); /* 2^0 + 2^-12 */ + volatile float y = x; + volatile float z = - ldexpf (1.0f, FLT_MIN_EXP - FLT_MANT_DIG); /* 2^-149 */ + /* x * y + z with infinite precision: 2^0 + 2^-11 + 2^-24 - 2^-149. + Lies between (2^23 + 2^12 + 0) * 2^-23 and (2^23 + 2^12 + 1) * 2^-23 + and is closer to (2^23 + 2^12 + 0) * 2^-23, therefore the rounding + must round down and produce (2^23 + 2^12 + 0) * 2^-23. */ + volatile float expected = 1.0f + ldexpf (1.0f, 1 - FLT_MANT_DIG / 2); + volatile float result = fmaf (x, y, z); + if (result != expected) + failed_tests |= 32; + } return failed_tests; }]])], [gl_cv_func_fmaf_works=yes],