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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libm/] [common/] [s_matherr.c] - Diff between revs 57 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 57 Rev 1765
 
 
/* @(#)s_matherr.c 5.1 93/09/24 */
/* @(#)s_matherr.c 5.1 93/09/24 */
/*
/*
 * ====================================================
 * ====================================================
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 *
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * software is freely granted, provided that this notice
 * is preserved.
 * is preserved.
 * ====================================================
 * ====================================================
 */
 */
 
 
/*
/*
 
 
FUNCTION
FUNCTION
        <<matherr>>---modifiable math error handler
        <<matherr>>---modifiable math error handler
 
 
INDEX
INDEX
        matherr
        matherr
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <math.h>
        #include <math.h>
        int matherr(struct exception *<[e]>);
        int matherr(struct exception *<[e]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <math.h>
        #include <math.h>
        int matherr(*<[e]>)
        int matherr(*<[e]>)
        struct exception *<[e]>;
        struct exception *<[e]>;
 
 
DESCRIPTION
DESCRIPTION
<<matherr>> is called whenever a math library function generates an error.
<<matherr>> is called whenever a math library function generates an error.
You can replace <<matherr>> by your own subroutine to customize
You can replace <<matherr>> by your own subroutine to customize
error treatment.  The customized <<matherr>> must return 0 if
error treatment.  The customized <<matherr>> must return 0 if
it fails to resolve the error, and non-zero if the error is resolved.
it fails to resolve the error, and non-zero if the error is resolved.
 
 
When <<matherr>> returns a nonzero value, no error message is printed
When <<matherr>> returns a nonzero value, no error message is printed
and the value of <<errno>> is not modified.  You can accomplish either
and the value of <<errno>> is not modified.  You can accomplish either
or both of these things in your own <<matherr>> using the information
or both of these things in your own <<matherr>> using the information
passed in the structure <<*<[e]>>>.
passed in the structure <<*<[e]>>>.
 
 
This is the <<exception>> structure (defined in `<<math.h>>'):
This is the <<exception>> structure (defined in `<<math.h>>'):
.       struct exception {
.       struct exception {
.               int type;
.               int type;
.               char *name;
.               char *name;
.               double arg1, arg2, retval;
.               double arg1, arg2, retval;
.               int err;
.               int err;
.       };
.       };
 
 
The members of the exception structure have the following meanings:
The members of the exception structure have the following meanings:
o+
o+
o type
o type
The type of mathematical error that occured; macros encoding error
The type of mathematical error that occured; macros encoding error
types are also defined in `<<math.h>>'.
types are also defined in `<<math.h>>'.
 
 
o name
o name
a pointer to a null-terminated string holding the
a pointer to a null-terminated string holding the
name of the math library function where the error occurred.
name of the math library function where the error occurred.
 
 
o arg1, arg2
o arg1, arg2
The arguments which caused the error.
The arguments which caused the error.
 
 
o retval
o retval
The error return value (what the calling function will return).
The error return value (what the calling function will return).
 
 
o err
o err
If set to be non-zero, this is the new value assigned to <<errno>>.
If set to be non-zero, this is the new value assigned to <<errno>>.
o-
o-
 
 
The error types defined in `<<math.h>>' represent possible mathematical
The error types defined in `<<math.h>>' represent possible mathematical
errors as follows:
errors as follows:
 
 
o+
o+
o DOMAIN
o DOMAIN
An argument was not in the domain of the function; e.g. <<log(-1.0)>>.
An argument was not in the domain of the function; e.g. <<log(-1.0)>>.
 
 
o SING
o SING
The requested calculation would result in a singularity; e.g. <<pow(0.0,-2.0)>>
The requested calculation would result in a singularity; e.g. <<pow(0.0,-2.0)>>
 
 
o OVERFLOW
o OVERFLOW
A calculation would produce a result too large to represent; e.g.
A calculation would produce a result too large to represent; e.g.
<<exp(1000.0)>>.
<<exp(1000.0)>>.
 
 
o UNDERFLOW
o UNDERFLOW
A calculation would produce a result too small to represent; e.g.
A calculation would produce a result too small to represent; e.g.
<<exp(-1000.0)>>.
<<exp(-1000.0)>>.
 
 
o TLOSS
o TLOSS
Total loss of precision.  The result would have no significant digits;
Total loss of precision.  The result would have no significant digits;
e.g. <<sin(10e70)>>.
e.g. <<sin(10e70)>>.
 
 
o PLOSS
o PLOSS
Partial loss of precision.
Partial loss of precision.
o-
o-
 
 
 
 
RETURNS
RETURNS
The library definition for <<matherr>> returns <<0>> in all cases.
The library definition for <<matherr>> returns <<0>> in all cases.
 
 
You can change the calling function's result from a customized <<matherr>>
You can change the calling function's result from a customized <<matherr>>
by modifying <<e->retval>>, which propagates backs to the caller.
by modifying <<e->retval>>, which propagates backs to the caller.
 
 
If <<matherr>> returns <<0>> (indicating that it was not able to resolve
If <<matherr>> returns <<0>> (indicating that it was not able to resolve
the error) the caller sets <<errno>> to an appropriate value, and prints
the error) the caller sets <<errno>> to an appropriate value, and prints
an error message.
an error message.
 
 
PORTABILITY
PORTABILITY
<<matherr>> is not ANSI C.
<<matherr>> is not ANSI C.
*/
*/
 
 
#include "fdlibm.h"
#include "fdlibm.h"
 
 
#ifdef __STDC__
#ifdef __STDC__
        int matherr(struct exception *x)
        int matherr(struct exception *x)
#else
#else
        int matherr(x)
        int matherr(x)
        struct exception *x;
        struct exception *x;
#endif
#endif
{
{
        int n=0;
        int n=0;
        if(x->arg1!=x->arg1) return 0;
        if(x->arg1!=x->arg1) return 0;
        return n;
        return n;
}
}
 
 

powered by: WebSVN 2.1.0

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