]> sourceware.org Git - newlib-cygwin.git/commitdiff
* include/math.h (sqrt): Remove inline definition.
authorDanny Smith <dannysmith@users.sourceforge.net>
Sat, 9 Nov 2002 10:44:02 +0000 (10:44 +0000)
committerDanny Smith <dannysmith@users.sourceforge.net>
Sat, 9 Nov 2002 10:44:02 +0000 (10:44 +0000)
(sqrtf): Replace inline definition with prototype.
(sqrtl): Likewise.
* mingwex/math/sqrtf.c (sqrtf): Set domain error if
argument less than zero.
* mingwex/math/sqrtf.c (sqrtl): Likewise.

Correct typo in 2002-10-30 ChangeLog entry.

winsup/mingw/include/math.h
winsup/mingw/mingwex/math/sqrtf.c
winsup/mingw/mingwex/math/sqrtl.c

index 48849389579e1d5c0b8acc5ee2c987069a5793b4..fbfd712c0a883ce362b9468118d0573732291e17 100644 (file)
@@ -144,12 +144,6 @@ double     log (double);
 double log10 (double);
 double pow (double, double);
 double sqrt (double);
-extern __inline__  double sqrt (double x)
-{
-  double res;
-  __asm__ ("fsqrt;" : "=t" (res) : "0" (x));
-  return res;
-}
 double ceil (double);
 double floor (double);
 double fabs (double);
@@ -504,19 +498,8 @@ extern __inline__ float powf (float x, float y)
 extern long double powl (long double, long double);
 
 /* 7.12.7.5 The sqrt functions. Double in C89. */
-extern __inline__ float sqrtf (float x)
-{
-  float res;
-  __asm__ ("fsqrt" : "=t" (res) : "0" (x));
-  return res;
-}
-
-extern __inline__ long double sqrtl (long double x)
-{
-  long double res;
-  __asm__ ("fsqrt" : "=t" (res) : "0" (x));
-  return res;
-}
+extern float sqrtf (float);
+extern long double sqrtl (long double);
 
 /* 7.12.8 Error and gamma functions: TODO */
 
index 55ca39dbe65fc55cb660879870c64c1a7803e081..b1029cad8455a8e1dcbc70f65dda5ba88f34d79e 100644 (file)
@@ -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;
+    }
 }
index 0bd3013906f202aed9a6410fd3512124e7262522..dba68d87860d9f4d7d0c3334fa729e52075f8c46 100644 (file)
@@ -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;
+    }
 }
This page took 0.034372 seconds and 5 git commands to generate.