xref: /netbsd-src/lib/libm/man/feenableexcept.3 (revision 7f1183f22662bddb962efdc74570b0c3bac3d7d7)
1*7f1183f2Sjoerg.\"	$NetBSD: feenableexcept.3,v 1.1 2010/07/31 21:47:53 joerg Exp $
2*7f1183f2Sjoerg.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
3*7f1183f2Sjoerg.\" All rights reserved.
4*7f1183f2Sjoerg.\"
5*7f1183f2Sjoerg.\" Redistribution and use in source and binary forms, with or without
6*7f1183f2Sjoerg.\" modification, are permitted provided that the following conditions
7*7f1183f2Sjoerg.\" are met:
8*7f1183f2Sjoerg.\" 1. Redistributions of source code must retain the above copyright
9*7f1183f2Sjoerg.\"    notice, this list of conditions and the following disclaimer.
10*7f1183f2Sjoerg.\" 2. Redistributions in binary form must reproduce the above copyright
11*7f1183f2Sjoerg.\"    notice, this list of conditions and the following disclaimer in the
12*7f1183f2Sjoerg.\"    documentation and/or other materials provided with the distribution.
13*7f1183f2Sjoerg.\"
14*7f1183f2Sjoerg.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*7f1183f2Sjoerg.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*7f1183f2Sjoerg.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*7f1183f2Sjoerg.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*7f1183f2Sjoerg.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*7f1183f2Sjoerg.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*7f1183f2Sjoerg.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*7f1183f2Sjoerg.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*7f1183f2Sjoerg.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*7f1183f2Sjoerg.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*7f1183f2Sjoerg.\" SUCH DAMAGE.
25*7f1183f2Sjoerg.\"
26*7f1183f2Sjoerg.Dd March 16, 2005
27*7f1183f2Sjoerg.Dt FEENABLEEXCEPT 3
28*7f1183f2Sjoerg.Os
29*7f1183f2Sjoerg.Sh NAME
30*7f1183f2Sjoerg.Nm feenableexcept ,
31*7f1183f2Sjoerg.Nm fedisableexcept ,
32*7f1183f2Sjoerg.Nm fegetexcept
33*7f1183f2Sjoerg.Nd floating-point exception masking
34*7f1183f2Sjoerg.Sh LIBRARY
35*7f1183f2Sjoerg.Lb libm
36*7f1183f2Sjoerg.Sh SYNOPSIS
37*7f1183f2Sjoerg.In fenv.h
38*7f1183f2Sjoerg.Fd "#pragma STDC FENV_ACCESS ON"
39*7f1183f2Sjoerg.Ft int
40*7f1183f2Sjoerg.Fn feenableexcept "int excepts"
41*7f1183f2Sjoerg.Ft int
42*7f1183f2Sjoerg.Fn fedisableexcept "int excepts"
43*7f1183f2Sjoerg.Ft int
44*7f1183f2Sjoerg.Fn fegetexcept "void"
45*7f1183f2Sjoerg.Sh DESCRIPTION
46*7f1183f2SjoergThe
47*7f1183f2Sjoerg.Fn feenableexcept
48*7f1183f2Sjoergand
49*7f1183f2Sjoerg.Fn fedisableexcept
50*7f1183f2Sjoergfunctions
51*7f1183f2Sjoergunmask and mask (respectively) exceptions specified in
52*7f1183f2Sjoerg.Fa excepts .
53*7f1183f2SjoergThe
54*7f1183f2Sjoerg.Fn fegetexcept
55*7f1183f2Sjoergfunction
56*7f1183f2Sjoergreturns the current exception mask.
57*7f1183f2SjoergAll exceptions are masked by default.
58*7f1183f2Sjoerg.Pp
59*7f1183f2SjoergFloating-point operations that produce unmasked exceptions will trap, and a
60*7f1183f2Sjoerg.Dv SIGFPE
61*7f1183f2Sjoergwill be delivered to the process.
62*7f1183f2SjoergBy installing a signal handler for
63*7f1183f2Sjoerg.Dv SIGFPE ,
64*7f1183f2Sjoergapplications can take appropriate action immediately without
65*7f1183f2Sjoergtesting the exception flags after every operation.
66*7f1183f2SjoergNote that the trap may not be immediate, but it should occur
67*7f1183f2Sjoergbefore the next floating-point instruction is executed.
68*7f1183f2Sjoerg.Pp
69*7f1183f2SjoergFor all of these functions, the possible types of exceptions
70*7f1183f2Sjoerginclude those described in
71*7f1183f2Sjoerg.Xr fenv 3 .
72*7f1183f2SjoergSome architectures may define other types of floating-point exceptions.
73*7f1183f2Sjoerg.Sh RETURN VALUES
74*7f1183f2SjoergThe
75*7f1183f2Sjoerg.Fn feenableexcept ,
76*7f1183f2Sjoerg.Fn fedisableexcept ,
77*7f1183f2Sjoergand
78*7f1183f2Sjoerg.Fn fegetexcept
79*7f1183f2Sjoergfunctions return a bitmap of the exceptions that were unmasked
80*7f1183f2Sjoergprior to the call.
81*7f1183f2Sjoerg.Sh SEE ALSO
82*7f1183f2Sjoerg.Xr sigaction 2 ,
83*7f1183f2Sjoerg.Xr feclearexcept 3 ,
84*7f1183f2Sjoerg.Xr feholdexcept 3 ,
85*7f1183f2Sjoerg.Xr fenv 3 ,
86*7f1183f2Sjoerg.Xr feupdateenv 3
87*7f1183f2Sjoerg.Sh BUGS
88*7f1183f2SjoergFunctions in the standard library may trigger exceptions multiple
89*7f1183f2Sjoergtimes as a result of intermediate computations;
90*7f1183f2Sjoerghowever, they generally do not trigger spurious exceptions.
91*7f1183f2Sjoerg.Pp
92*7f1183f2SjoergNo interface is provided to permit exceptions to be handled in
93*7f1183f2Sjoergnontrivial ways.
94*7f1183f2SjoergThere is no uniform way for an exception handler to access
95*7f1183f2Sjoerginformation about the exception-causing instruction, or
96*7f1183f2Sjoergto determine whether that instruction should be reexecuted
97*7f1183f2Sjoergafter returning from the handler.
98