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