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

diff --git a/src/math/i386/rint.c b/src/math/i386/rint.c
new file mode 100644 (file)
index 0000000..a5276a6
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+double rint(double x)
+{
+       __asm__ ("frndint" : "+t"(x));
+       return x;
+}
diff --git a/src/math/i386/rint.s b/src/math/i386/rint.s
deleted file mode 100644 (file)
index bb99a11..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global rint
-.type rint,@function
-rint:
-       fldl 4(%esp)
-       frndint
-       ret
diff --git a/src/math/i386/rintf.c b/src/math/i386/rintf.c
new file mode 100644 (file)
index 0000000..bb4121a
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+float rintf(float x)
+{
+       __asm__ ("frndint" : "+t"(x));
+       return x;
+}
diff --git a/src/math/i386/rintf.s b/src/math/i386/rintf.s
deleted file mode 100644 (file)
index bce4c5a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global rintf
-.type rintf,@function
-rintf:
-       flds 4(%esp)
-       frndint
-       ret
diff --git a/src/math/i386/rintl.c b/src/math/i386/rintl.c
new file mode 100644 (file)
index 0000000..e1a9207
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double rintl(long double x)
+{
+       __asm__ ("frndint" : "+t"(x));
+       return x;
+}
diff --git a/src/math/i386/rintl.s b/src/math/i386/rintl.s
deleted file mode 100644 (file)
index cd2bf9a..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global rintl
-.type rintl,@function
-rintl:
-       fldt 4(%esp)
-       frndint
-       ret
diff --git a/src/math/x86_64/rintl.c b/src/math/x86_64/rintl.c
new file mode 100644 (file)
index 0000000..e1a9207
--- /dev/null
@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double rintl(long double x)
+{
+       __asm__ ("frndint" : "+t"(x));
+       return x;
+}
diff --git a/src/math/x86_64/rintl.s b/src/math/x86_64/rintl.s
deleted file mode 100644 (file)
index 64e663c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.global rintl
-.type rintl,@function
-rintl:
-       fldt 8(%rsp)
-       frndint
-       ret