fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / common / s_matherr.c
blob58e24283455d33771710e174312e5c2efccbb64f
2 /* @(#)s_matherr.c 5.1 93/09/24 */
3 /*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
16 FUNCTION
17 <<matherr>>---modifiable math error handler
19 INDEX
20 matherr
22 ANSI_SYNOPSIS
23 #include <math.h>
24 int matherr(struct exception *<[e]>);
26 TRAD_SYNOPSIS
27 #include <math.h>
28 int matherr(*<[e]>)
29 struct exception *<[e]>;
31 DESCRIPTION
32 <<matherr>> is called whenever a math library function generates an error.
33 You can replace <<matherr>> by your own subroutine to customize
34 error treatment. The customized <<matherr>> must return 0 if
35 it fails to resolve the error, and non-zero if the error is resolved.
37 When <<matherr>> returns a nonzero value, no error message is printed
38 and the value of <<errno>> is not modified. You can accomplish either
39 or both of these things in your own <<matherr>> using the information
40 passed in the structure <<*<[e]>>>.
42 This is the <<exception>> structure (defined in `<<math.h>>'):
43 . struct exception {
44 . int type;
45 . char *name;
46 . double arg1, arg2, retval;
47 . int err;
48 . };
50 The members of the exception structure have the following meanings:
52 o type
53 The type of mathematical error that occured; macros encoding error
54 types are also defined in `<<math.h>>'.
56 o name
57 a pointer to a null-terminated string holding the
58 name of the math library function where the error occurred.
60 o arg1, arg2
61 The arguments which caused the error.
63 o retval
64 The error return value (what the calling function will return).
66 o err
67 If set to be non-zero, this is the new value assigned to <<errno>>.
70 The error types defined in `<<math.h>>' represent possible mathematical
71 errors as follows:
74 o DOMAIN
75 An argument was not in the domain of the function; e.g. <<log(-1.0)>>.
77 o SING
78 The requested calculation would result in a singularity; e.g. <<pow(0.0,-2.0)>>
80 o OVERFLOW
81 A calculation would produce a result too large to represent; e.g.
82 <<exp(1000.0)>>.
84 o UNDERFLOW
85 A calculation would produce a result too small to represent; e.g.
86 <<exp(-1000.0)>>.
88 o TLOSS
89 Total loss of precision. The result would have no significant digits;
90 e.g. <<sin(10e70)>>.
92 o PLOSS
93 Partial loss of precision.
97 RETURNS
98 The library definition for <<matherr>> returns <<0>> in all cases.
100 You can change the calling function's result from a customized <<matherr>>
101 by modifying <<e->retval>>, which propagates backs to the caller.
103 If <<matherr>> returns <<0>> (indicating that it was not able to resolve
104 the error) the caller sets <<errno>> to an appropriate value, and prints
105 an error message.
107 PORTABILITY
108 <<matherr>> is not ANSI C.
111 #include "fdlibm.h"
113 #ifdef __STDC__
114 int matherr(struct exception *x)
115 #else
116 int matherr(x)
117 struct exception *x;
118 #endif
120 int n=0;
121 if(x->arg1!=x->arg1) return 0;
122 return n;