diff options
author | Wilco <wdijkstr@arm.com> | 2014-05-15 15:21:55 +0100 |
---|---|---|
committer | Marcus Shawcroft <marcus.shawcroft@arm.com> | 2014-05-15 15:23:27 +0100 |
commit | c0c08d02c82275353f5c556f935a1a01714d9d7f (patch) | |
tree | c850cda3edb23e165d7d96eb9d82fdc74b5554f1 /sysdeps/arm/fesetenv.c | |
parent | 1a2f40e5d14ed6450696feacf04fca5eeceae7ef (diff) | |
download | glibc-c0c08d02c82275353f5c556f935a1a01714d9d7f.tar glibc-c0c08d02c82275353f5c556f935a1a01714d9d7f.tar.gz glibc-c0c08d02c82275353f5c556f935a1a01714d9d7f.tar.bz2 glibc-c0c08d02c82275353f5c556f935a1a01714d9d7f.zip |
ARM: Improve fenv implementation
Diffstat (limited to 'sysdeps/arm/fesetenv.c')
-rw-r--r-- | sysdeps/arm/fesetenv.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/sysdeps/arm/fesetenv.c b/sysdeps/arm/fesetenv.c index 62031d596d..9e2aa81f9b 100644 --- a/sysdeps/arm/fesetenv.c +++ b/sysdeps/arm/fesetenv.c @@ -16,43 +16,43 @@ License along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */ -#include <fenv.h> -#include <fpu_control.h> +#include <fenv_private.h> #include <arm-features.h> int fesetenv (const fenv_t *envp) { - fpu_control_t fpscr; - /* Fail if a VFP unit isn't present. */ if (!ARM_HAVE_VFP) return 1; - _FPU_GETCW (fpscr); + if ((envp == FE_DFL_ENV) || (envp == FE_NOMASK_ENV)) + { + fpu_control_t fpscr, new_fpscr; + + _FPU_GETCW (fpscr); - /* Preserve the reserved FPSCR flags. */ - fpscr &= _FPU_RESERVED; + /* Preserve the reserved FPSCR flags. */ + new_fpscr = fpscr & _FPU_RESERVED; - if (envp == FE_DFL_ENV) - fpscr |= _FPU_DEFAULT; - else if (envp == FE_NOMASK_ENV) - fpscr |= _FPU_IEEE; - else - fpscr |= envp->__cw & ~_FPU_RESERVED; + if (envp == FE_DFL_ENV) + _FPU_SETCW (new_fpscr | _FPU_DEFAULT); + else + { + _FPU_SETCW (new_fpscr | _FPU_IEEE); + /* Not all VFP architectures support trapping exceptions, so + test whether the relevant bits were set and fail if not. */ + _FPU_GETCW (fpscr); - _FPU_SETCW (fpscr); + if ((fpscr & _FPU_IEEE) != _FPU_IEEE) + return 1; + } - if (envp == FE_NOMASK_ENV) - { - /* Not all VFP architectures support trapping exceptions, so - test whether the relevant bits were set and fail if not. */ - _FPU_GETCW (fpscr); - if ((fpscr & _FPU_IEEE) != _FPU_IEEE) - return 1; + return 0; } + libc_fesetenv_vfp (envp); return 0; } |