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

@ -19,7 +19,15 @@
#include "libc/math.h"
#include "libc/runtime/fenv.h"
/**
* Rounds to nearest integer.
*/
double nearbyint(double x) {
#ifdef __aarch64__
asm("frinti\t%d0,%d1" : "=w"(x) : "w"(x));
#elif defined(__s390x__) && (defined(__HTM__) || __ARCH__ >= 9)
asm("fidbra\t%0,0,%1,4" : "=f"(x) : "f"(x));
#else
#ifdef FE_INEXACT
// #pragma STDC FENV_ACCESS ON
int e;
@ -29,5 +37,6 @@ double nearbyint(double x) {
#ifdef FE_INEXACT
if (!e) feclearexcept(FE_INEXACT);
#endif
#endif /* __aarch64__ */
return x;
}