瀏覽代碼

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

Alexander Monakov 5 年之前
父節點
當前提交
51f4f8c512
共有 8 個文件被更改,包括 28 次插入24 次删除
  1. 7 0
      src/math/i386/rint.c
  2. 0 6
      src/math/i386/rint.s
  3. 7 0
      src/math/i386/rintf.c
  4. 0 6
      src/math/i386/rintf.s
  5. 7 0
      src/math/i386/rintl.c
  6. 0 6
      src/math/i386/rintl.s
  7. 7 0
      src/math/x86_64/rintl.c
  8. 0 6
      src/math/x86_64/rintl.s

+ 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