Browse Source

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

pre-master-46
sjborley 21 years ago
parent
commit
eff209d8a3
  1. 50
      src/misc/missing_math.c
  2. 8
      src/misc/missing_math.h
  3. 54
      src/spicelib/devices/dev.c

50
src/misc/missing_math.c

@ -96,3 +96,53 @@ erfc(double x)
return(z); return(z);
} }
#endif #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 */

8
src/misc/missing_math.h

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

54
src/spicelib/devices/dev.c

@ -413,7 +413,7 @@ extern struct coreInfo_t coreInfo;
int load_opus(char *name){ int load_opus(char *name){
void *lib; void *lib;
char *msg;
const char *msg;
int *num=NULL; int *num=NULL;
struct coreInfo_t **core; struct coreInfo_t **core;
SPICEdev **devs; SPICEdev **devs;
@ -488,55 +488,3 @@ int load_opus(char *name){
#endif #endif
/*-------------------- end of XSPICE additions ----------------------*/ /*-------------------- 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
Loading…
Cancel
Save