NOTES: Summarize the state of glibc support for exceptions

and errno for error reporting.
This commit is contained in:
Michael Kerrisk 2008-07-30 07:16:18 +00:00
parent c20fd28b48
commit bb5baf62e8
1 changed files with 19 additions and 14 deletions

View File

@ -21,7 +21,7 @@
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.TH MATH_ERROR 7 2008-07-21 "Linux" "Linux Programmer's Manual"
.TH MATH_ERROR 7 2008-07-30 "Linux" "Linux Programmer's Manual"
.SH NAME
math_error \- detecting errors from mathematical functions
.SH SYNOPSIS
@ -48,18 +48,6 @@ as outlined below)
described in
.BR fenv (3).
C99 and POSIX.1-2001 specify a
.I math_errhandling
identifier,
which is supposed to indicate which of these two mechanisms is in use;
the standards require that at least one be in use,
but permit both to be available.
Although glibc does not support this identifier,
in practice it supports both mechanisms.
.\" I've tested glibc 2.3.3 and glibc 2.8, and both seem to support
.\" both mechanisms. A quick look at the glibc source code suggests
.\" that support goes back to glibc 2.1 at least. -- mtk, Jul 08
A portable program that needs to check for an error from a mathematical
function should set
.I errno
@ -196,8 +184,25 @@ or more leading zeros in the significand.
.SH NOTES
The
.I math_errhandling
identifier specified by C99 and POSIX.1-2001 is not supported.
identifier specified by C99 and POSIX.1-2001 is not supported by glibc.
.\" See CONFORMANCE in the glibc 2.8 (and earlier) source.
This identifer is supposed to indicate which of the two
error-notification mechanisms
.RI ( errno ,
exceptions retrievable via
.BR fettestexcept (3))
is in use.
The standards require that at least one be in use,
but permit both to be available.
The current (version 2.8) situation under glibc is messy.
Most (but not all) functions raise exceptions on errors.
Some also set
.IR errno .
A few functions set
.IR errno ,
but don't raise an exception.
A very few functions do neither.
See the individual manual pages for details.
To avoid the complexities of using
.I errno