OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libm/] [common/] [s_matherr.c] - Blame information for rev 194

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
 
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
 
16
FUNCTION
17
        <<matherr>>---modifiable math error handler
18
 
19
INDEX
20
        matherr
21
 
22
ANSI_SYNOPSIS
23
        #include <math.h>
24
        int matherr(struct exception *<[e]>);
25
 
26
TRAD_SYNOPSIS
27
        #include <math.h>
28
        int matherr(*<[e]>)
29
        struct exception *<[e]>;
30
 
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.
36
 
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]>>>.
41
 
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
.       };
49
 
50
The members of the exception structure have the following meanings:
51
o+
52
o type
53
The type of mathematical error that occured; macros encoding error
54
types are also defined in `<<math.h>>'.
55
 
56
o name
57
a pointer to a null-terminated string holding the
58
name of the math library function where the error occurred.
59
 
60
o arg1, arg2
61
The arguments which caused the error.
62
 
63
o retval
64
The error return value (what the calling function will return).
65
 
66
o err
67
If set to be non-zero, this is the new value assigned to <<errno>>.
68
o-
69
 
70
The error types defined in `<<math.h>>' represent possible mathematical
71
errors as follows:
72
 
73
o+
74
o DOMAIN
75
An argument was not in the domain of the function; e.g. <<log(-1.0)>>.
76
 
77
o SING
78
The requested calculation would result in a singularity; e.g. <<pow(0.0,-2.0)>>
79
 
80
o OVERFLOW
81
A calculation would produce a result too large to represent; e.g.
82
<<exp(1000.0)>>.
83
 
84
o UNDERFLOW
85
A calculation would produce a result too small to represent; e.g.
86
<<exp(-1000.0)>>.
87
 
88
o TLOSS
89
Total loss of precision.  The result would have no significant digits;
90
e.g. <<sin(10e70)>>.
91
 
92
o PLOSS
93
Partial loss of precision.
94
o-
95
 
96
 
97
RETURNS
98
The library definition for <<matherr>> returns <<0>> in all cases.
99
 
100
You can change the calling function's result from a customized <<matherr>>
101
by modifying <<e->retval>>, which propagates backs to the caller.
102
 
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.
106
 
107
PORTABILITY
108
<<matherr>> is not ANSI C.
109
*/
110
 
111
#include "fdlibm.h"
112
 
113
#ifdef __STDC__
114
        int matherr(struct exception *x)
115
#else
116
        int matherr(x)
117
        struct exception *x;
118
#endif
119
{
120
        int n=0;
121
        if(x->arg1!=x->arg1) return 0;
122
        return n;
123
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.