replacements for functions missing in the msvc world

This commit is contained in:
h_vogt 2013-12-07 12:14:47 +01:00 committed by rlar
parent c38f7236b1
commit 8ad6bd209d
5 changed files with 55 additions and 20 deletions

View File

@ -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);

View File

@ -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

View File

@ -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 Normal file
View File

@ -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;
}

View File

@ -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"
>