diff options
author | Wilco <wdijkstr@arm.com> | 2014-05-15 15:18:40 +0100 |
---|---|---|
committer | Marcus Shawcroft <marcus.shawcroft@arm.com> | 2014-05-15 15:23:27 +0100 |
commit | 1a2f40e5d14ed6450696feacf04fca5eeceae7ef (patch) | |
tree | f08d34c9426d8833b6daef1509a1ac431e0b3c0b /sysdeps/arm/feenablxcpt.c | |
parent | cf26a0cb6a0bbaca46a01ddad6662e5e5159a32a (diff) | |
download | glibc-1a2f40e5d14ed6450696feacf04fca5eeceae7ef.tar glibc-1a2f40e5d14ed6450696feacf04fca5eeceae7ef.tar.gz glibc-1a2f40e5d14ed6450696feacf04fca5eeceae7ef.tar.bz2 glibc-1a2f40e5d14ed6450696feacf04fca5eeceae7ef.zip |
ARM: Improve fenv implementation
Diffstat (limited to 'sysdeps/arm/feenablxcpt.c')
-rw-r--r-- | sysdeps/arm/feenablxcpt.c | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/sysdeps/arm/feenablxcpt.c b/sysdeps/arm/feenablxcpt.c index b286ec5565..afd8943638 100644 --- a/sysdeps/arm/feenablxcpt.c +++ b/sysdeps/arm/feenablxcpt.c @@ -25,35 +25,27 @@ int feenableexcept (int excepts) { - if (ARM_HAVE_VFP) - { - unsigned long int new_exc, old_exc; - - _FPU_GETCW(new_exc); - - old_exc = (new_exc >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT; + fpu_control_t fpscr, new_fpscr; - excepts &= FE_ALL_EXCEPT; + /* Fail if a VFP unit isn't present. */ + if (!ARM_HAVE_VFP) + return -1; - new_exc |= (excepts << FE_EXCEPT_SHIFT); + _FPU_GETCW (fpscr); + excepts &= FE_ALL_EXCEPT; + new_fpscr = fpscr | (excepts << FE_EXCEPT_SHIFT); - _FPU_SETCW(new_exc); + _FPU_SETCW (new_fpscr); - if (excepts != 0) - { - /* VFPv3 and VFPv4 do not support trapping exceptions, so - test whether the relevant bits were set and fail if - not. */ - unsigned int temp; - _FPU_GETCW (temp); - if ((temp & (excepts << FE_EXCEPT_SHIFT)) - != (excepts << FE_EXCEPT_SHIFT)) - return -1; - } - - return old_exc; + if (excepts != 0) + { + /* Not all VFP architectures support trapping exceptions, so + test whether the relevant bits were set and fail if not. */ + _FPU_GETCW (new_fpscr); + if ((new_fpscr & (excepts << FE_EXCEPT_SHIFT)) + != (excepts << FE_EXCEPT_SHIFT)) + return -1; } - /* Unsupported, so return -1 for failure. */ - return -1; + return (fpscr >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT; } |