1 #define __SYSCALL_LL_E(x) \
2 ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
3 ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
4 #define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x))
5
6 #define __asm_syscall(...) do { \
7 __asm__ __volatile__ ( "svc 0" \
8 : "=r"(r0) : __VA_ARGS__ : "memory"); \
9 return r0; \
10 } while (0)
11
12 #define R7_OPERAND "r"(r7)
13
__syscall0(long n)14 static inline long __syscall0(long n)
15 {
16 register long r7 __asm__("r7") = n;
17 register long r0 __asm__("r0");
18 __asm_syscall(R7_OPERAND);
19 }
20
__syscall1(long n,long a)21 static inline long __syscall1(long n, long a)
22 {
23 register long r7 __asm__("r7") = n;
24 register long r0 __asm__("r0") = a;
25 __asm_syscall(R7_OPERAND, "0"(r0));
26 }
27
__syscall2(long n,long a,long b)28 static inline long __syscall2(long n, long a, long b)
29 {
30 register long r7 __asm__("r7") = n;
31 register long r0 __asm__("r0") = a;
32 register long r1 __asm__("r1") = b;
33 __asm_syscall(R7_OPERAND, "0"(r0), "r"(r1));
34 }
35
__syscall3(long n,long a,long b,long c)36 static inline long __syscall3(long n, long a, long b, long c)
37 {
38 register long r7 __asm__("r7") = n;
39 register long r0 __asm__("r0") = a;
40 register long r1 __asm__("r1") = b;
41 register long r2 __asm__("r2") = c;
42 __asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2));
43 }
44
__syscall4(long n,long a,long b,long c,long d)45 static inline long __syscall4(long n, long a, long b, long c, long d)
46 {
47 register long r7 __asm__("r7") = n;
48 register long r0 __asm__("r0") = a;
49 register long r1 __asm__("r1") = b;
50 register long r2 __asm__("r2") = c;
51 register long r3 __asm__("r3") = d;
52 __asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2), "r"(r3));
53 }
54
__syscall5(long n,long a,long b,long c,long d,long e)55 static inline long __syscall5(long n, long a, long b, long c, long d, long e)
56 {
57 register long r7 __asm__("r7") = n;
58 register long r0 __asm__("r0") = a;
59 register long r1 __asm__("r1") = b;
60 register long r2 __asm__("r2") = c;
61 register long r3 __asm__("r3") = d;
62 register long r4 __asm__("r4") = e;
63 __asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4));
64 }
65
__syscall6(long n,long a,long b,long c,long d,long e,long f)66 static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
67 {
68 register long r7 __asm__("r7") = n;
69 register long r0 __asm__("r0") = a;
70 register long r1 __asm__("r1") = b;
71 register long r2 __asm__("r2") = c;
72 register long r3 __asm__("r3") = d;
73 register long r4 __asm__("r4") = e;
74 register long r5 __asm__("r5") = f;
75 __asm_syscall(R7_OPERAND, "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4), "r"(r5));
76 }
77