diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-05-16 14:10:16 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-05-16 14:10:16 +0000 |
commit | e4899a03d1fd17fac542f34f2b3d3e0087b26908 (patch) | |
tree | 8c29dafd63320636b4b89385bf44d927653618b7 /libc/sysdeps/powerpc/fpu/fesetenv.c | |
parent | 0b586afcbc9a2e292ebf44d2f8f4b968ba82e10f (diff) |
Merge changes between r2162 and r2243 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@2244 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/powerpc/fpu/fesetenv.c')
-rw-r--r-- | libc/sysdeps/powerpc/fpu/fesetenv.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libc/sysdeps/powerpc/fpu/fesetenv.c b/libc/sysdeps/powerpc/fpu/fesetenv.c index ff82dfd17..5a0c742ff 100644 --- a/libc/sysdeps/powerpc/fpu/fesetenv.c +++ b/libc/sysdeps/powerpc/fpu/fesetenv.c @@ -1,5 +1,5 @@ /* Install given floating-point environment. - Copyright (C) 1997,99,2000,01,02 Free Software Foundation, Inc. + Copyright (C) 1997,99,2000,01,02,07 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,6 +23,26 @@ int __fesetenv (const fenv_t *envp) { + fenv_union_t old, new; + + /* get the currently set exceptions. */ + new.fenv = *envp; + old.fenv = fegetenv_register (); + + /* If the old env has no eabled exceptions and the new env has any enabled + exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put + the hardware into "precise mode" and may cause the FPU to run slower on + some hardware. */ + if ((old.l[1] & 0x000000F8) == 0 && (new.l[1] & 0x000000F8) != 0) + (void)__fe_nomask_env (); + + /* If the old env had any eabled exceptions and the new env has no enabled + exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the + FPU to run faster because it always takes the default action and can not + generate SIGFPE. */ + if ((old.l[1] & 0x000000F8) != 0 && (new.l[1] & 0x000000F8) == 0) + (void)__fe_mask_env (); + fesetenv_register (*envp); /* Success. */ |