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

@ -49,6 +49,7 @@
*/
privileged int getpriority(int which, unsigned who) {
int rc;
#ifdef __x86_64__
char cf;
if (IsLinux()) {
asm volatile("syscall"
@ -73,6 +74,23 @@ privileged int getpriority(int which, unsigned who) {
} else {
rc = sys_getpriority_nt(which, who);
}
#elif defined(__aarch64__)
register long r0 asm("x0") = (long)which;
register long r1 asm("x1") = (long)who;
register long res_x0 asm("x0");
asm volatile("mov\tx8,%1\n"
"svc\t0"
: "=r"(res_x0)
: "i"(141), "r"(r0), "r"(r1)
: "x8", "memory");
rc = res_x0;
if (rc >= 0) {
rc = NZERO - rc;
} else {
errno = -rc;
rc = -1;
}
#endif
STRACE("getpriority(%s, %u) → %d% m", DescribeWhichPrio(which), who, rc);
return rc;
}