diff options
author | Matheus Castanho <msc@linux.ibm.com> | 2020-03-03 15:20:38 -0300 |
---|---|---|
committer | Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> | 2020-03-06 11:10:12 -0300 |
commit | 1c252f0e7e5d78695f19450aa7c470bab445aa8e (patch) | |
tree | ff03c7d2393a6eae4cd7029ab44078508e94579e /sysdeps/powerpc/bits | |
parent | af09e5e5d9ec3ca20891e61a6922eac984fcbdc4 (diff) | |
download | glibc-1c252f0e7e5d78695f19450aa7c470bab445aa8e.tar glibc-1c252f0e7e5d78695f19450aa7c470bab445aa8e.tar.gz glibc-1c252f0e7e5d78695f19450aa7c470bab445aa8e.tar.bz2 glibc-1c252f0e7e5d78695f19450aa7c470bab445aa8e.zip |
powerpc: Fix feraiseexcept and feclearexcept macros
A recent change to fenvinline.h modified the check if __e is a
a power of 2 inside feraiseexcept and feclearexcept macros. It
introduced the use of the powerof2 macro but also removed the
if statement checking whether __e != 0 before issuing an mtfsb*
instruction. This is problematic because powerof2 (0) evaluates
to 1 and without the removed if __e is allowed to be 0 when
__builtin_clz is called. In that case the value 32 is passed
to __MTFSB*, which is invalid.
This commit uses __builtin_popcount instead of powerof2 to fix this
issue and avoid the extra check for __e != 0. This was the approach
used by the initial versions of that previous patch.
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Diffstat (limited to 'sysdeps/powerpc/bits')
-rw-r--r-- | sysdeps/powerpc/bits/fenvinline.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sysdeps/powerpc/bits/fenvinline.h b/sysdeps/powerpc/bits/fenvinline.h index 89ea38a4f8..f2d095a72f 100644 --- a/sysdeps/powerpc/bits/fenvinline.h +++ b/sysdeps/powerpc/bits/fenvinline.h @@ -75,7 +75,7 @@ int __e = __excepts; \ int __ret = 0; \ if (__builtin_constant_p (__e) \ - && powerof2 (__e) \ + && __builtin_popcount (__e) == 1 \ && __e != FE_INVALID) \ { \ __MTFSB1 ((__builtin_clz (__e))); \ @@ -91,7 +91,7 @@ int __e = __excepts; \ int __ret = 0; \ if (__builtin_constant_p (__e) \ - && powerof2 (__e) \ + && __builtin_popcount (__e) == 1 \ && __e != FE_INVALID) \ { \ __MTFSB0 ((__builtin_clz (__e))); \ |