summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/mingwex/math/sqrtf.c
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/mingwex/math/sqrtf.c')
-rw-r--r--winsup/mingw/mingwex/math/sqrtf.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/winsup/mingw/mingwex/math/sqrtf.c b/winsup/mingw/mingwex/math/sqrtf.c
index 55ca39dbe..b1029cad8 100644
--- a/winsup/mingw/mingwex/math/sqrtf.c
+++ b/winsup/mingw/mingwex/math/sqrtf.c
@@ -1,9 +1,20 @@
#include <math.h>
+#include <errno.h>
+
+extern float __QNANF;
float
sqrtf (float x)
{
- float res;
- asm ("fsqrt" : "=t" (res) : "0" (x));
- return res;
+ if (x < 0.0F )
+ {
+ errno = EDOM;
+ return __QNANF;
+ }
+ else
+ {
+ float res;
+ asm ("fsqrt" : "=t" (res) : "0" (x));
+ return res;
+ }
}