]> Savannah Git Hosting - gnulib.git/commitdiff
logb: Fix test failure on glibc/powerpc.
authorBruno Haible <bruno@clisp.org>
Wed, 6 Jan 2021 18:59:10 +0000 (19:59 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 6 Jan 2021 18:59:50 +0000 (19:59 +0100)
* doc/posix-functions/logb.texi: Update platform info.
* m4/logb.m4 (gl_FUNC_LOGB_WORKS): Test against bug with negative
subnormal numbers.

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

index b68667bcf3d363cc633d74d19970067f452accbd..0831c85e1cec6f70ac11f648b0f18b1485071c56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
 2021-01-06  Paul Eggert  <eggert@cs.ucla.edu>
 
        libc-config: simplify clang __has_* macros
index 799628da06f2c08100a6d9869807dd84b408313d..ea9b3f5f752b406266e4aec392c8ab94b0dd4b2e 100644 (file)
@@ -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:
index 68e2c854d6cfff896a6f53510398540515002646..cd803c10024a8aaab1f4e418bbb6af08d0d19d98 100644 (file)
@@ -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],