xref: /netbsd/lib/libm/man/feclearexcept.3 (revision ab7858d6)
1.\"	$NetBSD: feclearexcept.3,v 1.2 2010/08/07 18:13:12 wiz Exp $
2.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.Dd May 8, 2004
27.Dt FECLEAREXCEPT 3
28.Os
29.Sh NAME
30.Nm feclearexcept ,
31.Nm fegetexceptflag ,
32.Nm feraiseexcept ,
33.Nm fesetexceptflag ,
34.Nm fetestexcept
35.Nd floating-point exception flag manipulation
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 feclearexcept "int excepts"
43.Ft int
44.Fn fegetexceptflag "fexcept_t *flagp" "int excepts"
45.Ft int
46.Fn feraiseexcept "int excepts"
47.Ft int
48.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts"
49.Ft int
50.Fn fetestexcept "int excepts"
51.Sh DESCRIPTION
52The
53.Fn feclearexcept
54routine clears the floating-point exception flags specified by
55.Fa excepts ,
56whereas
57.Fn feraiseexcept
58raises the specified exceptions.
59Raising an exception causes the corresponding flag to be set,
60and a
61.Dv SIGFPE
62is delivered to the process if the exception is unmasked.
63.Pp
64The
65.Fn fetestexcept
66function determines which flags are currently set, of those specified by
67.Fa excepts .
68.Pp
69The
70.Fn fegetexceptflag
71function stores the state of the exception flags specified in
72.Fa excepts
73in the opaque object pointed to by
74.Fa flagp .
75Similarly,
76.Fn fesetexceptflag
77changes the specified exception flags to reflect the state stored in
78the object pointed to by
79.Fa flagp .
80Note that the flags restored with
81.Fn fesetexceptflag
82must be a (not necessarily proper) subset of the flags recorded by
83a prior call to
84.Fn fegetexceptflag .
85.Pp
86For all of these functions, the possible types of exceptions
87include those described in
88.Xr fenv 3 .
89Some architectures may define other types of floating-point exceptions.
90.Sh IMPLEMENTATION NOTES
91On some architectures, raising an overflow or underflow exception
92also causes an inexact exception to be raised.
93In these cases, the overflow or underflow will be raised first.
94.Pp
95The
96.Fn fegetexceptflag
97and
98.Fn fesetexceptflag
99routines are preferred to
100.Fn fetestexcept
101and
102.Fn feraiseexcept ,
103respectively, for saving and restoring exception flags.
104The latter do not re-raise exceptions and may preserve
105architecture-specific information such as addresses where
106exceptions occurred.
107.Sh RETURN VALUES
108The
109.Fn feclearexcept ,
110.Fn fegetexceptflag ,
111.Fn feraiseexcept ,
112and
113.Fn fesetexceptflag
114functions return 0 upon success, and non-zero otherwise.
115The
116.Fn fetestexcept
117function returns the bitwise OR of the values of the current exception
118flags that were requested.
119.Sh SEE ALSO
120.Xr sigaction 2 ,
121.Xr feholdexcept 3 ,
122.Xr fenv 3 ,
123.Xr feupdateenv 3 ,
124.Xr fpgetsticky 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
138and
139.Nx 6.0 .
140