[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
logb: Fix test failure on glibc/powerpc
From: |
Bruno Haible |
Subject: |
logb: Fix test failure on glibc/powerpc |
Date: |
Wed, 06 Jan 2021 20:02:29 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) |
On glibc/powerpc and glibc/powerpc64le (in glibc version 2.17) I'm seeing
this test failure:
FAIL: test-logb
There was a bug in logb() in glibc 2.11 with positive subnormal numbers.
They fixed that, but left a bug with negative subnormal numbers.
This patch adds a workaround.
2021-01-06 Bruno Haible <bruno@clisp.org>
logb: Fix test failure on glibc/powerpc.
* doc/posix-functions/logb.texi: Update platform info.
* m4/logb.m4 (gl_FUNC_LOGB_WORKS): Test against bug with negative
subnormal numbers.
diff --git a/doc/posix-functions/logb.texi b/doc/posix-functions/logb.texi
index 799628d..ea9b3f5 100644
--- a/doc/posix-functions/logb.texi
+++ b/doc/posix-functions/logb.texi
@@ -16,7 +16,7 @@ This function is missing a declaration on some platforms:
Cygwin 1.5.x.
@item
This function produces wrong results for subnormal numbers on some platforms:
-glibc 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 11.4, Cygwin 1.5.x.
+glibc 2.17/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 11.4, Cygwin 1.5.x.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/m4/logb.m4 b/m4/logb.m4
index 68e2c85..cd803c1 100644
--- a/m4/logb.m4
+++ b/m4/logb.m4
@@ -1,4 +1,4 @@
-# logb.m4 serial 8
+# logb.m4 serial 9
dnl Copyright (C) 2010-2021 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -87,6 +87,8 @@ dnl Test whether logb() works.
dnl On glibc 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 10/SPARC,
dnl Solaris 11.4/x86_64, Cygwin 1.5.x, the return value for subnormal
dnl (denormalized) arguments is too large.
+dnl On glibc 2.17/ppc likewise but only for negative subnormal (denormalized)
+dnl arguments.
AC_DEFUN([gl_FUNC_LOGB_WORKS],
[
AC_REQUIRE([AC_PROG_CC])
@@ -105,13 +107,27 @@ double logb (double);
volatile double x;
int main ()
{
- int i;
- for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
- ;
- /* Here i = DBL_MIN_EXP - 1. Either x = 2^(i-1) is subnormal or x = 0.0. */
- if (x > 0.0 && !(logb (x) == (double)(i - 1)))
- return 1;
- return 0;
+ int result = 0;
+ /* This test fails on 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa,
+ Solaris 10/SPARC, Solaris 11.4/x86_64, Cygwin 1.5.x. */
+ {
+ int i;
+ for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
+ ;
+ /* Here i = DBL_MIN_EXP - 1. Either x = 2^(i-1) is subnormal or x = 0.0.
*/
+ if (x > 0.0 && !(logb (x) == (double)(i - 1)))
+ result |= 1;
+ }
+ /* This test fails on glibc 2.17/ppc. */
+ {
+ int i;
+ for (i = 1, x = -1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
+ ;
+ /* Here i = DBL_MIN_EXP - 1. Either x = -2^(i-1) is subnormal or x = -0.0.
*/
+ if (x < 0.0 && !(logb (x) == (double)(i - 1)))
+ result |= 2;
+ }
+ return result;
}
]])],
[gl_cv_func_logb_works=yes],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- logb: Fix test failure on glibc/powerpc,
Bruno Haible <=