2.9
[glibc/nacl-glibc.git] / sysdeps / powerpc / fpu / fesetenv.c
blob5a0c742ffe7d818cac7442285b086f8d9f166f5e
1 /* Install given floating-point environment.
2 Copyright (C) 1997,99,2000,01,02,07 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <fenv_libc.h>
21 #include <bp-sym.h>
23 int
24 __fesetenv (const fenv_t *envp)
26 fenv_union_t old, new;
28 /* get the currently set exceptions. */
29 new.fenv = *envp;
30 old.fenv = fegetenv_register ();
32 /* If the old env has no eabled exceptions and the new env has any enabled
33 exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put
34 the hardware into "precise mode" and may cause the FPU to run slower on
35 some hardware. */
36 if ((old.l[1] & 0x000000F8) == 0 && (new.l[1] & 0x000000F8) != 0)
37 (void)__fe_nomask_env ();
39 /* If the old env had any eabled exceptions and the new env has no enabled
40 exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
41 FPU to run faster because it always takes the default action and can not
42 generate SIGFPE. */
43 if ((old.l[1] & 0x000000F8) != 0 && (new.l[1] & 0x000000F8) == 0)
44 (void)__fe_mask_env ();
46 fesetenv_register (*envp);
48 /* Success. */
49 return 0;
52 #include <shlib-compat.h>
53 #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
54 strong_alias (__fesetenv, __old_fesetenv)
55 compat_symbol (libm, BP_SYM (__old_fesetenv), BP_SYM (fesetenv), GLIBC_2_1);
56 #endif
58 libm_hidden_ver (__fesetenv, fesetenv)
59 versioned_symbol (libm, BP_SYM (__fesetenv), BP_SYM (fesetenv), GLIBC_2_2);