sqrt.patch from bug #567

Using an old version of mingw-w64 (last updated May 2015),
calling sqrt(-1.0) would return NaN (the expected result).
After updating to the current version, it returns -1.0.

It looks like this bug was introduced by commit 6617eb.

Signed-off-by: Martin Whitaker <martinwhitaker@users.sf.net>
Signed-off-by: Kai Tietz <ktietz70@users.sf.net>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
diff --git a/mingw-w64-crt/math/sqrt.def.h b/mingw-w64-crt/math/sqrt.def.h
index 602409a..0cd401d 100644
--- a/mingw-w64-crt/math/sqrt.def.h
+++ b/mingw-w64-crt/math/sqrt.def.h
@@ -71,8 +71,15 @@
       if (x_class == FP_ZERO)
 	return __FLT_CST (-0.0);
 
-      __FLT_RPT_DOMAIN ("sqrt", x, 0.0, x);
-      return x;
+      if (x_class == FP_NAN)
+        {
+          __FLT_RPT_DOMAIN ("sqrt", x, 0.0, x);
+          return x;
+        }
+
+      res = -__FLT_NAN;
+      __FLT_RPT_DOMAIN ("sqrt", x, 0.0, res);
+      return res;
     }
   else if (x_class == FP_ZERO)
     return __FLT_CST (0.0);