Make further progress on non-x86 support

This commit is contained in:
Justine Tunney 2023-05-08 21:38:30 -07:00
parent aef9a69a60
commit 036b9a0002
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
155 changed files with 2307 additions and 653 deletions

View file

@ -18,6 +18,19 @@
*/
#include "libc/math.h"
/**
* Rounds 𝑥 to nearest integer, away from zero.
*/
long lroundf(float x) {
return roundf(x);
long res;
#ifdef __aarch64__
asm("fcvtas\t%x0,%s1" : "=r"(res) : "w"(x));
#elif defined(__powerpc64__) && defined(__VSX__)
asm("xsrdpi\t%1,%1\n\t"
"fctid\t%0,%1"
: "=d"(res), "+f"(x));
#else
res = roundf(x);
#endif
return res;
}