summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/mingwex/math/sqrtl.c
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/mingwex/math/sqrtl.c')
-rw-r--r--winsup/mingw/mingwex/math/sqrtl.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/winsup/mingw/mingwex/math/sqrtl.c b/winsup/mingw/mingwex/math/sqrtl.c
index 0bd301390..dba68d878 100644
--- a/winsup/mingw/mingwex/math/sqrtl.c
+++ b/winsup/mingw/mingwex/math/sqrtl.c
@@ -1,8 +1,20 @@
#include <math.h>
+#include <errno.h>
+
+extern long double __QNANL;
+
long double
sqrtl (long double x)
{
- long double res;
- asm ("fsqrt" : "=t" (res) : "0" (x));
- return res;
+ if (x < 0.0L )
+ {
+ errno = EDOM;
+ return __QNANL;
+ }
+ else
+ {
+ long double res;
+ asm ("fsqrt" : "=t" (res) : "0" (x));
+ return res;
+ }
}