critical impact:
ieee_set_fp_control, ieee_get_fp_control - not supported; use fenv functions (CrUn120)
Problem description
The ieee_set_fp_control and ieee_get_fp_control functions exist
on Tru64 UNIX, but not on HP-UX. However, a replacement technology exists in the fenv suite of functions.
The Tru64 UNIX functions are in libc and use the <machine/fpu.h> header file. The HP-UX functions are in libm and use the <fenv.h> header file.
The ieee_set_fp_control function is used either to enable traps for floating-point exceptions or to override the default IEEE gradual underflow capability and instead map denormalized inputs and underflow results to zero.
The ieee_get_fp_control function is also used to detect exceptions by checking status flags that are set whenever floating-point exceptions occur.
Two features in the Tru64 UNIX functions do not have equivalent functions on HP-UX. The support for exceptions for denormal operands and the IEEE_INHERIT option, which makes newly created threads inherit the exception trap and status settings of their creating thread.
Identifiers
 ieee_get_fp_control |
 ieee_set_fp_control |
Old behavior
#include <machine/fpu.h>
/* Enable traps for divide by zero and map underflow results to zero. */
ieee_set_fp_control(IEEE_TRAP_ENABLE_DZE | IEEE_MAP_UMZ);
/* Check for overflows. */
if (ieee_get_fp_control() & IEEE_STATUS_OVF)
printf("overflow exception occurred\n");
See also
Solution description
Use the fenv suite of functions to achieve similar results and modify source code.
Replace the header file <machine/fpu.h> with the header file <fenv.h> and link against
libm. When using the ieee_set_fp_control function to enable traps for floating-point exceptions, replace it with the fesettrapenable function.
When using the ieee_set_fp_control function to to override the default IEEE gradual underflow, replace it with the fesetflushtozero function. Note that setting flush-to-zero mode on Itanium(R)-based systems only maps underflow results to zero. It does not map denormalized inputs to zero.
When using the ieee_get_fp_control function to detect exceptions by checking status flags that are set whenever floating-point exceptions occur, replace it with the fetestexcept function.
Review applicable manpages and code for more information. New behavior
The following example shows how to use the <fenv.h> header file:
#include <fenv.h>
/* Enable traps for divide by zero. */
fesettrapenable(FE_DIVBYZERO);
/* Set flush-to-zero mode, which maps underflow results to zero. */
fesetflushtozero(1);
/* Check for overflows. */
if (fetestexcept(FE_OVERFLOW))
printf("overflow exception occurred\n");
See also
Problem summary
| classifications |
source types |
OS release |
severity |
type |
| SIG |
C, C++ |
any HP-UX 11i version |
critical |
unavailable |
|