diff --git a/ChangeLog b/ChangeLog index fa591e87c..125dad9c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2009-01-04 Dietmar Warning * src/math/misc/isinf.c, Makefile.am: a simple (but ugly) workaround for isinf needed by some adms generated models + * src/iclude/ngspice.h, missing_math.h: try to catch isinf by ieeefp.h * adms/ekv/amsva/ekv.va: compatibility regarding S/D diode behaviour 2009-01-02 Dietmar Warning diff --git a/src/include/missing_math.h b/src/include/missing_math.h index 4cfbf393f..daff6d1d4 100644 --- a/src/include/missing_math.h +++ b/src/include/missing_math.h @@ -33,13 +33,17 @@ extern int isnan(double); #endif #ifndef HAVE_DECL_ISINF -# ifndef HAVE_ISINF -# if defined(HAVE_FINITE) && (defined (HAVE_DECL_ISNAN) || defined (HAVE_ISNAN)) -# define isinf(x) (!finite(x) && !isnan(x)) -# endif -# else -extern int isinf(double); -# endif +#ifndef HAVE_ISINF +#if defined(HAVE_FINITE) && (defined (HAVE_DECL_ISNAN) || defined (HAVE_ISNAN)) +#define isinf(x) (!finite(x) && !isnan(x)) +#else +#ifdef HAVE_IEEEFP_H + extern int isinf(double); #endif +#endif +#else /* HAVE_ISINF */ + extern int isinf(double); +#endif /* HAVE_ISINF */ +#endif /* HAVE_DECL_ISINF */ #endif /* MISSING_MATH_H_INCLUDED */ diff --git a/src/include/ngspice.h b/src/include/ngspice.h index ef43c2a2c..4118bc5c3 100644 --- a/src/include/ngspice.h +++ b/src/include/ngspice.h @@ -31,6 +31,10 @@ #include #include +#ifdef HAVE_IEEEFP_H +#include +#endif + #include "missing_math.h" #ifdef STDC_HEADERS diff --git a/src/maths/misc/isinf.c b/src/maths/misc/isinf.c index a0532e9d9..a8b1b561e 100644 --- a/src/maths/misc/isinf.c +++ b/src/maths/misc/isinf.c @@ -1,26 +1,35 @@ #include "ngspice.h" -/* this is really ugly - but it is a emergency case */ - #ifndef HAVE_DECL_ISINF + #ifndef HAVE_ISINF -static int -isinf(double x) -{ - volatile double a = x; +#ifdef HAVE_IEEEFP_H - if (a > DBL_MAX) - return 1; - if (a < -DBL_MAX) - return -1; - return 0; -} + int isinf(double x) { return !finite(x) && x==x; } + +#else /* HAVE_IEEEFP_H */ + + /* this is really ugly - but it is a emergency case */ + + static int + isinf(double x) + { + volatile double a = x; + + if (a > DBL_MAX) + return 1; + if (a < -DBL_MAX) + return -1; + return 0; + } + +#endif /* HAVE_IEEEFP_H */ -/* - * end isinf.c - */ #else /* HAVE_ISINF */ -int Dummy_Symbol_5; + + int Dummy_Symbol_5; + #endif /* HAVE_ISINF */ + #endif /* HAVE_DECL_ISINF */