1 /* Install given floating-point environment.
2 Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by David Huggins-Daines <dhd@debian.org>, 2000
5 Based on the m68k version by
6 Andreas Schwab <schwab@suse.de>
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 fesetenv (const fenv_t
*envp
)
28 union { unsigned long long buf
[4]; fenv_t env
; } temp
;
29 unsigned long long *bufptr
;
31 /* Install the environment specified by ENVP. But there are a few
32 values which we do not want to come from the saved environment.
33 Therefore, we get the current environment and replace the values
34 we want to use from the environment specified by the parameter. */
37 "fstd,ma %%fr0,8(%1)\n"
38 : "=m" (temp
), "+r" (bufptr
) : : "%r0");
40 temp
.env
.__status_word
&= ~(FE_ALL_EXCEPT
41 | (FE_ALL_EXCEPT
<< 27)
43 if (envp
== FE_DFL_ENV
)
45 else if (envp
== FE_NOMASK_ENV
)
46 temp
.env
.__status_word
|= FE_ALL_EXCEPT
;
48 temp
.env
.__status_word
|= (envp
->__status_word
51 | (FE_ALL_EXCEPT
<< 27)));
53 /* Load the new environment. We use bufptr again since the
54 initial asm has modified the value of the register and here
55 we take advantage of that to load in reverse order so fr0
56 is loaded last and T-Bit is enabled. */
58 "fldd,mb -8(%1),%%fr0\n"
59 : "=m" (temp
), "+r" (bufptr
) : : "%r0" );
64 libm_hidden_def (fesetenv
)