fp_setenv()

Set the floating point environment

Synopsis:

#include <fpstatus.h>

void fp_setenv( int rounding 
               int flags
               int fmask
               int exc
               int emask);

Arguments:

exc
Modify the thread's exception mask. This parameter is analogous with flags.
emask
Modify the thread's exception mask. This parameter is analogous with fmask. This is the same mask that's manipulated by the fp_exception_mask() function.
flags
Describe the sticky exception flags that are set or cleared. For each flag that's set in fmask, the corresponding sticky exception flag of the thread is set if that flag is also set in flags; otherwise, it's cleared. Sticky exception flags for which the corresponding flag isn't set in fmask are unchanged.
fmask
Describes the sticky exception flags that are set or cleared. For each flag that's set in fmask, the corresponding sticky exception flag of the thread is set if that flag is also set in flags; otherwise, it's cleared. Sticky exception flags for which the corresponding flag isn't set in fmask are unchanged.
rounding
The rounding mode. You can use -1 for unchanged. The rounding parameter is treated exactly as for the fp_rounding() function.

Library:

libm

Use the -l m option to qcc to link against this library.

Description:

Currently the fp_setenv() function is defined only for PPC (both SPE and non-SPE); it isn't defined for other architectures.

The fp_setenv() function is basically a combination of the functions fp_rounding() and fp_exception_mask() along with additional functionality. The fp_setenv() function permits:

  • the calling thread to set its floating point rounding mode
  • a change its set of currently set sticky exception flags
  • a change its set of enabled exceptions.
For all of the above situations, only the calling thread is affected.

The parameters flags, fmask, exc, and emaskall represent sets of flags. The flags are exactly the same as those described for the new_mask parameter of fp_exception_mask():

  • _FP_EXC_INVALID
  • _FP_EXC_DIVZERO
  • _FP_EXC_OVERFLOW
  • _FP_EXC_UNDERFLOW
  • _FP_EXC_INEXACT
  • _FP_EXC_DENORMAL

After fp_setenv() is called (directly or indirectly), exceptions that aren't masked will result in SIGFPE being delivered to the thread whenever the corresponding exception occurs. Regardless of whether an exception was masked, the corresponding sticky exception flag is set whenever the associated exception occurs. Once raised, sticky exception flags remain raised until they're cleared by the application thread.

Returns:

This function doesn't return any value. There is no error indication.

Examples:

Clear all sticky flags and allow SIGFPE for divide-by-zero (only); the rounding mode remains unchanged:

fp_setenv(-1, 0, _FP_EXC_ALL, _FP_EXC_DIVZERO, _FP_EXC_DIVZERO);

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes