This is the mail archive of the glibc-bugs@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SPARC] glibc fraiseexcpt bug


Hello,

I found a bug in SPARC branch of the Glibc by using test-fenv program from the Glibc's testsuite. It comes from the issue #69 in the SPARC v9 errata ( http://www.sparc.com/standards/v9-errata.html ), but I detected on SuperSPARC (SPARC v8) cpu.

The issue is a wrong underflow exception raising. According to the errata, an underflow trap is called when the FPU result is subnormal. This works fine. But when the underflow trap is disabled, the FPU accumulated underflow is set only if the result is subnormal AND inexact. The original fraiseexception() function divided the smallest double number by 16 to raise underflow exception. This is correct when the trap is enabled, but does not work when the trap is disabled because the result is not inexact. I changed the divider to 6 and now it works in both cases ( test-fenv passes cleanly).

Regards,
Krzysztof Helt
--- glibc-2.3.2/sysdeps/sparc/fpu/fraiseexcpt.c.orig	2005-01-29 07:39:25.000000000 +0100
+++ glibc-2.3.2/sysdeps/sparc/fpu/fraiseexcpt.c	2005-01-29 07:39:57.000000000 +0100
@@ -27,9 +27,9 @@
 {
   static volatile double sink;
   static const struct {
-    double zero, one, max, min, sixteen, pi;
+    double zero, one, max, min, six, pi;
   } c = {
-    0.0, 1.0, DBL_MAX, DBL_MIN, 16.0, M_PI
+    0.0, 1.0, DBL_MAX, DBL_MIN, 6, M_PI
   };
 
   /* Raise exceptions represented by EXPECTS.  But we must raise only
@@ -52,7 +52,7 @@
 
   /* Next: underflow.  */
   if ((FE_UNDERFLOW & excepts) != 0)
-    sink = c.min / c.sixteen;
+    sink = c.min / c.six;
 
   /* Last: inexact.  */
   if ((FE_INEXACT & excepts) != 0)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]