Browse Source

math: move x87-family rint functions to C with inline asm

Alexander Monakov 5 years ago
parent
commit
51f4f8c512

+ 7 - 0
src/math/i386/rint.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+double rint(double x)
+{
+	__asm__ ("frndint" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/i386/rint.s

@@ -1,6 +0,0 @@
-.global rint
-.type rint,@function
-rint:
-	fldl 4(%esp)
-	frndint
-	ret

+ 7 - 0
src/math/i386/rintf.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+float rintf(float x)
+{
+	__asm__ ("frndint" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/i386/rintf.s

@@ -1,6 +0,0 @@
-.global rintf
-.type rintf,@function
-rintf:
-	flds 4(%esp)
-	frndint
-	ret

+ 7 - 0
src/math/i386/rintl.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double rintl(long double x)
+{
+	__asm__ ("frndint" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/i386/rintl.s

@@ -1,6 +0,0 @@
-.global rintl
-.type rintl,@function
-rintl:
-	fldt 4(%esp)
-	frndint
-	ret

+ 7 - 0
src/math/x86_64/rintl.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double rintl(long double x)
+{
+	__asm__ ("frndint" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/x86_64/rintl.s

@@ -1,6 +0,0 @@
-.global rintl
-.type rintl,@function
-rintl:
-	fldt 8(%rsp)
-	frndint
-	ret