Port a lot more code to AARCH64

- Introduce epoll_pwait()
- Rewrite -ftrapv and ffs() libraries in C code
- Use more FreeBSD code in math function library
- Get significantly more tests passing on qemu-aarch64
- Fix many Musl long double functions that were broken on AARCH64
This commit is contained in:
Justine Tunney 2023-05-14 09:32:15 -07:00
parent 91791e9f38
commit 550b52abf6
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
158 changed files with 6018 additions and 3499 deletions

View file

@ -22,44 +22,45 @@
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
double _trunc(double) asm("trunc");
float _truncf(float) asm("truncf");
long double _truncl(long double) asm("truncl");
TEST(trunc, test) {
EXPECT_STREQ("3", gc(xdtoa(trunc(3))));
EXPECT_STREQ("3", gc(xdtoa(trunc(3.14))));
EXPECT_STREQ("-3", gc(xdtoa(trunc(-3.14))));
EXPECT_STREQ("-0", gc(xdtoa(trunc(-0.))));
EXPECT_STREQ("NAN", gc(xdtoa(trunc(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(trunc(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(trunc(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(trunc(-INFINITY))));
EXPECT_STREQ("3", gc(xdtoa(_trunc(3))));
EXPECT_STREQ("3", gc(xdtoa(_trunc(3.14))));
EXPECT_STREQ("-3", gc(xdtoa(_trunc(-3.14))));
EXPECT_STREQ("-0", gc(xdtoa(_trunc(-0.))));
EXPECT_STREQ("NAN", gc(xdtoa(_trunc(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(_trunc(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(_trunc(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(_trunc(-INFINITY))));
}
TEST(truncf, test) {
EXPECT_STREQ("3", gc(xdtoaf(truncf(3))));
EXPECT_STREQ("3", gc(xdtoaf(truncf(3.14))));
EXPECT_STREQ("-3", gc(xdtoaf(truncf(-3.14))));
EXPECT_STREQ("-0", gc(xdtoaf(truncf(-0.))));
EXPECT_STREQ("NAN", gc(xdtoaf(truncf(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoaf(truncf(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoaf(truncf(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoaf(truncf(-INFINITY))));
EXPECT_STREQ("3", gc(xdtoaf(_truncf(3))));
EXPECT_STREQ("3", gc(xdtoaf(_truncf(3.14))));
EXPECT_STREQ("-3", gc(xdtoaf(_truncf(-3.14))));
EXPECT_STREQ("-0", gc(xdtoaf(_truncf(-0.))));
EXPECT_STREQ("NAN", gc(xdtoaf(_truncf(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoaf(_truncf(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoaf(_truncf(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoaf(_truncf(-INFINITY))));
}
TEST(truncl, test) {
EXPECT_STREQ("3", gc(xdtoal(truncl(3))));
EXPECT_STREQ("3", gc(xdtoal(truncl(3.14))));
EXPECT_STREQ("-3", gc(xdtoal(truncl(-3.14))));
EXPECT_STREQ("-0", gc(xdtoal(truncl(-0.))));
EXPECT_STREQ("NAN", gc(xdtoal(truncl(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoal(truncl(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoal(truncl(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoal(truncl(-INFINITY))));
EXPECT_STREQ("3", gc(xdtoal(_truncl(3))));
EXPECT_STREQ("3", gc(xdtoal(_truncl(3.14))));
EXPECT_STREQ("-3", gc(xdtoal(_truncl(-3.14))));
EXPECT_STREQ("-0", gc(xdtoal(_truncl(-0.))));
EXPECT_STREQ("NAN", gc(xdtoal(_truncl(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoal(_truncl(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoal(_truncl(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoal(_truncl(-INFINITY))));
}
BENCH(truncl, bench) {
double _trunc(double) asm("trunc");
float _truncf(float) asm("truncf");
long double _truncl(long double) asm("truncl");
EZBENCH2("trunc", donothing, _trunc(.7)); /* ~2ns */
EZBENCH2("truncf", donothing, _truncf(.7)); /* ~2ns */
EZBENCH2("truncl", donothing, _truncl(.7)); /* ~9ns */
EZBENCH2("trunc", donothing, _trunc(.7)); // ~1ns
EZBENCH2("truncf", donothing, _truncf(.7)); // ~1ns
EZBENCH2("truncl", donothing, _truncl(.7)); // ~7ns
}