math: move x87-family fabs functions to C with inline asm
authorAlexander Monakov <amonakov@ispras.ru>
Mon, 6 Jan 2020 08:36:18 +0000 (11:36 +0300)
committerRich Felker <dalias@aerifal.cx>
Tue, 24 Mar 2020 20:27:38 +0000 (16:27 -0400)
src/math/i386/fabs.c [new file with mode: 0644]
src/math/i386/fabs.s [deleted file]
src/math/i386/fabsf.c [new file with mode: 0644]
src/math/i386/fabsf.s [deleted file]
src/math/i386/fabsl.c [new file with mode: 0644]
src/math/i386/fabsl.s [deleted file]
src/math/x86_64/fabsl.c [new file with mode: 0644]
src/math/x86_64/fabsl.s [deleted file]

diff --git a/src/math/i386/fabs.c b/src/math/i386/fabs.c
new file mode 100644 (file)
index 0000000..3967278
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+double fabs(double x)
+{
+       __asm__ ("fabs" : "+t"(x));
+       return x;
+}
diff --git a/src/math/i386/fabs.s b/src/math/i386/fabs.s
deleted file mode 100644 (file)
index d66ea9a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global fabs
-.type fabs,@function
-fabs:
-       fldl 4(%esp)
-       fabs
-       ret
diff --git a/src/math/i386/fabsf.c b/src/math/i386/fabsf.c
new file mode 100644 (file)
index 0000000..d882eee
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+float fabsf(float x)
+{
+       __asm__ ("fabs" : "+t"(x));
+       return x;
+}
diff --git a/src/math/i386/fabsf.s b/src/math/i386/fabsf.s
deleted file mode 100644 (file)
index a981c42..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global fabsf
-.type fabsf,@function
-fabsf:
-       flds 4(%esp)
-       fabs
-       ret
diff --git a/src/math/i386/fabsl.c b/src/math/i386/fabsl.c
new file mode 100644 (file)
index 0000000..cc1c9ed
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double fabsl(long double x)
+{
+       __asm__ ("fabs" : "+t"(x));
+       return x;
+}
diff --git a/src/math/i386/fabsl.s b/src/math/i386/fabsl.s
deleted file mode 100644 (file)
index ceef9e4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global fabsl
-.type fabsl,@function
-fabsl:
-       fldt 4(%esp)
-       fabs
-       ret
diff --git a/src/math/x86_64/fabsl.c b/src/math/x86_64/fabsl.c
new file mode 100644 (file)
index 0000000..cc1c9ed
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double fabsl(long double x)
+{
+       __asm__ ("fabs" : "+t"(x));
+       return x;
+}
diff --git a/src/math/x86_64/fabsl.s b/src/math/x86_64/fabsl.s
deleted file mode 100644 (file)
index 4e7ab52..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global fabsl
-.type fabsl,@function
-fabsl:
-       fldt 8(%rsp)
-       fabs
-       ret