From 51f4f8c512d682fe0c1a7a891909e75f416f20f6 Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Tue, 14 Jan 2020 14:53:38 +0300 Subject: math: move x87-family rint functions to C with inline asm --- src/math/i386/rint.c | 7 +++++++ src/math/i386/rint.s | 6 ------ src/math/i386/rintf.c | 7 +++++++ src/math/i386/rintf.s | 6 ------ src/math/i386/rintl.c | 7 +++++++ src/math/i386/rintl.s | 6 ------ src/math/x86_64/rintl.c | 7 +++++++ src/math/x86_64/rintl.s | 6 ------ 8 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 src/math/i386/rint.c delete mode 100644 src/math/i386/rint.s create mode 100644 src/math/i386/rintf.c delete mode 100644 src/math/i386/rintf.s create mode 100644 src/math/i386/rintl.c delete mode 100644 src/math/i386/rintl.s create mode 100644 src/math/x86_64/rintl.c delete mode 100644 src/math/x86_64/rintl.s diff --git a/src/math/i386/rint.c b/src/math/i386/rint.c new file mode 100644 index 00000000..a5276a60 --- /dev/null +++ b/src/math/i386/rint.c @@ -0,0 +1,7 @@ +#include + +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 index bb99a11c..00000000 --- a/src/math/i386/rint.s +++ /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 index 00000000..bb4121a4 --- /dev/null +++ b/src/math/i386/rintf.c @@ -0,0 +1,7 @@ +#include + +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 index bce4c5a6..00000000 --- a/src/math/i386/rintf.s +++ /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 index 00000000..e1a92077 --- /dev/null +++ b/src/math/i386/rintl.c @@ -0,0 +1,7 @@ +#include + +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 index cd2bf9a9..00000000 --- a/src/math/i386/rintl.s +++ /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 index 00000000..e1a92077 --- /dev/null +++ b/src/math/x86_64/rintl.c @@ -0,0 +1,7 @@ +#include + +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 index 64e663cd..00000000 --- a/src/math/x86_64/rintl.s +++ /dev/null @@ -1,6 +0,0 @@ -.global rintl -.type rintl,@function -rintl: - fldt 8(%rsp) - frndint - ret -- cgit v1.2.1