FPSIGNAL(3C) — Silicon Graphics
NAME
fpsignal - floating point exception handling system.
SYNOPSIS
#include <fperr.h>
fpsigset(handler,flag)
int (∗handler ());
int flag;
_raise_fperror(operation,type)
int operation,type;
_lraise_fperror(operation,type)
int operation,type;
DESCRIPTION
The routines of fpsignal are used to control handling of floating point exceptions. Routines for manipulating floating point numbers and routines in the math library call one of the routines _raise_fperror or _lraise_fperror (depending on the precision of the operation being performed), when erroneous input or other conditions are detected. These routines fill in the type, operation and precision field of the global structure _fperror and raise a SIGFPE exception using kill(2). The normal result of using kill is to abort with a core dump. This default handling may be altered by calling fpsigset with an optional user handler function (0 if none), and a flag word indicated the type of action to be performed upon receipt of a SIGFPE signal. Fpsigset installs its own handler to take control of the SIGFPE signal. The default action of this handler is to print a message on stderr indicating the error which occurred, and the routine causing it. In the case of errors from functions in the math library, the erroneous operand or the possibly erroneous result may be printed. The handler then aborts with a core dump.
The user may inhibit the message, the abort, or the core dump by setting bits in the second argument to fpsigset. The bit INHIBIT_DUMP will inhibit the core dump if an abort occurs. The bit CONTINUE_AFTER_FPERROR will cause processing to continue upon receipt of a SIGFPE signal. The bit INHIBIT_FPMESSAGE will inhibit the printing of any error message. Thus, if the user wants to totally ignore any floating point exceptions, calling fpsigset with the first argument zero and the second argument set to CONTINUE_AFTER_FPERROR|INHIBIT_FPMESSAGE will suffice.
Upon returning from the signal, the result found in the global error structure _fperror determines the result of the operation. In the case of floating point compare, the result in _fperror replaces the erroneous operand and the comparison is re-tried. In all other cases, the value in _fperror becomes the final result of the operation. Unless the signal arises from the math library (i.e., the operation field of _fperror is MATH) and its typecode is PARTIAL_SLOSS, the value in _fperror is set to zero in the early stage of handling the exception. In the case of MATH/PARTIAL_SLOSS, the possibly erroneous result which was calculated by the math routine is returned.
The user may specify a handler to be called when the signal is caught. If such a handler is specified, it is called prior to printing any message. The handler may, of course, set the value in _fperror in order to determine the result of the operation.
_Fpsignal distinguishes between each different erroneous condition which is specified in the IEEE draft standard. These error types are defined in the header file fperr.h, as are the definitions for the bits in the second argument to fpsigset, and the definition of the global error structure _fperror. The error types and conditions are more completely discussed in the paper IRIS Floating Point in the IRIS Workstation Guide.
SEE ALSO
IRIS Floating Point, IRIS Workstation Guide.
Version 2.1 — January 02, 1985