summaryrefslogtreecommitdiff
path: root/sysdeps/powerpc/fsetexcptflg.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/powerpc/fsetexcptflg.c')
-rw-r--r--sysdeps/powerpc/fsetexcptflg.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sysdeps/powerpc/fsetexcptflg.c b/sysdeps/powerpc/fsetexcptflg.c
index 4279b74849..b762552dbf 100644
--- a/sysdeps/powerpc/fsetexcptflg.c
+++ b/sysdeps/powerpc/fsetexcptflg.c
@@ -23,15 +23,26 @@ void
fesetexceptflag (const fexcept_t *flagp, int excepts)
{
fenv_union_t u;
+ fexcept_t flag;
/* Get the current state. */
u.fenv = fegetenv_register ();
+ /* Ignore exceptions not listed in 'excepts'. */
+ flag = *flagp & excepts;
+
/* Replace the exception status */
- u.l[1] = u.l[1] & FPSCR_STICKY_BITS | *flagp & FE_to_sticky (excepts);
+ u.l[1] = (u.l[1] & ~(FPSCR_STICKY_BITS & excepts)
+ | flag & FPSCR_STICKY_BITS
+ | (flag >> (31 - FPSCR_VX) - (31 - FPSCR_VXSOFT)
+ & FE_INVALID_SOFTWARE));
/* Store the new status word (along with the rest of the environment).
This may cause floating-point exceptions if the restored state
requests it. */
fesetenv_register (u.fenv);
+
+ /* Deal with FE_INVALID_SOFTWARE not being implemented on some chips. */
+ if (flag & FE_INVALID)
+ feraiseexcept(FE_INVALID);
}