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

This commit is contained in:
Alexander Monakov 2020-01-14 14:53:38 +03:00 committed by Rich Felker
parent 9443f1b5cf
commit 51f4f8c512
8 changed files with 28 additions and 24 deletions

7
src/math/i386/rint.c Normal file
View File

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

View File

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

7
src/math/i386/rintf.c Normal file
View File

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

View File

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

7
src/math/i386/rintl.c Normal file
View File

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

View File

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

7
src/math/x86_64/rintl.c Normal file
View File

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

View File

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