aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/arm/feenablxcpt.c
diff options
context:
space:
mode:
authorWilco <wdijkstr@arm.com>2014-05-15 15:18:40 +0100
committerMarcus Shawcroft <marcus.shawcroft@arm.com>2014-05-15 15:23:27 +0100
commit1a2f40e5d14ed6450696feacf04fca5eeceae7ef (patch)
treef08d34c9426d8833b6daef1509a1ac431e0b3c0b /sysdeps/arm/feenablxcpt.c
parentcf26a0cb6a0bbaca46a01ddad6662e5e5159a32a (diff)
downloadglibc-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.c42
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;
}