1.\" $OpenBSD: fegetenv.3,v 1.4 2018/03/16 16:58:26 schwarze Exp $ 2.\" 3.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: March 16 2018 $ 18.Dt FEGETENV 3 19.Os 20.Sh NAME 21.Nm fegetenv , 22.Nm feholdexcept , 23.Nm fesetenv , 24.Nm feupdateenv 25.Nd manage floating-point environment 26.Sh SYNOPSIS 27.In fenv.h 28.Ft int 29.Fn fegetenv "fenv_t *envp" 30.Ft int 31.Fn feholdexcept "fenv_t *envp" 32.Ft int 33.Fn fesetenv "const fenv_t *envp" 34.Ft int 35.Fn feupdateenv "const fenv_t *envp" 36.Sh DESCRIPTION 37These functions manage the floating-point environment \(em status 38flags, rounding direction modes and exception masks \(em as one entity. 39The 40.Fa envp 41input argument is an object representing the floating-point environment. 42The macro 43.Dv FE_DFL_ENV 44represents the default floating-point environment \(em the one installed 45at program startup. 46.Pp 47The 48.Fn fegetenv 49function stores the current floating-point environment in the object 50pointed to by 51.Pa envp . 52.Pp 53The 54.Fn feholdexcept 55function saves the current floating-point environment in the object 56pointed to by 57.Pa envp , 58clears the floating-point status flags, and then installs a non-stop 59(continue on floating-point exceptions) mode for all floating-point 60exceptions. 61.Pp 62The 63.Fn fesetenv 64function establishes the floating-point environment represented by 65the object pointed to by 66.Pa envp . 67The argument 68.Pa envp 69shall point to an object set by a call to 70.Fn fegetenv 71or 72.Fn feholdexcept , 73or equal the macro 74.Dv FE_DFL_ENV . 75Note that 76.Fn fesetenv 77merely installs the state of the floating-point status flags 78represented through its argument, and does not raise these 79floating-point exceptions. 80.Pp 81The 82.Fn feupdateenv 83function saves the currently raised floating-point exceptions in 84its automatic storage, installs the floating-point environment 85represented by the object pointed to by 86.Pa envp , 87and then raises the saved floating-point exceptions. 88The argument 89.Pa envp 90shall point to an object set by a call to 91.Fn feholdexcept 92or 93.Fn fegetenv , 94or equal the macro 95.Dv FE_DFL_ENV . 96.Sh RETURN VALUES 97The 98.Fn fegetenv , 99.Fn feholdexcept , 100.Fn fesetenv , 101and 102.Fn feupdateenv 103functions return zero on success, and non-zero if an error occurred. 104.Sh SEE ALSO 105.Xr feclearexcept 3 , 106.Xr feenableexcept 3 , 107.Xr fegetround 3 108.Sh STANDARDS 109The 110.Fn fegetenv , 111.Fn feholdexcept , 112.Fn fesetenv , 113and 114.Fn feupdateenv 115functions conform to 116.St -isoC-99 . 117.Pp 118The return types for 119.Fn fegetenv , 120.Fn fesetenv , 121and 122.Fn feupdateenv 123are 124.Vt int 125for alignment with 126.St -isoC-99 127Defect Report #202. 128