Browse Source

try to catch isinf over ieeefp.h

pre-master-46
dwarning 17 years ago
parent
commit
abc18c40f0
  1. 1
      ChangeLog
  2. 18
      src/include/missing_math.h
  3. 4
      src/include/ngspice.h
  4. 45
      src/maths/misc/isinf.c

1
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

18
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 */

4
src/include/ngspice.h

@ -31,6 +31,10 @@
#include <math.h>
#include <stdio.h>
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
#include "missing_math.h"
#ifdef STDC_HEADERS

45
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;
if (a > DBL_MAX)
return 1;
if (a < -DBL_MAX)
return -1;
return 0;
}
/*
* end isinf.c
*/
#ifdef HAVE_IEEEFP_H
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 */
#else /* HAVE_ISINF */
int Dummy_Symbol_5;
int Dummy_Symbol_5;
#endif /* HAVE_ISINF */
#endif /* HAVE_DECL_ISINF */
Loading…
Cancel
Save