Moved isnan() to src/misc/missing_math.c from src/spicelib/devices/dev.c following suggestion from Dietmar warning. Also took opportunity to fixed a compiler warning in dev.c

This commit is contained in:
sjborley 2005-05-18 20:25:05 +00:00
parent 9f24102048
commit eff209d8a3
3 changed files with 57 additions and 55 deletions

View File

@ -96,3 +96,53 @@ erfc(double x)
return(z);
}
#endif
#ifndef HAVE_ISNAN
// isnan (originally) for SOI devices in MINGW32 hvogt (dev.c)
union ieee754_double
{
double d;
/* This is the IEEE 754 double-precision format. */
struct
{
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
} ieee;
struct
{
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
} ieee_nan;
};
int
isnan(double value)
{
union ieee754_double u;
u.d = value;
/* IEEE 754 NaN's have the maximum possible
exponent and a nonzero mantissa. */
return ((u.ieee.exponent & 0x7ff) == 0x7ff &&
(u.ieee.mantissa0 != 0 || u.ieee.mantissa1 != 0));
}
/*
* end isnan.c
*/
#endif /* HAVE_ISNAN */

View File

@ -17,7 +17,11 @@ double logb(double);
#ifndef HAVE_SCALB
# ifndef HAVE_SCALBN
double scalb(double, int);
#endif
# endif
#endif
#endif
#ifndef HAVE_ISNAN
int isnan(double value);
#endif /* HAVE_ISNAN */
#endif /* MISSING_MATH_H_INCLUDED */

View File

@ -413,7 +413,7 @@ extern struct coreInfo_t coreInfo;
int load_opus(char *name){
void *lib;
char *msg;
const char *msg;
int *num=NULL;
struct coreInfo_t **core;
SPICEdev **devs;
@ -488,55 +488,3 @@ int load_opus(char *name){
#endif
/*-------------------- end of XSPICE additions ----------------------*/
#ifdef __MINGW32__
// isnan for SOI devices in MINGW32 hvogt
union ieee754_double
{
double d;
/* This is the IEEE 754 double-precision format. */
struct
{
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
} ieee;
struct
{
/* Together these conprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
} ieee_nan;
};
#ifndef HAVE_ISNAN
int
isnan(double value)
{
union ieee754_double u;
u.d = value;
/* IEEE 754 NaN's have the maximum possible
exponent and a nonzero mantissa. */
return ((u.ieee.exponent & 0x7ff) == 0x7ff &&
(u.ieee.mantissa0 != 0 || u.ieee.mantissa1 != 0));
}
/*
* end isnan.c
*/
#endif /* HAVE_ISNAN */
#endif