Browse Source

replacements for functions missing in the msvc world

pre-master-46
h_vogt 12 years ago
committed by rlar
parent
commit
8ad6bd209d
  1. 20
      src/frontend/numparam/xpressn.c
  2. 8
      src/include/ngspice/ngspice.h
  3. 4
      visualc-shared/sharedspice.vcproj
  4. 39
      visualc/msvc-compat.c
  5. 4
      visualc/vngspice.vcproj

20
src/frontend/numparam/xpressn.c

@ -177,33 +177,13 @@ mathfunction(int f, double z, double x)
y = atan(x);
break;
case XFU_ASINH:
#ifdef HAVE_ASINH
y = asinh(x);
#else
y = ((x > 0) ? log(x + sqrt(x * x + 1.0)) : -log(-x + sqrt(x * x + 1.0)));
#endif
break;
case XFU_ACOSH:
#ifdef HAVE_ACOSH
y = acosh(x);
#else
/* domain check (HUGE_VAL like gnu libc) */
if (x < 1.)
y = HUGE_VAL;
else
y = (log(x + sqrt(x*x-1.0)));
#endif
break;
case XFU_ATANH:
#ifdef HAVE_ATANH
y = atanh(x);
#else
/* domain check (HUGE_VAL like gnu libc) */
if (fabs(x) >= 1.)
y = HUGE_VAL;
else
y = (log((1.0 + x) / (1.0 - x)) / 2.0);
#endif
break;
case XFU_TAN:
y = tan(x);

8
src/include/ngspice/ngspice.h

@ -158,6 +158,14 @@ extern void SetAnalyse(char *Analyse, int Percent);
#if defined (_MSC_VER)
#include <direct.h>
#include <process.h>
#define trunc x_trunc
extern double x_trunc(double);
#define asinh x_asinh
extern double x_asinh(double);
#define acosh x_acosh
extern double x_acosh(double);
#define atanh x_atanh
extern double x_atanh(double);
#define strdup _strdup
#define unlink _unlink
#define fileno _fileno

4
visualc-shared/sharedspice.vcproj

@ -6444,6 +6444,10 @@
RelativePath="..\src\spicelib\devices\mos9\mos9trun.c"
>
</File>
<File
RelativePath="..\visualc\msvc-compat.c"
>
</File>
<File
RelativePath="..\src\maths\deriv\multder.c"
>

39
visualc/msvc-compat.c

@ -0,0 +1,39 @@
#include <math.h>
/*
* some rather simple minded replacements
* for functions missing in most msvc incarnations
*/
double
x_trunc(double x)
{
return (x < 0) ? ceil(x) : floor(x);
}
double
x_asinh(double x)
{
return (x > 0) ? log(x + sqrt(x * x + 1.0)) : -log(-x + sqrt(x * x + 1.0));
}
double
x_acosh(double x)
{
/* domain check (HUGE_VAL like gnu libc) */
if (x < 1.0)
return HUGE_VAL;
else
return log(x + sqrt(x * x - 1.0));
}
double
x_atanh(double x)
{
/* domain check (HUGE_VAL like gnu libc) */
if (fabs(x) >= 1.0)
return HUGE_VAL;
else
return log((1.0 + x) / (1.0 - x)) / 2.0;
}

4
visualc/vngspice.vcproj

@ -7268,6 +7268,10 @@
RelativePath="..\src\spicelib\devices\mos9\mos9trun.c"
>
</File>
<File
RelativePath="msvc-compat.c"
>
</File>
<File
RelativePath="..\src\maths\deriv\multder.c"
>

Loading…
Cancel
Save