1 '\" te
   2 .\" Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
   3 .\" Portions Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
   4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at 
   5 .\" http://www.opengroup.org/bookstore/.
   6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   7 .\"  This notice shall appear on any product containing this material.
   8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  11 .TH feupdateenv 3M "12 Jul 2006" "SunOS 5.11" "Mathematical Library Functions"
  12 .SH NAME
  13 feupdateenv \- update floating-point environment
  14 .SH SYNOPSIS
  15 .LP
  16 .nf
  17 c99 [ \fIflag\fR... ] \fIfile\fR... \fB-lm\fR [ \fIlibrary\fR... ]
  18 #include <fenv.h>
  19 
  20 \fBint\fR \fBfeupdateenv\fR(\fBconst fenv_t *\fR\fIenvp\fR);
  21 .fi
  22 
  23 .SH DESCRIPTION
  24 .sp
  25 .LP
  26 The \fBfeupdateenv()\fR function attempts to save the currently raised
  27 floating-point exceptions in its automatic storage, attempts to install the
  28 floating-point environment represented by the object pointed to by \fIenvp\fR,
  29 and then attempts to raise the saved floating-point exceptions. The \fIenvp\fR
  30 argument points to an object set by a call to \fBfegetenv\fR(3M) or
  31 \fBfeholdexcept\fR(3M), or equals a floating-point environment macro.
  32 .SH RETURN VALUES
  33 .sp
  34 .LP
  35 The \fBfeupdateenv()\fR function returns 0 if and only if all the required
  36 actions were successfully carried out.
  37 .SH ERRORS
  38 .sp
  39 .LP
  40 No errors are defined.
  41 .SH EXAMPLES
  42 .sp
  43 .LP
  44 The following example demonstrates sample code to hide spurious underflow
  45 floating-point exceptions:
  46 .LP
  47 \fBExample 1 \fRHide spurious underflow floating-point exceptions.
  48 .sp
  49 .in +2
  50 .nf
  51 #include <fenv.h>
  52 double f(double x)
  53 {
  54 #   pragma STDC FENV_ACCESS ON
  55     double result;
  56     fenv_t save_env;
  57     feholdexcept(&save_env);
  58     // compute result
  59     if (/* test spurious underflow */)
  60     feclearexcept(FE_UNDERFLOW);
  61     feupdateenv(&save_env);
  62     return result;
  63 }
  64 .fi
  65 .in -2
  66 
  67 .SH ATTRIBUTES
  68 .sp
  69 .LP
  70 See \fBattributes\fR(5) for descriptions of the following attributes:
  71 .sp
  72 
  73 .sp
  74 .TS
  75 tab() box;
  76 cw(2.75i) |cw(2.75i) 
  77 lw(2.75i) |lw(2.75i) 
  78 .
  79 ATTRIBUTE TYPEATTRIBUTE VALUE
  80 _
  81 Interface StabilityStandard
  82 _
  83 MT-LevelMT-Safe
  84 .TE
  85 
  86 .SH SEE ALSO
  87 .sp
  88 .LP
  89 \fBfegetenv\fR(3M), \fBfeholdexcept\fR(3M), \fBfenv.h\fR(3HEAD),
  90 \fBattributes\fR(5), \fBstandards\fR(5)
  91 .SH NOTES
  92 .sp
  93 .LP
  94 In a multithreaded program, the \fBfeupdateenv()\fR function affects the
  95 floating point environment only for the calling thread.
  96 .sp
  97 .LP
  98 When the \fBFEX_CUSTOM\fR handling mode is in effect for an exception, raising
  99 that exception using \fBfeupdateenv()\fR causes the handling function to be
 100 invoked. The handling function can then modify the exception flags to be set as
 101 described in \fBfex_set_handling\fR(3M).  Any result value the handler supplies
 102 will be ignored.
 103 .sp
 104 .LP
 105 The \fBfeupdateenv()\fR function automatically installs and deinstalls
 106 \fBSIGFPE\fR handlers and sets and clears the trap enable mode bits in the
 107 floating point status register as needed. If a program uses these functions and
 108 attempts to install a \fBSIGFPE\fR handler or control the trap enable mode bits
 109 independently, the resulting behavior is not defined.
 110 .sp
 111 .LP
 112 As described in \fBfex_set_handling\fR(3M), when a handling function installed
 113 in \fBFEX_CUSTOM\fR mode is invoked, all exception traps are disabled (and will
 114 not be reenabled while \fBSIGFPE\fR is blocked). Thus, attempting to change the
 115 environment from within a handler by calling \fBfesetenv\fR(3M) or
 116 \fBfeupdateenv\fR might not produce the expected results.