about summary refs log tree commit diff
path: root/src/math
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2020-01-06 20:31:47 +0300
committerRich Felker <dalias@aerifal.cx>2020-03-24 16:31:36 -0400
commit29adaeb2c0e795e75044a9b678b8cc66570f7e95 (patch)
tree223b97dc91e5c78692246b93eaa16989dbf8cf1d /src/math
parent41b290ba397067a09525b6ac89b4040728349046 (diff)
downloadmusl-29adaeb2c0e795e75044a9b678b8cc66570f7e95.tar.gz
musl-29adaeb2c0e795e75044a9b678b8cc66570f7e95.tar.xz
musl-29adaeb2c0e795e75044a9b678b8cc66570f7e95.zip
math: move i386 sqrtf to C with inline asm
Diffstat (limited to 'src/math')
-rw-r--r--src/math/i386/sqrtf.c12
-rw-r--r--src/math/i386/sqrtf.s7
2 files changed, 12 insertions, 7 deletions
diff --git a/src/math/i386/sqrtf.c b/src/math/i386/sqrtf.c
new file mode 100644
index 00000000..41c65c2b
--- /dev/null
+++ b/src/math/i386/sqrtf.c
@@ -0,0 +1,12 @@
+#include <math.h>
+
+float sqrtf(float x)
+{
+	long double t;
+	/* The long double result has sufficient precision so that
+	 * second rounding to float still keeps the returned value
+	 * correctly rounded, see Pierre Roux, "Innocuous Double
+	 * Rounding of Basic Arithmetic Operations". */
+	__asm__ ("fsqrt" : "=t"(t) : "0"(x));
+	return (float)t;
+}
diff --git a/src/math/i386/sqrtf.s b/src/math/i386/sqrtf.s
deleted file mode 100644
index 9e944f45..00000000
--- a/src/math/i386/sqrtf.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global sqrtf
-.type sqrtf,@function
-sqrtf:	flds 4(%esp)
-	fsqrt
-	fstps 4(%esp)
-	flds 4(%esp)
-	ret