xref: /netbsd-src/lib/libm/man/fegetenv.3 (revision 3b43a9401a5b6f1de7e9441c24b1bb6da04181d3)
1*3b43a940Swiz.\"	$NetBSD: fegetenv.3,v 1.2 2010/08/04 18:58:18 wiz Exp $
27f1183f2Sjoerg.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
37f1183f2Sjoerg.\" All rights reserved.
47f1183f2Sjoerg.\"
57f1183f2Sjoerg.\" Redistribution and use in source and binary forms, with or without
67f1183f2Sjoerg.\" modification, are permitted provided that the following conditions
77f1183f2Sjoerg.\" are met:
87f1183f2Sjoerg.\" 1. Redistributions of source code must retain the above copyright
97f1183f2Sjoerg.\"    notice, this list of conditions and the following disclaimer.
107f1183f2Sjoerg.\" 2. Redistributions in binary form must reproduce the above copyright
117f1183f2Sjoerg.\"    notice, this list of conditions and the following disclaimer in the
127f1183f2Sjoerg.\"    documentation and/or other materials provided with the distribution.
137f1183f2Sjoerg.\"
147f1183f2Sjoerg.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
157f1183f2Sjoerg.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
167f1183f2Sjoerg.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
177f1183f2Sjoerg.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
187f1183f2Sjoerg.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
197f1183f2Sjoerg.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
207f1183f2Sjoerg.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
217f1183f2Sjoerg.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
227f1183f2Sjoerg.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
237f1183f2Sjoerg.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
247f1183f2Sjoerg.\" SUCH DAMAGE.
257f1183f2Sjoerg.\"
267f1183f2Sjoerg.Dd May 8, 2004
277f1183f2Sjoerg.Dt FEGETENV 3
287f1183f2Sjoerg.Os
297f1183f2Sjoerg.Sh NAME
307f1183f2Sjoerg.Nm fegetenv ,
317f1183f2Sjoerg.Nm feholdexcept ,
327f1183f2Sjoerg.Nm fesetenv ,
337f1183f2Sjoerg.Nm feupdateenv
347f1183f2Sjoerg.Nd floating-point environment save and restore
357f1183f2Sjoerg.Sh LIBRARY
367f1183f2Sjoerg.Lb libm
377f1183f2Sjoerg.Sh SYNOPSIS
387f1183f2Sjoerg.In fenv.h
397f1183f2Sjoerg.Fd "#pragma STDC FENV_ACCESS ON"
407f1183f2Sjoerg.Ft int
417f1183f2Sjoerg.Fn fegetenv "fenv_t *envp"
427f1183f2Sjoerg.Ft int
437f1183f2Sjoerg.Fn feholdexcept "fenv_t *envp"
447f1183f2Sjoerg.Ft int
457f1183f2Sjoerg.Fn fesetenv "const fenv_t *envp"
467f1183f2Sjoerg.Ft int
477f1183f2Sjoerg.Fn feupdateenv "const fenv_t *envp"
487f1183f2Sjoerg.Sh DESCRIPTION
497f1183f2SjoergThe floating-point environment includes exception flags and masks, the
507f1183f2Sjoergcurrent rounding mode, and other architecture-specific settings.
517f1183f2SjoergHowever, it does not include the floating-point register file.
527f1183f2Sjoerg.Pp
537f1183f2SjoergThe
547f1183f2Sjoerg.Fn fegetenv
557f1183f2Sjoergfunction stores the current floating-point environment in the object
567f1183f2Sjoergpointed to by
577f1183f2Sjoerg.Fa envp ,
587f1183f2Sjoergwhereas
597f1183f2Sjoerg.Fn feholdexcept
607f1183f2Sjoergsaves the current environment, then clears all exception flags
617f1183f2Sjoergand masks all floating-point exceptions.
627f1183f2Sjoerg.Pp
637f1183f2SjoergThe
647f1183f2Sjoerg.Fn fesetenv
657f1183f2Sjoergfunction restores a previously saved environment.
667f1183f2SjoergThe
677f1183f2Sjoerg.Fn feupdateenv
687f1183f2Sjoergfunction restores a saved environment as well, but it also
697f1183f2Sjoergraises any exceptions that were set in the environment it
707f1183f2Sjoergreplaces.
717f1183f2Sjoerg.Pp
727f1183f2SjoergThe
737f1183f2Sjoerg.Fn feholdexcept
747f1183f2Sjoergfunction is often used with
757f1183f2Sjoerg.Fn feupdateenv
767f1183f2Sjoergor
777f1183f2Sjoerg.Fn fesetenv
787f1183f2Sjoergto suppress spurious exceptions that occur as a result of
797f1183f2Sjoergintermediate computations.
807f1183f2SjoergAn example in
817f1183f2Sjoerg.Xr fenv 3
827f1183f2Sjoergdemonstrates how to do this.
837f1183f2Sjoerg.Sh RETURN VALUES
847f1183f2SjoergThe
857f1183f2Sjoerg.Fn fegetenv ,
867f1183f2Sjoerg.Fn feholdexcept ,
877f1183f2Sjoerg.Fn fesetenv ,
887f1183f2Sjoergand
897f1183f2Sjoerg.Fn feupdateenv
907f1183f2Sjoergfunctions return 0 if they succeed, and non-zero otherwise.
917f1183f2Sjoerg.Sh SEE ALSO
927f1183f2Sjoerg.Xr feclearexcept 3 ,
937f1183f2Sjoerg.Xr fenv 3 ,
947f1183f2Sjoerg.Xr feraiseexcept 3 ,
957f1183f2Sjoerg.Xr fesetenv 3 ,
967f1183f2Sjoerg.Xr fetestexcept 3 ,
977f1183f2Sjoerg.Xr fpgetmask 3 ,
987f1183f2Sjoerg.\"Xr fpgetprec 3 ,
99*3b43a940Swiz.Xr fpsetmask 3
1007f1183f2Sjoerg.\"Xr fpsetprec 3
1017f1183f2Sjoerg.Sh STANDARDS
1027f1183f2SjoergThe
1037f1183f2Sjoerg.Fn fegetenv ,
1047f1183f2Sjoerg.Fn feholdexcept ,
1057f1183f2Sjoerg.Fn fesetenv ,
1067f1183f2Sjoergand
1077f1183f2Sjoerg.Fn feupdateenv
1087f1183f2Sjoergfunctions conform to
1097f1183f2Sjoerg.St -isoC-99 .
1107f1183f2Sjoerg.Sh HISTORY
1117f1183f2SjoergThese routines first appeared in
1127f1183f2Sjoerg.Fx 5.3
1137f1183f2Sjoergand
1147f1183f2Sjoerg.Nx 6.0 .
115