riscv32: add new syscall numbers
[musl.git] / arch / mips / syscall_arch.h
blob5b7c38de2043f6250db3cb691aa1782a71e3d273
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))
6 #define SYSCALL_RLIM_INFINITY (-1UL/2)
8 #if __mips_isa_rev >= 6
9 #define SYSCALL_CLOBBERLIST \
10 "$1", "$3", "$11", "$12", "$13", \
11 "$14", "$15", "$24", "$25", "memory"
12 #else
13 #define SYSCALL_CLOBBERLIST \
14 "$1", "$3", "$11", "$12", "$13", \
15 "$14", "$15", "$24", "$25", "hi", "lo", "memory"
16 #endif
18 static inline long __syscall0(long n)
20 register long r7 __asm__("$7");
21 register long r2 __asm__("$2");
22 __asm__ __volatile__ (
23 "addu $2,$0,%2 ; syscall"
24 : "=&r"(r2), "=r"(r7)
25 : "ir"(n), "0"(r2)
26 : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
27 return r7 && r2>0 ? -r2 : r2;
30 static inline long __syscall1(long n, long a)
32 register long r4 __asm__("$4") = a;
33 register long r7 __asm__("$7");
34 register long r2 __asm__("$2");
35 __asm__ __volatile__ (
36 "addu $2,$0,%2 ; syscall"
37 : "=&r"(r2), "=r"(r7)
38 : "ir"(n), "0"(r2), "r"(r4)
39 : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
40 return r7 && r2>0 ? -r2 : r2;
43 static inline long __syscall2(long n, long a, long b)
45 register long r4 __asm__("$4") = a;
46 register long r5 __asm__("$5") = b;
47 register long r7 __asm__("$7");
48 register long r2 __asm__("$2");
49 __asm__ __volatile__ (
50 "addu $2,$0,%2 ; syscall"
51 : "=&r"(r2), "=r"(r7)
52 : "ir"(n), "0"(r2), "r"(r4), "r"(r5)
53 : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
54 return r7 && r2>0 ? -r2 : r2;
57 static inline long __syscall3(long n, long a, long b, long c)
59 register long r4 __asm__("$4") = a;
60 register long r5 __asm__("$5") = b;
61 register long r6 __asm__("$6") = c;
62 register long r7 __asm__("$7");
63 register long r2 __asm__("$2");
64 __asm__ __volatile__ (
65 "addu $2,$0,%2 ; syscall"
66 : "=&r"(r2), "=r"(r7)
67 : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6)
68 : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
69 return r7 && r2>0 ? -r2 : r2;
72 static inline long __syscall4(long n, long a, long b, long c, long d)
74 register long r4 __asm__("$4") = a;
75 register long r5 __asm__("$5") = b;
76 register long r6 __asm__("$6") = c;
77 register long r7 __asm__("$7") = d;
78 register long r2 __asm__("$2");
79 __asm__ __volatile__ (
80 "addu $2,$0,%2 ; syscall"
81 : "=&r"(r2), "+r"(r7)
82 : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6)
83 : SYSCALL_CLOBBERLIST, "$8", "$9", "$10");
84 return r7 && r2>0 ? -r2 : r2;
87 static inline long __syscall5(long n, long a, long b, long c, long d, long e)
89 register long r4 __asm__("$4") = a;
90 register long r5 __asm__("$5") = b;
91 register long r6 __asm__("$6") = c;
92 register long r7 __asm__("$7") = d;
93 register long r8 __asm__("$8") = e;
94 register long r2 __asm__("$2");
95 __asm__ __volatile__ (
96 "subu $sp,$sp,32 ; sw $8,16($sp) ; "
97 "addu $2,$0,%3 ; syscall ;"
98 "addu $sp,$sp,32"
99 : "=&r"(r2), "+r"(r7), "+r"(r8)
100 : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6)
101 : SYSCALL_CLOBBERLIST, "$9", "$10");
102 return r7 && r2>0 ? -r2 : r2;
105 static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
107 register long r4 __asm__("$4") = a;
108 register long r5 __asm__("$5") = b;
109 register long r6 __asm__("$6") = c;
110 register long r7 __asm__("$7") = d;
111 register long r8 __asm__("$8") = e;
112 register long r9 __asm__("$9") = f;
113 register long r2 __asm__("$2");
114 __asm__ __volatile__ (
115 "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; "
116 "addu $2,$0,%4 ; syscall ;"
117 "addu $sp,$sp,32"
118 : "=&r"(r2), "+r"(r7), "+r"(r8), "+r"(r9)
119 : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6)
120 : SYSCALL_CLOBBERLIST, "$10");
121 return r7 && r2>0 ? -r2 : r2;
124 static inline long __syscall7(long n, long a, long b, long c, long d, long e, long f, long g)
126 register long r4 __asm__("$4") = a;
127 register long r5 __asm__("$5") = b;
128 register long r6 __asm__("$6") = c;
129 register long r7 __asm__("$7") = d;
130 register long r8 __asm__("$8") = e;
131 register long r9 __asm__("$9") = f;
132 register long r10 __asm__("$10") = g;
133 register long r2 __asm__("$2");
134 __asm__ __volatile__ (
135 "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; sw $10,24($sp) ; "
136 "addu $2,$0,%5 ; syscall ;"
137 "addu $sp,$sp,32"
138 : "=&r"(r2), "+r"(r7), "+r"(r8), "+r"(r9), "+r"(r10)
139 : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6)
140 : SYSCALL_CLOBBERLIST);
141 return r7 && r2>0 ? -r2 : r2;
144 #define VDSO_USEFUL
145 #define VDSO_CGT32_SYM "__vdso_clock_gettime"
146 #define VDSO_CGT32_VER "LINUX_2.6"
147 #define VDSO_CGT_SYM "__vdso_clock_gettime64"
148 #define VDSO_CGT_VER "LINUX_2.6"
150 #define SO_SNDTIMEO_OLD 0x1005
151 #define SO_RCVTIMEO_OLD 0x1006
153 #undef SYS_socketcall