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/fesetround.c | |
parent | cf26a0cb6a0bbaca46a01ddad6662e5e5159a32a (diff) | |
download | glibc-1a2f40e5d14ed6450696feacf04fca5eeceae7ef.tar.gz glibc-1a2f40e5d14ed6450696feacf04fca5eeceae7ef.tar.xz glibc-1a2f40e5d14ed6450696feacf04fca5eeceae7ef.zip |
ARM: Improve fenv implementation
Diffstat (limited to 'sysdeps/arm/fesetround.c')
-rw-r--r-- | sysdeps/arm/fesetround.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/sysdeps/arm/fesetround.c b/sysdeps/arm/fesetround.c index 6f533d1992..d1b92dc255 100644 --- a/sysdeps/arm/fesetround.c +++ b/sysdeps/arm/fesetround.c @@ -24,30 +24,21 @@ int fesetround (int round) { - if (ARM_HAVE_VFP) - { - fpu_control_t temp; - - switch (round) - { - case FE_TONEAREST: - case FE_UPWARD: - case FE_DOWNWARD: - case FE_TOWARDZERO: - _FPU_GETCW (temp); - temp = (temp & ~FE_TOWARDZERO) | round; - _FPU_SETCW (temp); - return 0; - default: - return 1; - } - } - else if (round == FE_TONEAREST) - /* This is the only supported rounding mode for soft-fp. */ - return 0; - - /* Unsupported, so fail. */ - return 1; + fpu_control_t fpscr; + + /* FE_TONEAREST is the only supported rounding mode + if a VFP unit isn't present. */ + if (!ARM_HAVE_VFP) + return (round == FE_TONEAREST) ? 0 : 1; + + /* Fail if the rounding mode is not valid. */ + if (round & ~FE_TOWARDZERO) + return 1; + + _FPU_GETCW (fpscr); + fpscr = (fpscr & ~FE_TOWARDZERO) | round; + _FPU_SETCW (fpscr); + return 0; } libm_hidden_def (fesetround) |