Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
 
2
/*
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice
9
 * is preserved.
10
 * ====================================================
11
 */
12
13
 
14
15
 
16
	<>---modifiable math error handler
17
18
 
19
	matherr
20
21
 
22
	#include 
23
	int matherr(struct exception *<[e]>);
24
25
 
26
	#include 
27
	int matherr(*<[e]>)
28
	struct exception *<[e]>;
29
30
 
31
<> is called whenever a math library function generates an error.
32
You can replace <> by your own subroutine to customize
33
error treatment.  The customized <> must return 0 if
34
it fails to resolve the error, and non-zero if the error is resolved.
35
36
 
37
and the value of <> is not modified.  You can accomplish either
38
or both of these things in your own <> using the information
39
passed in the structure <<*<[e]>>>.
40
41
 
42
.	struct exception {
43
.	        int type;
44
.	        char *name;
45
.	        double arg1, arg2, retval;
46
.		int err;
47
.	};
48
49
 
50
o+
51
o type
52
The type of mathematical error that occured; macros encoding error
53
types are also defined in `<>'.
54
55
 
56
a pointer to a null-terminated string holding the
57
name of the math library function where the error occurred.
58
59
 
60
The arguments which caused the error.
61
62
 
63
The error return value (what the calling function will return).
64
65
 
66
If set to be non-zero, this is the new value assigned to <>.
67
o-
68
69
 
70
errors as follows:
71
72
 
73
o DOMAIN
74
An argument was not in the domain of the function; e.g. <>.
75
76
 
77
The requested calculation would result in a singularity; e.g. <>
78
79
 
80
A calculation would produce a result too large to represent; e.g.
81
<>.
82
83
 
84
A calculation would produce a result too small to represent; e.g.
85
<>.
86
87
 
88
Total loss of precision.  The result would have no significant digits;
89
e.g. <>.
90
91
 
92
Partial loss of precision.
93
o-
94
95
 
96
 
97
The library definition for <> returns <<0>> in all cases.
98
99
 
100
by modifying <retval>>, which propagates backs to the caller.
101
102
 
103
the error) the caller sets <> to an appropriate value, and prints
104
an error message.
105
106
 
107
<> is not ANSI C.
108
*/
109
110
 
111
112
 
113
	int matherr(struct exception *x)
114
#else
115
	int matherr(x)
116
	struct exception *x;
117
#endif
118
{
119
	int n=0;
120
	if(x->arg1!=x->arg1) return 0;
121
	return n;
122
}
123