xref: /freebsd/lib/msun/man/fegetenv.3 (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd May 8, 2004
28.Dt FEGETENV 3
29.Os
30.Sh NAME
31.Nm fegetenv ,
32.Nm feholdexcept ,
33.Nm fesetenv ,
34.Nm feupdateenv
35.Nd floating-point environment save and restore
36.Sh LIBRARY
37.Lb libm
38.Sh SYNOPSIS
39.In fenv.h
40.Fd "#pragma STDC FENV_ACCESS ON"
41.Ft int
42.Fn fegetenv "fenv_t *envp"
43.Ft int
44.Fn feholdexcept "fenv_t *envp"
45.Ft int
46.Fn fesetenv "const fenv_t *envp"
47.Ft int
48.Fn feupdateenv "const fenv_t *envp"
49.Sh DESCRIPTION
50The floating-point environment includes exception flags and masks, the
51current rounding mode, and other architecture-specific settings.
52However, it does not include the floating-point register file.
53.Pp
54The
55.Fn fegetenv
56function stores the current floating-point environment in the object
57pointed to by
58.Fa envp ,
59whereas
60.Fn feholdexcept
61saves the current environment, then clears all exception flags
62and masks all floating-point exceptions.
63.Pp
64The
65.Fn fesetenv
66function restores a previously saved environment.
67The
68.Fn feupdateenv
69function restores a saved environment as well, but it also
70raises any exceptions that were set in the environment it
71replaces.
72.Pp
73The
74.Fn feholdexcept
75function is often used with
76.Fn feupdateenv
77or
78.Fn fesetenv
79to suppress spurious exceptions that occur as a result of
80intermediate computations.
81An example in
82.Xr fenv 3
83demonstrates how to do this.
84.Sh RETURN VALUES
85The
86.Fn fegetenv ,
87.Fn feholdexcept ,
88.Fn fesetenv ,
89and
90.Fn feupdateenv
91functions return 0 if they succeed, and non-zero otherwise.
92.Sh SEE ALSO
93.Xr feclearexcept 3 ,
94.Xr fenv 3 ,
95.Xr feraiseexcept 3 ,
96.Xr fesetenv 3 ,
97.Xr fetestexcept 3 ,
98.Xr fpgetmask 3 ,
99.Xr fpgetprec 3 ,
100.Xr fpsetmask 3 ,
101.Xr fpsetprec 3
102.Sh STANDARDS
103The
104.Fn fegetenv ,
105.Fn feholdexcept ,
106.Fn fesetenv ,
107and
108.Fn feupdateenv
109functions conform to
110.St -isoC-99 .
111.Sh HISTORY
112These routines first appeared in
113.Fx 5.3 .
114