syscall_arch.h (1800B)
1 /* tcc-build aarch64 syscall_arch.h replacement. 2 * 3 * Stock musl uses GCC register-asm-variable inline asm 4 * (`register long x8 __asm__("x8") = n; ... svc 0`); tcc 0.9.26 lacks 5 * that GCC extension and arm64-asm.c phase 1+2 has no inline-asm 6 * operand constraint plumbing. Route every __syscallN through one 7 * variadic-style trampoline implemented in pure asm 8 * (src/internal/aarch64/syscall.s); the trampoline shuffles C-ABI 9 * x0-x6 into kernel-ABI x8 + x0-x5 and issues svc #0. 10 * 11 * The wrappers are static __inline functions, not macros — musl's 12 * src/internal/syscall.h defines `#define __syscall1(n,a) __syscall1(n,__scc(a))` 13 * which would defeat a macro-form wrapper (CPP self-reference rule 14 * leaves the call unexpanded, producing an unresolved __syscall1 15 * symbol). With static functions, syscall.h's macro applies __scc(), 16 * then the rescan resolves to the static function. 17 * 18 * Mirrors the x86_64 trampoline strategy. */ 19 20 #define __SYSCALL_LL_E(x) (x) 21 #define __SYSCALL_LL_O(x) (x) 22 23 extern long __syscall(long, ...); 24 25 static __inline long __syscall0(long n) 26 { 27 return __syscall(n); 28 } 29 static __inline long __syscall1(long n, long a) 30 { 31 return __syscall(n, a); 32 } 33 static __inline long __syscall2(long n, long a, long b) 34 { 35 return __syscall(n, a, b); 36 } 37 static __inline long __syscall3(long n, long a, long b, long c) 38 { 39 return __syscall(n, a, b, c); 40 } 41 static __inline long __syscall4(long n, long a, long b, long c, long d) 42 { 43 return __syscall(n, a, b, c, d); 44 } 45 static __inline long __syscall5(long n, long a, long b, long c, long d, long e) 46 { 47 return __syscall(n, a, b, c, d, e); 48 } 49 static __inline long __syscall6(long n, long a, long b, long c, long d, long e, long f) 50 { 51 return __syscall(n, a, b, c, d, e, f); 52 } 53 54 #define SYSCALL_FADVISE_6_ARG 55 #define SYSCALL_IPC_BROKEN_MODE