Make more code aarch64 friendly

This commit is contained in:
Justine Tunney 2023-05-02 13:38:16 -07:00
parent ca2860947f
commit 2b73e72d59
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
568 changed files with 2197 additions and 1061 deletions

View file

@ -18,6 +18,7 @@
*/
#include "libc/calls/struct/seccomp.h"
#include "libc/calls/calls.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/describeflags.internal.h"
@ -36,6 +37,7 @@
*/
privileged int seccomp(unsigned operation, unsigned flags, void *args) {
int rc;
#ifdef __x86_64__
if (IsLinux()) {
asm volatile("syscall"
: "=a"(rc)
@ -62,6 +64,20 @@ privileged int seccomp(unsigned operation, unsigned flags, void *args) {
} else {
rc = enosys();
}
#elif defined(__aarch64__)
register long r0 asm("x0") = (long)operation;
register long r1 asm("x1") = (long)flags;
register long r2 asm("x2") = (long)args;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n"
"svc\t0"
: "=r"(res_x0)
: "i"(211), "r"(r0), "r"(r1), "r"(r2)
: "x8", "memory");
rc = _sysret32(res_x0);
#else
#error "arch unsupported"
#endif
STRACE("seccomp(%s, %#x, %p) → %d% m", DescribeSeccompOperation(operation),
flags, args, rc);
return rc;