[PATCH] sparc: Force calculation that raises exception
Daniel Cederman
cederman@gaisler.com
Fri Jan 12 09:26:25 GMT 2024
Read out the FPU control word to force the calculation to complete and
raise the exception.
With this change the math/test-fenv test pass for LEON.
Signed-off-by: Daniel Cederman <cederman@gaisler.com>
---
sysdeps/sparc/fpu/fraiseexcpt.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sysdeps/sparc/fpu/fraiseexcpt.c b/sysdeps/sparc/fpu/fraiseexcpt.c
index 26a7720ec9..43176cf6a3 100644
--- a/sysdeps/sparc/fpu/fraiseexcpt.c
+++ b/sysdeps/sparc/fpu/fraiseexcpt.c
@@ -20,6 +20,7 @@
#include <float.h>
#include <math.h>
#include <shlib-compat.h>
+#include <fpu_control.h>
int
__feraiseexcept (int excepts)
@@ -30,6 +31,7 @@ __feraiseexcept (int excepts)
0.0, 1.0, DBL_MAX, DBL_MIN, M_PI
};
double d;
+ fpu_control_t cw;
/* Raise exceptions represented by EXPECTS. But we must raise only
one signal at a time. It is important the if the overflow/underflow
@@ -43,6 +45,7 @@ __feraiseexcept (int excepts)
__asm ("" : "=e" (d) : "0" (c.zero));
d /= c.zero;
__asm __volatile ("" : : "e" (d));
+ _FPU_GETCW(cw);
}
/* Next: division by zero. */
@@ -51,6 +54,7 @@ __feraiseexcept (int excepts)
__asm ("" : "=e" (d) : "0" (c.one));
d /= c.zero;
__asm __volatile ("" : : "e" (d));
+ _FPU_GETCW(cw);
}
/* Next: overflow. */
@@ -59,6 +63,7 @@ __feraiseexcept (int excepts)
__asm ("" : "=e" (d) : "0" (c.max));
d *= d;
__asm __volatile ("" : : "e" (d));
+ _FPU_GETCW(cw);
}
/* Next: underflow. */
@@ -67,6 +72,7 @@ __feraiseexcept (int excepts)
__asm ("" : "=e" (d) : "0" (c.min));
d *= d;
__asm __volatile ("" : : "e" (d));
+ _FPU_GETCW(cw);
}
/* Last: inexact. */
@@ -75,6 +81,7 @@ __feraiseexcept (int excepts)
__asm ("" : "=e" (d) : "0" (c.one));
d /= c.pi;
__asm __volatile ("" : : "e" (d));
+ _FPU_GETCW(cw);
}
/* Success. */
--
2.40.1
More information about the Libc-alpha
mailing list