SYNOPSIS

DESCRIPTION

This function provides easy exception handling to exploit
ANSI/IEEE Std 754-1985 arithmetic in a C program. The first
two arguments are pointers to strings. For efficiency,
results arising from invalid arguments and invalid combina-
tions are undefined.
There are three types of action : ``get'', ``set'', and
``clear''. There are five types of exception :
``inexact''
``division'' ... division by zero exception
``underflow''
``overflow''
``invalid''
``all'' ... all five exceptions above
``common'' ... invalid, overflow, and division
exceptions
Note: ``all'' and ``common'' only make sense with ``set'' or
``clear''.
hdl contains the address of a signal-handling routine.
<floatingpoint.h> defines sigfpe_handler_type .
``get'' will return the location of the current handler rou-
tine for exception cast to a long.
``set'' will set the routine pointed at by hdl to be the
handler routine and at the same time enable the trap on
exception, except when hdl == SIGFPE_DEFAULT or
SIGFPE_IGNORE; then ieee_handler() will disable the trap on
exception. When hdl == SIGFPE_ABORT, any trap on exception
will dump core using abort(3).
``clear'' disables trapping on exception and sets the
handler routine for exception to SIGFPE_DEFAULT. ``clear''
``all'' disables trapping on all five exceptions and sets
the handler routine for all five exceptions to
SIGFPE_DEFAULT.
Two steps are required to intercept an IEEE-related SIGFPE
code with ieee_handler:
1) Set up a handler with ieee_handler.
2) Perform a floating-point operation that generates the
intended IEEE exception.
ieee_handler() also adjusts floating-point hardware mode
bits affecting IEEE trapping. For ``clear'', ``set''
SIGFPE_DEFAULT, or ``set'' SIGFPE_IGNORE, the hardware trap
is disabled. For any other ``set'', the hardware trap is
enabled.
SIGFPE signals can be handled using sigaction(2)ieee_handler(3M), or fex_set_handling(3M).
In a particular program, to avoid confusion, use only one of
these interfaces to handle SIGFPE signals.

DIAGNOSTICS

ieee_handler() normally returns 0 for ``set''; 1 will be
returned if the action is not available (for instance, not
supported in hardware). For ``get'', the address of the
current handler is returned, cast to a long.

SEE ALSO

NOTES

On Intel systems, the floating point hardware traps whenever
an exception's trap is enabled (i.e., the exception is
"unmasked") and its corresponding flag is raised. Thus,
enabling a trap for an exception via ieee_handler() will
provoke a subsequent trap if the exception's flag is already
raised when ieee_handler() is called. To avoid such spuri-
ous traps, a program should clear the flags corresponding to
each exception for which trapping will be enabled before
calling ieee_handler(). (The ieee_flags(3M) function pro-
vides one way to clear exception flags.)