Appendix E:
• A set of facilities is outlined below which provide the user with
control over floating point exception handling.
• An exception is triggered in either precision if an attempt is made to
print a not-a-number or infinity.
• The default handling of all floating point exceptions is to abort with
a core dump.
User control over floating point exceptions is provided by the C library
routine fpsigset(), and the global exception data structure _fperror. This structure
contains a floating point value and information about the circumstances
surrounding the exception. When a floating point exception is triggered, the
following events occur:
• The global structure is filled in with the exception type, the
operation in progress, and the precision of the operation. Unless
the operation is MATH, the data value in _fperror is set to zero.
• The standard UNIX exception SIGFPE is raised. This will abort with
a core dump unless a call has been made to fpsigset() (see below), or
the user has otherwise arranged for catching the signal.
• If the SIGFPE is caught and the exception is returned from, the data
value found in _fperror is returned to the routine which raised the
exception. In the case of floating point compare, this value replaces
the erroneous operand and the comparison is retried. In all other
cases (such as add, subtract, etc.), this value will become the result
of the operation, if one is needed.
User control over floating point exception processing consists of calling fpsigset().
fpsigset() takes two arguments. The first is a pointer to a user handler function,
or NULL if none. The second is a flag word in which individual bits indicate:
• whether an error message should be printed on stderr concerning
the exception.
• whether the process should abort at the end of processing the
exception.
• if the process is to abort, whether or not it should make a core
dump.
The file /usr/include/fperr.h contains the definitions for the various bits in this flag
word, as well as the definition for the _fperror structure.
fpsigset() sets a routine to catch the SIGFPE signal. When this routine gains
control, it will do the following:
• If a user handler was specified in the last call to fpsigset(), it will be
called. The user routine may diagnose the error by examining the
structure _fperror and alter the value for the result, if so desired. If
Version 1.0
IRIS WORKSTATION GUIDE
93
Need help?
Do you have a question about the IRIS Workstation and is the answer not in the manual?