]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man3/matherr.3
fuse.4: ffix
[thirdparty/man-pages.git] / man3 / matherr.3
index bd48b1f0735bcdd32001877685aca5c571b0ef96..d7605a0553a533a5c08a4b0e3d4e0f9d43ec6788 100644 (file)
@@ -2,6 +2,7 @@
 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
 .\"     <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
-.TH MATHERR 3 2008-07-21 "Linux" "Linux Programmer's Manual"
+.TH MATHERR 3 2017-09-15 "Linux" "Linux Programmer's Manual"
 .SH NAME
 matherr \- SVID math library exception handling
 .SH SYNOPSIS
 .nf
-.B #define _SVID_SOURCE
 .B #include <math.h>
-
+.PP
 .BI "int matherr(struct exception *" exc );
-
+.PP
 .B extern _LIB_VERSION_TYPE _LIB_VERSION;
 .fi
-.sp
+.PP
 Link with \fI\-lm\fP.
 .SH DESCRIPTION
+.IR Note :
+the mechanism described in this page is no longer supported by glibc.
+Before glibc 2.27, it had been marked as obsolete.
+Since glibc 2.27,
+.\" glibc commit 813378e9fe17e029caf627cab76fe23eb46815fa
+the mechanism has been removed altogether.
+New applications should use the techniques described in
+.BR math_error (7)
+and
+.BR fenv (3).
+This page documents the
+.BR matherr ()
+mechanism as an aid for maintaining and porting older applications.
+.PP
 The System V Interface Definition (SVID) specifies that various
 math functions should invoke a function called
 .BR matherr ()
@@ -46,27 +61,20 @@ after
 .BR matherr ()
 returns, the system then returns to the math function,
 which in turn returns to the caller.
-
-The
-.BR matherr ()
-mechanism is supported by glibc, but is now obsolete:
-new applications should use the techniques described in
-.BR math_error (7)
-and
-.BR fenv (3).
-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_SOURCE
-feature test macro, and assign the value
+feature test macro
+(before including
+.I any
+header files),
+and assign the value
 .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
@@ -78,9 +86,9 @@ version, which will be invoked when an exception occurs.
 The function is invoked with one argument, a pointer to an
 .I exception
 structure, defined as follows:
-
+.PP
 .in +4n
