Update copyright notices with scripts/update-copyrights.
[glibc.git] / sysdeps / powerpc / fpu / fesetenv.c
blob72989c476d0c586977440b603e259e32f91669af
1 /* Install given floating-point environment.
2 Copyright (C) 1997-2013 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, see
17 <http://www.gnu.org/licenses/>. */
19 #include <fenv_libc.h>
20 #include <fpu_control.h>
21 #include <bp-sym.h>
23 #define _FPU_MASK_ALL (_FPU_MASK_ZM | _FPU_MASK_OM | _FPU_MASK_UM | _FPU_MASK_XM | _FPU_MASK_IM)
25 int
26 __fesetenv (const fenv_t *envp)
28 fenv_union_t old, new;
30 /* get the currently set exceptions. */
31 new.fenv = *envp;
32 old.fenv = fegetenv_register ();
34 /* If the old env has no enabled exceptions and the new env has any enabled
35 exceptions, then unmask SIGFPE in the MSR FE0/FE1 bits. This will put the
36 hardware into "precise mode" and may cause the FPU to run slower on some
37 hardware. */
38 if ((old.l[1] & _FPU_MASK_ALL) == 0 && (new.l[1] & _FPU_MASK_ALL) != 0)
39 (void)__fe_nomask_env ();
41 /* If the old env had any enabled exceptions and the new env has no enabled
42 exceptions, then mask SIGFPE in the MSR FE0/FE1 bits. This may allow the
43 FPU to run faster because it always takes the default action and can not
44 generate SIGFPE. */
45 if ((old.l[1] & _FPU_MASK_ALL) != 0 && (new.l[1] & _FPU_MASK_ALL) == 0)
46 (void)__fe_mask_env ();
48 fesetenv_register (*envp);
50 /* Success. */
51 return 0;
54 #include <shlib-compat.h>
55 #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
56 strong_alias (__fesetenv, __old_fesetenv)
57 compat_symbol (libm, BP_SYM (__old_fesetenv), BP_SYM (fesetenv), GLIBC_2_1);
58 #endif
60 libm_hidden_ver (__fesetenv, fesetenv)
61 versioned_symbol (libm, BP_SYM (__fesetenv), BP_SYM (fesetenv), GLIBC_2_2);