]>
Commit | Line | Data |
---|---|---|
c72aa4a2 | 1 | /* Install given floating-point environment. |
6d7e8eda | 2 | Copyright (C) 1997-2023 Free Software Foundation, Inc. |
c72aa4a2 | 3 | This file is part of the GNU C Library. |
c72aa4a2 UD |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or | |
3214b89b AJ |
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. | |
c72aa4a2 UD |
9 | |
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 | |
3214b89b | 13 | Lesser General Public License for more details. |
c72aa4a2 | 14 | |
3214b89b | 15 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff | 16 | License along with the GNU C Library. If not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
c72aa4a2 UD |
18 | |
19 | #include <fenv.h> | |
20 | ||
146bade7 UD |
21 | int |
22 | __fesetenv (const fenv_t *envp) | |
c72aa4a2 UD |
23 | { |
24 | fenv_t temp; | |
25 | ||
26 | /* Install the environment specified by ENVP. But there are a few | |
27 | values which we do not want to come from the saved environment. | |
28 | Therefore, we get the current environment and replace the values | |
29 | we want to use from the environment specified by the parameter. */ | |
9c986f87 AS |
30 | #ifdef __mcoldfire__ |
31 | __asm__ ("fmove%.l %/fpcr,%0" : "=dm" (temp.__control_register)); | |
32 | __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (temp.__status_register)); | |
33 | __asm__ ("fmove%.l %/fpiar,%0" : "=dm" (temp.__instruction_address)); | |
34 | #else | |
053ed290 | 35 | __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*&temp)); |
9c986f87 | 36 | #endif |
c72aa4a2 | 37 | |
303e5382 AS |
38 | temp.__status_register &= ~FE_ALL_EXCEPT; |
39 | temp.__control_register &= ~((FE_ALL_EXCEPT << 6) | FE_UPWARD); | |
c72aa4a2 UD |
40 | if (envp == FE_DFL_ENV) |
41 | ; | |
42 | else if (envp == FE_NOMASK_ENV) | |
303e5382 | 43 | temp.__control_register |= FE_ALL_EXCEPT << 6; |
c72aa4a2 UD |
44 | else |
45 | { | |
303e5382 AS |
46 | temp.__control_register |= (envp->__control_register |
47 | & ((FE_ALL_EXCEPT << 6) | FE_UPWARD)); | |
48 | temp.__status_register |= envp->__status_register & FE_ALL_EXCEPT; | |
c72aa4a2 UD |
49 | } |
50 | ||
9c986f87 AS |
51 | #ifdef __mcoldfire__ |
52 | __asm__ __volatile__ ("fmove%.l %0,%/fpiar" | |
53 | :: "dm" (temp.__instruction_address)); | |
54 | __asm__ __volatile__ ("fmove%.l %0,%/fpcr" | |
55 | :: "dm" (temp.__control_register)); | |
56 | __asm__ __volatile__ ("fmove%.l %0,%/fpsr" | |
57 | :: "dm" (temp.__status_register)); | |
58 | #else | |
053ed290 | 59 | __asm__ __volatile__ ("fmovem%.l %0,%/fpcr/%/fpsr/%/fpiar" : : "m" (*&temp)); |
9c986f87 | 60 | #endif |
146bade7 UD |
61 | |
62 | /* Success. */ | |
63 | return 0; | |
c72aa4a2 | 64 | } |
60446d7a RM |
65 | |
66 | #include <shlib-compat.h> | |
67 | #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) | |
146bade7 | 68 | strong_alias (__fesetenv, __old_fesetenv) |
60446d7a RM |
69 | compat_symbol (libm, __old_fesetenv, fesetenv, GLIBC_2_1); |
70 | #endif | |
71 | ||
cd42798a | 72 | libm_hidden_def (__fesetenv) |
280ad607 | 73 | libm_hidden_ver (__fesetenv, fesetenv) |
60446d7a | 74 | versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2); |