1*07235cc8SDavid Schultz.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org> 2*07235cc8SDavid Schultz.\" All rights reserved. 3*07235cc8SDavid Schultz.\" 4*07235cc8SDavid Schultz.\" Redistribution and use in source and binary forms, with or without 5*07235cc8SDavid Schultz.\" modification, are permitted provided that the following conditions 6*07235cc8SDavid Schultz.\" are met: 7*07235cc8SDavid Schultz.\" 1. Redistributions of source code must retain the above copyright 8*07235cc8SDavid Schultz.\" notice, this list of conditions and the following disclaimer. 9*07235cc8SDavid Schultz.\" 2. Redistributions in binary form must reproduce the above copyright 10*07235cc8SDavid Schultz.\" notice, this list of conditions and the following disclaimer in the 11*07235cc8SDavid Schultz.\" documentation and/or other materials provided with the distribution. 12*07235cc8SDavid Schultz.\" 13*07235cc8SDavid Schultz.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*07235cc8SDavid Schultz.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*07235cc8SDavid Schultz.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*07235cc8SDavid Schultz.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*07235cc8SDavid Schultz.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*07235cc8SDavid Schultz.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*07235cc8SDavid Schultz.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*07235cc8SDavid Schultz.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*07235cc8SDavid Schultz.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*07235cc8SDavid Schultz.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*07235cc8SDavid Schultz.\" SUCH DAMAGE. 24*07235cc8SDavid Schultz.\" 25*07235cc8SDavid Schultz.Dd May 8, 2004 26*07235cc8SDavid Schultz.Dt FEGETENV 3 27*07235cc8SDavid Schultz.Os 28*07235cc8SDavid Schultz.Sh NAME 29*07235cc8SDavid Schultz.Nm fegetenv , 30*07235cc8SDavid Schultz.Nm feholdexcept , 31*07235cc8SDavid Schultz.Nm fesetenv , 32*07235cc8SDavid Schultz.Nm feupdateenv 33*07235cc8SDavid Schultz.Nd floating-point environment save and restore 34*07235cc8SDavid Schultz.Sh LIBRARY 35*07235cc8SDavid Schultz.Lb libm 36*07235cc8SDavid Schultz.Sh SYNOPSIS 37*07235cc8SDavid Schultz.In fenv.h 38*07235cc8SDavid Schultz.Fd "#pragma STDC FENV_ACCESS ON" 39*07235cc8SDavid Schultz.Ft int 40*07235cc8SDavid Schultz.Fn fegetenv "fenv_t *envp" 41*07235cc8SDavid Schultz.Ft int 42*07235cc8SDavid Schultz.Fn feholdexcept "fenv_t *envp" 43*07235cc8SDavid Schultz.Ft int 44*07235cc8SDavid Schultz.Fn fesetenv "const fenv_t *envp" 45*07235cc8SDavid Schultz.Ft int 46*07235cc8SDavid Schultz.Fn feupdateenv "const fenv_t *envp" 47*07235cc8SDavid Schultz.Sh DESCRIPTION 48*07235cc8SDavid SchultzThe floating-point environment includes exception flags and masks, the 49*07235cc8SDavid Schultzcurrent rounding mode, and other architecture-specific settings. 50*07235cc8SDavid SchultzHowever, it does not include the floating-point register file. 51*07235cc8SDavid Schultz.Pp 52*07235cc8SDavid SchultzThe 53*07235cc8SDavid Schultz.Fn fegetenv 54*07235cc8SDavid Schultzfunction stores the current floating-point environment in the object 55*07235cc8SDavid Schultzpointed to by 56*07235cc8SDavid Schultz.Fa envp , 57*07235cc8SDavid Schultzwhereas 58*07235cc8SDavid Schultz.Fn feholdexcept 59*07235cc8SDavid Schultzsaves the current environment, then clears all exception flags 60*07235cc8SDavid Schultzand masks all floating-point exceptions. 61*07235cc8SDavid Schultz.Pp 62*07235cc8SDavid SchultzThe 63*07235cc8SDavid Schultz.Fn fesetenv 64*07235cc8SDavid Schultzfunction restores a previously saved environment. 65*07235cc8SDavid SchultzThe 66*07235cc8SDavid Schultz.Fn feupdateenv 67*07235cc8SDavid Schultzfunction restores a saved environment as well, but it also 68*07235cc8SDavid Schultzraises any exceptions that were set in the environment it 69*07235cc8SDavid Schultzreplaces. 70*07235cc8SDavid Schultz.Pp 71*07235cc8SDavid SchultzThe 72*07235cc8SDavid Schultz.Fn feholdexcept 73*07235cc8SDavid Schultzfunction is often used with 74*07235cc8SDavid Schultz.Fn feupdateenv 75*07235cc8SDavid Schultzor 76*07235cc8SDavid Schultz.Fn fesetenv 77*07235cc8SDavid Schultzto suppress spurious exceptions that occur as a result of 78*07235cc8SDavid Schultzintermediate computations. 79*07235cc8SDavid SchultzAn example in 80*07235cc8SDavid Schultz.Xr fenv 3 81*07235cc8SDavid Schultzdemonstrates how to do this. 82*07235cc8SDavid Schultz.Sh RETURN VALUES 83*07235cc8SDavid SchultzThe 84*07235cc8SDavid Schultz.Fn fegetenv , 85*07235cc8SDavid Schultz.Fn feholdexcept , 86*07235cc8SDavid Schultz.Fn fesetenv , 87*07235cc8SDavid Schultzand 88*07235cc8SDavid Schultz.Fn feupdateenv 89*07235cc8SDavid Schultzfunctions return 0 if they succeed, and non-zero otherwise. 90*07235cc8SDavid Schultz.Sh SEE ALSO 91*07235cc8SDavid Schultz.Xr feclearexcept 3 , 92*07235cc8SDavid Schultz.Xr fenv 3 , 93*07235cc8SDavid Schultz.Xr feraiseexcept 3 , 94*07235cc8SDavid Schultz.Xr fesetenv 3 , 95*07235cc8SDavid Schultz.Xr fetestexcept 3 , 96*07235cc8SDavid Schultz.Xr fpgetmask 3 , 97*07235cc8SDavid Schultz.Xr fpgetprec 3 , 98*07235cc8SDavid Schultz.Xr fpsetmask 3 , 99*07235cc8SDavid Schultz.Xr fpsetprec 3 100*07235cc8SDavid Schultz.Sh STANDARDS 101*07235cc8SDavid SchultzThe 102*07235cc8SDavid Schultz.Fn fegetenv , 103*07235cc8SDavid Schultz.Fn feholdexcept , 104*07235cc8SDavid Schultz.Fn fesetenv , 105*07235cc8SDavid Schultzand 106*07235cc8SDavid Schultz.Fn feupdateenv 107*07235cc8SDavid Schultzfunctions conform to 108*07235cc8SDavid Schultz.St -isoC-99 . 109*07235cc8SDavid Schultz.Sh HISTORY 110*07235cc8SDavid SchultzThese routines first appeared in 111*07235cc8SDavid Schultz.Fx 5.3 . 112