Please review, i'll commit it, just need an OK.
diff --git a/mingw-w64-crt/math/softmath/acosh.c b/mingw-w64-crt/math/softmath/acosh.c
index 09bfaa6..01d3e20 100644
--- a/mingw-w64-crt/math/softmath/acosh.c
+++ b/mingw-w64-crt/math/softmath/acosh.c
@@ -46,5 +46,19 @@
double acosh(double x)
{
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN || x < 1.0)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "acosh", x, 0.0, NAN);
+ return NAN;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "acosh", x, 0.0, NAN);
+ return NAN;
+ }
+
return softmath_log(x + sqrt(x * x * 2 - 1));
}
diff --git a/mingw-w64-crt/math/softmath/acoshf.c b/mingw-w64-crt/math/softmath/acoshf.c
index e8940fb..cc18e6b 100644
--- a/mingw-w64-crt/math/softmath/acoshf.c
+++ b/mingw-w64-crt/math/softmath/acoshf.c
@@ -46,5 +46,19 @@
float acoshf(float x)
{
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN || x < 1.0f)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "acoshf", x, 0.0, NANF);
+ return NANF;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "acoshf", x, 0.0, NANF);
+ return NANF;
+ }
+
return softmath_logf(x + sqrtf(x * x * 2 - 1));
}
diff --git a/mingw-w64-crt/math/softmath/acoshl.c b/mingw-w64-crt/math/softmath/acoshl.c
index 64d2033..f0c6288 100644
--- a/mingw-w64-crt/math/softmath/acoshl.c
+++ b/mingw-w64-crt/math/softmath/acoshl.c
@@ -46,6 +46,20 @@
long double acoshl(long double x)
{
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN || x < 1.0l)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "acoshl", x, 0.0, NANL);
+ return NANL;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "acoshl", x, 0.0, NANL);
+ return NANL;
+ }
+
#if defined(__arm__) || defined(_ARM_)
return acosh(x);
#else
diff --git a/mingw-w64-crt/math/softmath/exp.c b/mingw-w64-crt/math/softmath/exp.c
index b5216c8..f8c067d 100644
--- a/mingw-w64-crt/math/softmath/exp.c
+++ b/mingw-w64-crt/math/softmath/exp.c
@@ -49,6 +49,35 @@ double exp(double x)
double result = 0.0;
int n;
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "exp", x, 0.0, x);
+ return x;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ double r = (signbit (x) ? 0.0 : HUGE_VAL);
+ errno = ERANGE;
+ __mingw_raise_matherr (signbit (x) ? _OVERFLOW : _UNDERFLOW, "exp", x, 0.0, r);
+ return r;
+ }
+ else if (x_class == FP_ZERO)
+ {
+ return 1.0;
+ }
+ else if (x > 7.09782712893383996843E2)
+ {
+ errno = ERANGE;
+ __mingw_raise_matherr (_OVERFLOW, "exp", x, 0.0, HUGE_VAL);
+ return HUGE_VAL;
+ }
+ else if (x < -7.45133219101941108420E2)
+ {
+ return 0.0;
+ }
+
for(n = 0; n < 64; n++)
{
result += (bsd__ieee754_pow(x, n) / softmath_fact(n));
diff --git a/mingw-w64-crt/math/softmath/expl.c b/mingw-w64-crt/math/softmath/expl.c
index 00d03f2..675a8cb 100644
--- a/mingw-w64-crt/math/softmath/expl.c
+++ b/mingw-w64-crt/math/softmath/expl.c
@@ -46,6 +46,35 @@
long double expl(long double x)
{
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "expl", x, 0.0, x);
+ return x;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ long double r = (signbit (x) ? 0.0l : HUGE_VALL);
+ errno = ERANGE;
+ __mingw_raise_matherr (signbit (x) ? _OVERFLOW : _UNDERFLOW, "expl", x, 0.0, r);
+ return r;
+ }
+ else if (x_class == FP_ZERO)
+ {
+ return 1.0l;
+ }
+ else if (x > 1.1356523406294143949492E4L)
+ {
+ errno = ERANGE;
+ __mingw_raise_matherr (_OVERFLOW, "expl", x, 0.0, HUGE_VALL);
+ return HUGE_VALL;
+ }
+ else if (x < -1.1355137111933024058873E4L)
+ {
+ return 0.0l;
+ }
+
#if defined(__arm__) || defined(_ARM_)
return exp(x);
#else
diff --git a/mingw-w64-crt/math/softmath/expm1.c b/mingw-w64-crt/math/softmath/expm1.c
index a76f9c8..bd01683 100644
--- a/mingw-w64-crt/math/softmath/expm1.c
+++ b/mingw-w64-crt/math/softmath/expm1.c
@@ -46,5 +46,21 @@
double expm1(double x)
{
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "expm1", x, 0.0, x);
+ return x;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ return (signbit (x) ? -1.0 : HUGE_VAL);
+ }
+ else if (x_class == FP_ZERO)
+ {
+ return x;
+ }
+
return exp(x) - 1;
}
diff --git a/mingw-w64-crt/math/softmath/expm1f.c b/mingw-w64-crt/math/softmath/expm1f.c
index b5d3a86..00ec59d 100644
--- a/mingw-w64-crt/math/softmath/expm1f.c
+++ b/mingw-w64-crt/math/softmath/expm1f.c
@@ -46,5 +46,21 @@
float expm1f(float x)
{
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "expm1f", x, 0.0, x);
+ return x;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ return (signbit (x) ? -1.0f : HUGE_VALF);
+ }
+ else if (x_class == FP_ZERO)
+ {
+ return x;
+ }
+
return softmath_expf(x) - 1;
}
diff --git a/mingw-w64-crt/math/softmath/expm1l.c b/mingw-w64-crt/math/softmath/expm1l.c
index 82832a9..ca7bfd3 100644
--- a/mingw-w64-crt/math/softmath/expm1l.c
+++ b/mingw-w64-crt/math/softmath/expm1l.c
@@ -46,6 +46,22 @@
long double expm1l(long double x)
{
+ int x_class = fpclassify (x);
+ if (x_class == FP_NAN)
+ {
+ errno = EDOM;
+ __mingw_raise_matherr (_DOMAIN, "expm1l", x, 0.0, x);
+ return x;
+ }
+ else if (x_class == FP_INFINITE)
+ {
+ return (signbit (x) ? -1.0l : HUGE_VALL);
+ }
+ else if (x_class == FP_ZERO)
+ {
+ return x;
+ }
+
#if defined(__arm__) || defined(_ARM_)
return expm1(x);
#else
diff --git a/mingw-w64-crt/math/softmath/log.c b/mingw-w64-crt/math/softmath/log.c
index 7473609..45275ca 100644
--- a/mingw-w64-crt/math/softmath/log.c
+++ b/mingw-w64-crt/math/softmath/log.c
@@ -59,7 +59,7 @@ double log(double x)
}
else if (x_class == FP_ZERO)
{
- errno = EDOM;
+ errno = ERANGE;
__mingw_raise_matherr (_OVERFLOW, "log", x, 0.0, -HUGE_VAL);
return -HUGE_VAL;
}
diff --git a/mingw-w64-crt/math/softmath/logl.c b/mingw-w64-crt/math/softmath/logl.c
index 77c7757..f7cd497 100644
--- a/mingw-w64-crt/math/softmath/logl.c
+++ b/mingw-w64-crt/math/softmath/logl.c
@@ -59,7 +59,7 @@ long double logl(long double x)
}
else if (x_class == FP_ZERO)
{
- errno = EDOM;
+ errno = ERANGE;
__mingw_raise_matherr (_OVERFLOW, "logl", x, 0.0, -HUGE_VALL);
return -HUGE_VALL;
}
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public