This is the mail archive of the libc-alpha@sourceware.org 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]

Re: [PATCH] Fix underflow reporting and tie up loose ends in sparcsoft-fp.


On 05/27/2012 09:16 PM, David Miller wrote:
-  if (exceptions&  FP_EX_INVALID)
-    d = p[0]/p[0];
-  if (exceptions&  FP_EX_OVERFLOW)
-    {
-      d = p[3] + p[3];
-      exceptions&= ~FP_EX_INEXACT;
-    }
-  if (exceptions&  FP_EX_UNDERFLOW)
-    {
-      if (exceptions&  FP_EX_INEXACT)
-        {
-	  d = p[2] * p[2];
-	  exceptions&= ~FP_EX_INEXACT;
-	}
-      else
-	d = p[1] - p[2];
-    }
-  if (exceptions&  FP_EX_DIVZERO)
-    d = 1.0/p[0];
-  if (exceptions&  FP_EX_INEXACT)
-    d = p[3] - p[2];
-  return d;
+  fpu_control_t fcw;
+  int tem, ou;
+
+  _FPU_GETCW(fcw);
+
+  tem = (fcw>>  23)&  0x1f;
+
+  ou = exceptions&  (FP_EX_OVERFLOW | FP_EX_UNDERFLOW);
+  if (ou&  tem)
+    exceptions&= ~FP_EX_INVALID;
+
+  fcw&= ~0x1f;
+  fcw |= (exceptions | (exceptions<<  5));
+
+  _FPU_SETCW(fcw);

The thing that the former code does that the later does not is raise SIGFPE in the event that the exception is not masked.


r~



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