small polish regarding HAVE_DECL_XXX macros
This commit is contained in:
parent
c702897d13
commit
91f10abc65
|
|
@ -2,7 +2,6 @@
|
|||
Copyright 1999 Emmanuel Rouat
|
||||
**********/
|
||||
|
||||
|
||||
/* Decl. for missing maths functions, if any */
|
||||
|
||||
#ifndef MISSING_MATH_H_INCLUDED
|
||||
|
|
@ -26,23 +25,23 @@ extern double scalb(double, double);
|
|||
extern double scalbn(double, int);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_ISNAN
|
||||
#if !HAVE_DECL_ISNAN
|
||||
#ifndef HAVE_ISNAN
|
||||
extern int isnan(double);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_ISINF < 1)
|
||||
#if !HAVE_DECL_ISINF
|
||||
#ifndef HAVE_ISINF
|
||||
#if defined(HAVE_FINITE) && ((HAVE_DECL_ISNAN < 1) || defined (HAVE_ISNAN))
|
||||
#if defined(HAVE_FINITE) && (HAVE_DECL_ISNAN || defined (HAVE_ISNAN))
|
||||
#define isinf(x) (!finite(x) && !isnan(x))
|
||||
#else
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
extern int isinf(double);
|
||||
extern int isinf(double);
|
||||
#endif
|
||||
#endif
|
||||
#else /* HAVE_ISINF */
|
||||
extern int isinf(double);
|
||||
extern int isinf(double);
|
||||
#endif /* HAVE_ISINF */
|
||||
#endif /* HAVE_DECL_ISINF */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +1,31 @@
|
|||
#include "ngspice.h"
|
||||
|
||||
#if (HAVE_DECL_ISINF < 1)
|
||||
|
||||
#if !HAVE_DECL_ISINF
|
||||
#ifndef HAVE_ISINF
|
||||
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
|
||||
int isinf(double x) { return !finite(x) && x==x; }
|
||||
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;
|
||||
}
|
||||
/* this is really ugly - but it is a emergency case */
|
||||
|
||||
static int
|
||||
isinf (const double x)
|
||||
{
|
||||
double y = x - x;
|
||||
int s = (y != y);
|
||||
|
||||
if (s && x > 0)
|
||||
return +1;
|
||||
else if (s && x < 0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_IEEEFP_H */
|
||||
|
||||
#else /* HAVE_ISINF */
|
||||
|
||||
int Dummy_Symbol_5;
|
||||
|
||||
int Dummy_Symbol_5;
|
||||
#endif /* HAVE_ISINF */
|
||||
|
||||
#endif /* HAVE_DECL_ISINF */
|
||||
|
|
|
|||
|
|
@ -1,45 +1,45 @@
|
|||
#include "ngspice.h"
|
||||
|
||||
#if (HAVE_DECL_ISNAN < 1)
|
||||
#if !HAVE_DECL_ISNAN
|
||||
#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
|
||||
{
|
||||
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
|
||||
{
|
||||
} 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;
|
||||
} 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. */
|
||||
exponent and a nonzero mantissa. */
|
||||
return ((u.ieee.exponent & 0x7ff) == 0x7ff &&
|
||||
(u.ieee.mantissa0 != 0 || u.ieee.mantissa1 != 0));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue