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