Matherr(), 1. behavior of math exception handling – Comtrol eCos User Manual

Page 357

Advertising
background image

Chapter 13. C and math library overview

matherr()

As mentioned above, in X/Open or SVID modes, the user can supply a function

matherr()

of the form:

int

matherr

( struct exception *e )

where struct exception is defined as:

struct exception {

int type;

char *name;

double arg1, arg2, retval;

};

type is the exception type and is one of:

DOMAIN

argument domain exception

SING

argument singularity

OVERFLOW

overflow range exception

UNDERFLOW

underflow range exception

TLOSS

total loss of significance

PLOSS

partial loss of significance

name

is a string containing the name of the function

arg1

and

arg2

are the arguments passed to the function

retval

is the default value that will be returned by the function, and can be changed by

matherr()

Note: matherr must have “C” linkage, not “C

++

” linkage.

If matherr returns zero, or the user doesn’t supply their own matherr, then the following usually happens in SVID
mode:

Table 13-1. Behavior of math exception handling

Type

Behavior

253

Advertising