Introduce FreeBSD ARM64 support

It's 100% passing test fleet. Solid as a rock.
This commit is contained in:
Justine Tunney 2023-12-29 20:11:23 -08:00
parent 43fe5956ad
commit 83107f78ed
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
455 changed files with 778 additions and 551 deletions

View file

@ -74,13 +74,27 @@ wontreturn void _Exit1(int rc) {
}
notpossible;
#elif defined(__aarch64__)
if (IsLinux()) {
register long r0 asm("x0") = rc;
asm volatile("mov\tx8,%0\n\t"
"svc\t0"
: /* no outputs */
: "i"(93), "r"(r0)
: "x8", "memory");
if (IsLinux() || IsFreebsd()) {
register int x0 asm("x0") = rc;
register int x8 asm("x8");
if (IsLinux()) {
x8 = 93; // exit
} else if (IsFreebsd()) {
x8 = 431; // thr_exit
} else {
__builtin_unreachable();
}
asm volatile("svc\t0" : "+r"(x0) : "r"(x8) : "memory");
if (SupportsFreebsd()) {
// On FreeBSD, thr_exit() fails if the current thread is orphaned.
// In that case we're really better off just calling plain _exit()
x0 = rc;
asm volatile("mov\tx8,#1\n\t"
"svc\t0"
: /* no outputs */
: "r"(x0)
: "memory");
}
} else if (IsXnu()) {
__syslib->__pthread_exit(0);
}