.BR matherr ()
returns, the system then returns to the math function,
which in turn returns to the caller.
-
+.PP
The
.BR matherr ()
mechanism is supported by glibc, but is now obsolete:
This page documents the glibc
.BR matherr ()
mechanism as an aid for maintaining and porting older applications.
-
+.PP
To employ
.BR matherr (),
the programmer must define the
.B _SVID_
to the external variable
.BR _LIB_VERSION .
-
+.PP
The system provides a default version of
.BR matherr ().
This version does nothing, and returns zero
The function is invoked with one argument, a pointer to an
.I exception
structure, defined as follows:
-
+.PP
.in +4n
.nf
struct exception {
fields are the arguments supplied to the function
.RI ( arg2
is undefined for functions that take only one argument).
-
+.PP
The
.I retval
field specifies the return value that the math
The programmer-defined
.BR matherr ()
can modify this field to change the return value of the math function.
-
+.PP
If the
.BR matherr ()
function returns zero, then the system sets
.I errno
as described above, and may print an error message on standard error
(see below).
-
+.PP
If the
.BR matherr ()
function returns a nonzero value, then the system does not set
.BR matherr ().
The "Result" column is the default return value assigned to
.IR exc\->retval .
-
+.PP
The "Msg?" and "errno" columns describe the default behavior if
.BR matherr ()
returns zero.
If the "Msg?" columns contains "y",
then the system prints an error message on standard error.
-
+.PP
The table uses the following notations and abbreviations:
.RS
.nf
then it specifies an alternative return value that
.BR matherr ()
should assign as the return value of the math function.
-
+.PP
The following example run, where
.BR log (3)
is given an argument of 0.0, does not use
.BR matherr ():
-
+.PP
.in +4n
.nf
.RB "$" " ./a.out 0.0"
x=-inf
.fi
.in
-
+.PP
In the following run,
.BR matherr ()
is called, and returns 0:
-
+.PP
.in +4n
.nf
.RB "$" " ./a.out 0.0 0"
x=-340282346638528859811704183484516925440.000000
.fi
.in
-
+.PP
The message "log: SING error" was printed by the C library.
-
+.PP
In the following run,
.BR matherr ()
is called, and returns a nonzero value:
-
+.PP
.in +4n
.nf
.RB "$" " ./a.out 0.0 1"
x=-340282346638528859811704183484516925440.000000
.fi
.in
-
+.PP
In this case, the C library did not print a message, and
.I errno
was not set.
-
+.PP
In the following run,
.BR matherr ()
is called, changes the return value of the math function,
and returns a nonzero value:
-
+.PP
.in +4n
.nf
.RB "$" " ./a.out 0.0 1 12345.0"