-.nf
+.EX
 struct exception {
     int    type;      /* Exception type */
     char  *name;      /* Name of function causing exception */
@@ -88,7 +96,7 @@ struct exception {
     double arg2;      /* 2nd argument to function */
     double retval;    /* Function return value */
 }
-.fi
+.EE
 .in
 .PP
 The
@@ -149,7 +157,7 @@ and
 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
@@ -157,17 +165,17 @@ function will return to its caller.
 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 non-zero value, then the system does not set
+function returns a nonzero value, then the system does not set
 .IR errno ,
 and doesn't print an error message.
 .SS Math functions that employ matherr()
@@ -180,17 +188,17 @@ when calling
 .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:
+.PP
 .RS
 .nf
-
 x        first argument to function
 y        second argument to function
 fin      finite value for argument
@@ -211,9 +219,9 @@ Function    Type    Result  Msg?    errno
 acos(|x|>1)    DOMAIN  HUGE    y       EDOM
 asin(|x|>1)    DOMAIN  HUGE    y       EDOM
 atan2(0,0)     DOMAIN  HUGE    y       EDOM
-acosh(x<1)     DOMAIN  NAN     y       EDOM    \" retval is 0.0/0.0
-atanh(|x|>1)   DOMAIN  NAN     y       EDOM    \" retval is 0.0/0.0
-atanh(|x|==1)  SING    (x>0.0)?        y       EDOM    \" retval is x/0.0
+acosh(x<1)     DOMAIN  NAN     y       EDOM    \" retval is 0.0/0.0
+atanh(|x|>1)   DOMAIN  NAN     y       EDOM    \" retval is 0.0/0.0
+atanh(|x|==1)  SING    (x>0.0)?        y       EDOM    \" retval is x/0.0
 \      \       HUGE_VAL :
 \      \       \-HUGE_VAL
 cosh(fin) o/f  OVERFLOW        HUGE    n       ERANGE
@@ -249,7 +257,7 @@ tgamma(0)   SING    copysign(       y       ERANGE
 log(0) SING    \-HUGE  y       EDOM
 log(x<0)       DOMAIN  \-HUGE  y       EDOM
 log2(0)        SING    \-HUGE  n       EDOM    \" different from log()
-log2(x<0)      DOMAIN  -HUGE   n       EDOM    \" different from log()
+log2(x<0)      DOMAIN  \-HUGE  n       EDOM    \" different from log()
 log10(0)       SING    \-HUGE  y       EDOM
 log10(x<0)     DOMAIN  \-HUGE  y       EDOM
 pow(0.0,0.0)   DOMAIN  0.0     y       EDOM
@@ -264,7 +272,19 @@ scalb() o/f        OVERFLOW        (x>0.0) ?       n       ERANGE
 scalb() u/f    UNDERFLOW       copysign(       n       ERANGE
 \      \       \ \ 0.0,x)
 fmod(x,0)      DOMAIN  x       y       EDOM
-remainder(x,0) DOMAIN  NAN     y       EDOM    \" retval is 0.0/0.0
+remainder(x,0) DOMAIN  NAN     y       EDOM    \" retval is 0.0/0.0
+.TE
+.SH ATTRIBUTES
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lb lb lb
+l l l.
+Interface      Attribute       Value
+T{
+.BR matherr ()
+T}     Thread safety   MT-Safe
 .TE
 .SH EXAMPLE
 The example program demonstrates the use of
@@ -287,73 +307,73 @@ If the optional third command-line argument is supplied,
 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() :
-
+.BR matherr ():
+.PP
 .in +4n
-.nf
+.EX
 .RB "$" " ./a.out 0.0"
 errno: Numerical result out of range
 x=-inf
-.fi
+.EE
 .in
-
+.PP
 In the following run,
 .BR matherr ()
 is called, and returns 0:
-
+.PP
 .in +4n
-.nf
+.EX
 .RB "$" " ./a.out 0.0 0"
 matherr SING exception in log() function
         args:   0.000000, 0.000000
-        retval: -340282346638528859811704183484516925440.000000
+        retval: \-340282346638528859811704183484516925440.000000
 log: SING error
 errno: Numerical argument out of domain
 x=-340282346638528859811704183484516925440.000000
-.fi
+.EE
 .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 non-zero value:
-
+is called, and returns a nonzero value:
+.PP
 .in +4n
-.nf
+.EX
 .RB "$" " ./a.out 0.0 1"
 matherr SING exception in log() function
         args:   0.000000, 0.000000
-        retval: -340282346638528859811704183484516925440.000000
+        retval: \-340282346638528859811704183484516925440.000000
 x=-340282346638528859811704183484516925440.000000
-.fi
+.EE
 .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 non-zero value:
-
+and returns a nonzero value:
+.PP
 .in +4n
-.nf
+.EX
 .RB "$" " ./a.out 0.0 1 12345.0"
 matherr SING exception in log() function
         args:   0.000000, 0.000000
-        retval: -340282346638528859811704183484516925440.000000
+        retval: \-340282346638528859811704183484516925440.000000
 x=12345.000000
-.fi
+.EE
 .in
 .SS Program source
 \&
-.nf
+.EX
 #define _SVID_SOURCE
 #include <errno.h>
 #include <math.h>
@@ -378,7 +398,7 @@ matherr(struct exception *exc)
            (exc\->type == PLOSS) ?     "PLOSS" : "???",
             exc\->name);
     fprintf(stderr, "        args:   %f, %f\\n",
-            exc\->arg1, exc->arg2);
+            exc\->arg1, exc\->arg2);
     fprintf(stderr, "        retval: %f\\n", exc\->retval);
 
     if (change_retval)
@@ -394,7 +414,7 @@ main(int argc, char *argv[])
 
     if (argc < 2) {
         fprintf(stderr, "Usage: %s <argval>"
-                " [<matherr\-ret> [<new\-func-retval>]]\\n", argv[0]);
+                " [<matherr\-ret> [<new\-func\-retval>]]\\n", argv[0]);
         exit(EXIT_FAILURE);
     }
 
@@ -415,7 +435,7 @@ main(int argc, char *argv[])
     printf("x=%f\\n", x);
     exit(EXIT_SUCCESS);
 }
-.fi
+.EE
 .SH SEE ALSO
 .BR fenv (3),
 .BR math_error (7),