source: trunk/libs/newlib/src/newlib/libm/common/s_matherr.c @ 567

Last change on this file since 567 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.9 KB
Line 
1
2/* @(#)s_matherr.c 5.1 93/09/24 */
3/*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 *
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 * ====================================================
12 */
13
14/*
15
16FUNCTION
17        <<matherr>>---modifiable math error handler
18
19INDEX
20        matherr
21
22SYNOPSIS
23        #include <math.h>
24        int matherr(struct exception *<[e]>);
25
26DESCRIPTION
27<<matherr>> is called whenever a math library function generates an error.
28You can replace <<matherr>> by your own subroutine to customize
29error treatment.  The customized <<matherr>> must return 0 if
30it fails to resolve the error, and non-zero if the error is resolved.
31
32When <<matherr>> returns a nonzero value, no error message is printed
33and the value of <<errno>> is not modified.  You can accomplish either
34or both of these things in your own <<matherr>> using the information
35passed in the structure <<*<[e]>>>.
36
37This is the <<exception>> structure (defined in `<<math.h>>'):
38.       struct exception {
39.               int type;
40.               char *name;
41.               double arg1, arg2, retval;
42.               int err;
43.       };
44
45The members of the exception structure have the following meanings:
46o+
47o type
48The type of mathematical error that occured; macros encoding error
49types are also defined in `<<math.h>>'.
50
51o name
52a pointer to a null-terminated string holding the
53name of the math library function where the error occurred.
54
55o arg1, arg2
56The arguments which caused the error.
57
58o retval
59The error return value (what the calling function will return).
60
61o err
62If set to be non-zero, this is the new value assigned to <<errno>>.
63o-
64
65The error types defined in `<<math.h>>' represent possible mathematical
66errors as follows:
67
68o+
69o DOMAIN
70An argument was not in the domain of the function; e.g. <<log(-1.0)>>.
71
72o SING
73The requested calculation would result in a singularity; e.g. <<pow(0.0,-2.0)>>
74
75o OVERFLOW
76A calculation would produce a result too large to represent; e.g.
77<<exp(1000.0)>>.
78
79o UNDERFLOW
80A calculation would produce a result too small to represent; e.g.
81<<exp(-1000.0)>>.
82
83o TLOSS
84Total loss of precision.  The result would have no significant digits;
85e.g. <<sin(10e70)>>.
86
87o PLOSS
88Partial loss of precision.
89o-
90
91
92RETURNS
93The library definition for <<matherr>> returns <<0>> in all cases.
94
95You can change the calling function's result from a customized <<matherr>>
96by modifying <<e->retval>>, which propagates backs to the caller.
97
98If <<matherr>> returns <<0>> (indicating that it was not able to resolve
99the error) the caller sets <<errno>> to an appropriate value, and prints
100an error message.
101
102PORTABILITY
103<<matherr>> is not ANSI C. 
104*/
105
106#include "fdlibm.h"
107
108#ifdef __STDC__
109        int matherr(struct exception *x)
110#else
111        int matherr(x)
112        struct exception *x;
113#endif
114{
115        int n=0;
116        if(x->arg1!=x->arg1) return 0;
117        return n;
118}
Note: See TracBrowser for help on using the repository browser.