]> Savannah Git Hosting - gnulib.git/commitdiff
fmaf: Work around a bug on FreeBSD 12.2/arm.
authorBruno Haible <bruno@clisp.org>
Wed, 9 Dec 2020 23:15:42 +0000 (00:15 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 9 Dec 2020 23:17:49 +0000 (00:17 +0100)
* m4/fmaf.m4 (gl_FUNC_FMAF_WORKS): Add one more test.
* doc/posix-functions/fmaf.texi: Mention the FreeBSD bug.

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

index 45aa98528b457b9d137b9a556ee1cac584d12801..8c05ee6e9e222e083e45b4e7508a20eaf0a8efec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-09  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        threadlib: Fix test-fstrcmp failure on FreeBSD 11.
index 0515acd365da7a12723ce9aca5d01f102b062067..1e0d34a11dcef9141cf90ecbd2571a895af40774 100644 (file)
@@ -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:
index bad747ebc6ae9418989ddd9a016bfa897a4a38f4..4387d574cb7a0af07893244549cbf616456272c8 100644 (file)
@@ -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],