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