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