]> sourceware.org Git - glibc.git/blame - sysdeps/i386/fpu/fesetenv.c
Update.
[glibc.git] / sysdeps / i386 / fpu / fesetenv.c
CommitLineData
63551311 1/* Install given floating-point environment.
d111572f 2 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
63551311
UD
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
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 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include <fenv.h>
22
23#include <assert.h>
24
25
26void
27fesetenv (const fenv_t *envp)
28{
29 fenv_t temp;
30
31 /* The memory block used by fstenv/fldenv has a size of 28 bytes. */
32 assert (sizeof (fenv_t) == 28);
33
34 /* Install the environment specified by ENVP. But there are a few
35 values which we do not want to come from the saved environment.
36 Therefore, we get the current environment and replace the values
37 we want to use from the environment specified by the parameter. */
38 __asm__ ("fnstenv %0" : "=m" (*&temp));
39
40 if (envp == FE_DFL_ENV)
41 {
42 temp.control_word |= FE_ALL_EXCEPT;
43 temp.control_word &= ~FE_TOWARDSZERO;
44 temp.status_word &= ~FE_ALL_EXCEPT;
45 temp.eip = 0;
46 temp.cs_selector = 0;
47 temp.opcode = 0;
48 temp.data_offset = 0;
49 temp.data_selector = 0;
50 }
51 else if (envp == FE_NOMASK_ENV)
52 {
d111572f 53 temp.control_word &= ~(FE_ALL_EXCEPT | FE_TOWARDZERO);
63551311
UD
54 temp.status_word &= ~FE_ALL_EXCEPT;
55 temp.eip = 0;
56 temp.cs_selector = 0;
57 temp.opcode = 0;
58 temp.data_offset = 0;
59 temp.data_selector = 0;
60 }
61 else
62 {
d111572f 63 temp.control_word &= ~(FE_ALL_EXCEPT | FE_TOWARDZERO);
63551311 64 temp.control_word |= (envp->control_word
d111572f 65 & (FE_ALL_EXCEPT | FE_TOWARDZERO));
63551311
UD
66 temp.status_word &= ~FE_ALL_EXCEPT;
67 temp.status_word |= envp->status_word & FE_ALL_EXCEPT;
68 temp.eip = envp->eip;
69 temp.cs_selector = envp->cs_selector;
70 temp.opcode = envp->opcode;
71 temp.data_offset = envp->data_offset;
72 temp.data_selector = envp->data_selector;
73 }
74
75 __asm__ ("fldenv %0" : : "m" (temp));
76}
This page took 0.044347 seconds and 5 git commands to generate.