xref: /freebsd/lib/msun/man/feclearexcept.3 (revision 69d94f4c7608e41505996559367450706e91fbb8)
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 FECLEAREXCEPT 3
29.Os
30.Sh NAME
31.Nm feclearexcept ,
32.Nm fegetexceptflag ,
33.Nm feraiseexcept ,
34.Nm fesetexceptflag ,
35.Nm fetestexcept
36.Nd floating-point exception flag manipulation
37.Sh LIBRARY
38.Lb libm
39.Sh SYNOPSIS
40.In fenv.h
41.Fd "#pragma STDC FENV_ACCESS ON"
42.Ft int
43.Fn feclearexcept "int excepts"
44.Ft int
45.Fn fegetexceptflag "fexcept_t *flagp" "int excepts"
46.Ft int
47.Fn feraiseexcept "int excepts"
48.Ft int
49.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts"
50.Ft int
51.Fn fetestexcept "int excepts"
52.Sh DESCRIPTION
53The
54.Fn feclearexcept
55routine clears the floating-point exception flags specified by
56.Fa excepts ,
57whereas
58.Fn feraiseexcept
59raises the specified exceptions.
60Raising an exception causes the corresponding flag to be set,
61and a
62.Dv SIGFPE
63is delivered to the process if the exception is unmasked.
64.Pp
65The
66.Fn fetestexcept
67function determines which flags are currently set, of those specified by
68.Fa excepts .
69.Pp
70The
71.Fn fegetexceptflag
72function stores the state of the exception flags specified in
73.Fa excepts
74in the opaque object pointed to by
75.Fa flagp .
76Similarly,
77.Fn fesetexceptflag
78changes the specified exception flags to reflect the state stored in
79the object pointed to by
80.Fa flagp .
81Note that the flags restored with
82.Fn fesetexceptflag
83must be a (not necessarily proper) subset of the flags recorded by
84a prior call to
85.Fn fegetexceptflag .
86.Pp
87For all of these functions, the possible types of exceptions
88include those described in
89.Xr fenv 3 .
90Some architectures may define other types of floating-point exceptions.
91.Sh IMPLEMENTATION NOTES
92On some architectures, raising an overflow or underflow exception
93also causes an inexact exception to be raised.
94In these cases, the overflow or underflow will be raised first.
95.Pp
96The
97.Fn fegetexceptflag
98and
99.Fn fesetexceptflag
100routines are preferred to
101.Fn fetestexcept
102and
103.Fn feraiseexcept ,
104respectively, for saving and restoring exception flags.
105The latter do not re-raise exceptions and may preserve
106architecture-specific information such as addresses where
107exceptions occurred.
108.Sh RETURN VALUES
109The
110.Fn feclearexcept ,
111.Fn fegetexceptflag ,
112.Fn feraiseexcept ,
113and
114.Fn fesetexceptflag
115functions return 0 upon success, and non-zero otherwise.
116The
117.Fn fetestexcept
118function returns the bitwise OR of the values of the current exception
119flags that were requested.
120.Sh SEE ALSO
121.Xr sigaction 2 ,
122.Xr feholdexcept 3 ,
123.Xr fenv 3 ,
124.Xr feupdateenv 3 ,
125.Xr fpgetsticky 3 ,
126.Xr fpresetsticky 3
127.Sh STANDARDS
128The
129.Fn feclearexcept ,
130.Fn fegetexceptflag ,
131.Fn feraiseexcept ,
132.Fn fesetexceptflag ,
133and
134.Fn fetestexcept
135routines conform to
136.St -isoC-99 .
137.Sh HISTORY
138These functions first appeared in
139.Fx 5.3 .
140