1feupdateenv(3M) Mathematical Library Functions feupdateenv(3M)
2
3
4
6 feupdateenv - update floating-point environment
7
9 c99 [ flag... ] file... -lm [ library... ]
10 #include <fenv.h>
11
12 int feupdateenv(const fenv_t *envp);
13
14
16 The feupdateenv() function attempts to save the currently raised float‐
17 ing-point exceptions in its automatic storage, attempts to install the
18 floating-point environment represented by the object pointed to by
19 envp, and then attempts to raise the saved floating-point exceptions.
20 The envp argument points to an object set by a call to fegetenv(3M) or
21 feholdexcept(3M), or equals a floating-point environment macro.
22
24 The feupdateenv() function returns 0 if and only if all the required
25 actions were successfully carried out.
26
28 No errors are defined.
29
31 The following example demonstrates sample code to hide spurious under‐
32 flow floating-point exceptions:
33
34 Example 1 Hide spurious underflow floating-point exceptions.
35
36 #include <fenv.h>
37 double f(double x)
38 {
39 # pragma STDC FENV_ACCESS ON
40 double result;
41 fenv_t save_env;
42 feholdexcept(&save_env);
43 // compute result
44 if (/* test spurious underflow */)
45 feclearexcept(FE_UNDERFLOW);
46 feupdateenv(&save_env);
47 return result;
48 }
49
50
52 See attributes(5) for descriptions of the following attributes:
53
54
55
56
57 ┌─────────────────────────────┬─────────────────────────────┐
58 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
59 ├─────────────────────────────┼─────────────────────────────┤
60 │Interface Stability │Standard │
61 ├─────────────────────────────┼─────────────────────────────┤
62 │MT-Level │MT-Safe │
63 └─────────────────────────────┴─────────────────────────────┘
64
66 fegetenv(3M), feholdexcept(3M), fenv.h(3HEAD), attributes(5), stan‐
67 dards(5)
68
70 In a multithreaded program, the feupdateenv() function affects the
71 floating point environment only for the calling thread.
72
73
74 When the FEX_CUSTOM handling mode is in effect for an exception, rais‐
75 ing that exception using feupdateenv() causes the handling function to
76 be invoked. The handling function can then modify the exception flags
77 to be set as described in fex_set_handling(3M). Any result value the
78 handler supplies will be ignored.
79
80
81 The feupdateenv() function automatically installs and deinstalls SIGFPE
82 handlers and sets and clears the trap enable mode bits in the floating
83 point status register as needed. If a program uses these functions and
84 attempts to install a SIGFPE handler or control the trap enable mode
85 bits independently, the resulting behavior is not defined.
86
87
88 As described in fex_set_handling(3M), when a handling function
89 installed in FEX_CUSTOM mode is invoked, all exception traps are dis‐
90 abled (and will not be reenabled while SIGFPE is blocked). Thus,
91 attempting to change the environment from within a handler by calling
92 fesetenv(3M) or feupdateenv might not produce the expected results.
93
94
95
96SunOS 5.11 12 Jul 2006 feupdateenv(3M)