]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix powerpc fesetexceptflag clearing FE_INVALID (bug 20455).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 10 Aug 2016 21:47:35 +0000 (21:47 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 10 Aug 2016 21:47:35 +0000 (21:47 +0000)
As shown by the test math/test-fexcept, the powerpc fesetexceptflag
implementation fails to clear a previously set FE_INVALID flag, when
that flag is clear in the saved exceptions and FE_INVALID is included
in the mask of flags to restore, because it fails to mask out the
sub-exceptions of FE_INVALID from the FPSCR state.  This patch fixes
the masking logic accordingly.

Tested for powerpc.

[BZ #20455]
* sysdeps/powerpc/fpu/fsetexcptflg.c (__fesetexceptflag): Mask out
all FE_INVALID sub-exceptions from FPSCR when FE_INVALID specified
to be restored.

ChangeLog
sysdeps/powerpc/fpu/fsetexcptflg.c

index 2cf36488c25314f9519aeee58738c9ff9269528a..6a2e39cfb2ca9ca6d9a80146176bbc424996e187 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2016-08-10  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #20455]
+       * sysdeps/powerpc/fpu/fsetexcptflg.c (__fesetexceptflag): Mask out
+       all FE_INVALID sub-exceptions from FPSCR when FE_INVALID specified
+       to be restored.
+
        * math/test-fexcept-traps.c: New file.
        * math/test-fexcept.c: Likewise.
        * math/Makefile (tests): Add test-fexcept and test-fexcept-traps.
index a06640593c7cae9ecd71b3a50a43042596767b83..cb440d570d0163d285aca82d7fe691998017c4ab 100644 (file)
@@ -31,7 +31,10 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts)
   flag = *flagp & excepts;
 
   /* Replace the exception status */
-  n.l = ((u.l & ~(FPSCR_STICKY_BITS & excepts))
+  int excepts_mask = FPSCR_STICKY_BITS & excepts;
+  if ((excepts & FE_INVALID) != 0)
+    excepts_mask |= FE_ALL_INVALID;
+  n.l = ((u.l & ~excepts_mask)
         | (flag & FPSCR_STICKY_BITS)
         | (flag >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
            & FE_INVALID_SOFTWARE));