Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: fusl/src/internal/syscall.h

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef _INTERNAL_SYSCALL_H 1 #ifndef _INTERNAL_SYSCALL_H
2 #define _INTERNAL_SYSCALL_H 2 #define _INTERNAL_SYSCALL_H
3 3
4 #include <sys/syscall.h> 4 #include <sys/syscall.h>
5 #include "syscall_arch.h" 5 #include "syscall_arch.h"
6 6
7 #ifndef SYSCALL_RLIM_INFINITY 7 #ifndef SYSCALL_RLIM_INFINITY
8 #define SYSCALL_RLIM_INFINITY (~0ULL) 8 #define SYSCALL_RLIM_INFINITY (~0ULL)
9 #endif 9 #endif
10 10
11 #ifndef SYSCALL_MMAP2_UNIT 11 #ifndef SYSCALL_MMAP2_UNIT
12 #define SYSCALL_MMAP2_UNIT 4096ULL 12 #define SYSCALL_MMAP2_UNIT 4096ULL
13 #endif 13 #endif
14 14
15 #ifndef __scc 15 #ifndef __scc
16 #define __scc(X) ((long) (X)) 16 #define __scc(X) ((long)(X))
17 typedef long syscall_arg_t; 17 typedef long syscall_arg_t;
18 #endif 18 #endif
19 19
20 __attribute__((visibility("hidden"))) 20 __attribute__((visibility("hidden"))) long __syscall_ret(unsigned long),
21 long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...), 21 __syscall(syscall_arg_t, ...), __syscall_cp(syscall_arg_t,
22 » __syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t, 22 syscall_arg_t,
23 » syscall_arg_t, syscall_arg_t, syscall_arg_t); 23 syscall_arg_t,
24 syscall_arg_t,
25 syscall_arg_t,
26 syscall_arg_t,
27 syscall_arg_t);
24 28
25 #ifdef SYSCALL_NO_INLINE 29 #ifdef SYSCALL_NO_INLINE
26 #define __syscall0(n) (__syscall)(n) 30 #define __syscall0(n) (__syscall)(n)
27 #define __syscall1(n,a) (__syscall)(n,__scc(a)) 31 #define __syscall1(n, a) (__syscall)(n, __scc(a))
28 #define __syscall2(n,a,b) (__syscall)(n,__scc(a),__scc(b)) 32 #define __syscall2(n, a, b) (__syscall)(n, __scc(a), __scc(b))
29 #define __syscall3(n,a,b,c) (__syscall)(n,__scc(a),__scc(b),__scc(c)) 33 #define __syscall3(n, a, b, c) (__syscall)(n, __scc(a), __scc(b), __scc(c))
30 #define __syscall4(n,a,b,c,d) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d)) 34 #define __syscall4(n, a, b, c, d) \
31 #define __syscall5(n,a,b,c,d,e) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d ),__scc(e)) 35 (__syscall)(n, __scc(a), __scc(b), __scc(c), __scc(d))
32 #define __syscall6(n,a,b,c,d,e,f) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc (d),__scc(e),__scc(f)) 36 #define __syscall5(n, a, b, c, d, e) \
37 (__syscall)(n, __scc(a), __scc(b), __scc(c), __scc(d), __scc(e))
38 #define __syscall6(n, a, b, c, d, e, f) \
39 (__syscall)(n, __scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
33 #else 40 #else
34 #define __syscall1(n,a) __syscall1(n,__scc(a)) 41 #define __syscall1(n, a) __syscall1(n, __scc(a))
35 #define __syscall2(n,a,b) __syscall2(n,__scc(a),__scc(b)) 42 #define __syscall2(n, a, b) __syscall2(n, __scc(a), __scc(b))
36 #define __syscall3(n,a,b,c) __syscall3(n,__scc(a),__scc(b),__scc(c)) 43 #define __syscall3(n, a, b, c) __syscall3(n, __scc(a), __scc(b), __scc(c))
37 #define __syscall4(n,a,b,c,d) __syscall4(n,__scc(a),__scc(b),__scc(c),__scc(d)) 44 #define __syscall4(n, a, b, c, d) \
38 #define __syscall5(n,a,b,c,d,e) __syscall5(n,__scc(a),__scc(b),__scc(c),__scc(d) ,__scc(e)) 45 __syscall4(n, __scc(a), __scc(b), __scc(c), __scc(d))
39 #define __syscall6(n,a,b,c,d,e,f) __syscall6(n,__scc(a),__scc(b),__scc(c),__scc( d),__scc(e),__scc(f)) 46 #define __syscall5(n, a, b, c, d, e) \
47 __syscall5(n, __scc(a), __scc(b), __scc(c), __scc(d), __scc(e))
48 #define __syscall6(n, a, b, c, d, e, f) \
49 __syscall6(n, __scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
40 #endif 50 #endif
41 #define __syscall7(n,a,b,c,d,e,f,g) (__syscall)(n,__scc(a),__scc(b),__scc(c),__s cc(d),__scc(e),__scc(f),__scc(g)) 51 #define __syscall7(n, a, b, c, d, e, f, g) \
52 (__syscall)(n, __scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f), \
53 __scc(g))
42 54
43 #define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n 55 #define __SYSCALL_NARGS_X(a, b, c, d, e, f, g, h, n, ...) n
44 #define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,) 56 #define __SYSCALL_NARGS(...) \
45 #define __SYSCALL_CONCAT_X(a,b) a##b 57 __SYSCALL_NARGS_X(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1, 0, )
46 #define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b) 58 #define __SYSCALL_CONCAT_X(a, b) a##b
47 #define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(_ _VA_ARGS__) 59 #define __SYSCALL_CONCAT(a, b) __SYSCALL_CONCAT_X(a, b)
60 #define __SYSCALL_DISP(b, ...) \
61 __SYSCALL_CONCAT(b, __SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
48 62
49 #define __syscall(...) __SYSCALL_DISP(__syscall,__VA_ARGS__) 63 #define __syscall(...) __SYSCALL_DISP(__syscall, __VA_ARGS__)
50 #define syscall(...) __syscall_ret(__syscall(__VA_ARGS__)) 64 #define syscall(...) __syscall_ret(__syscall(__VA_ARGS__))
51 65
52 #define socketcall __socketcall 66 #define socketcall __socketcall
53 #define socketcall_cp __socketcall_cp 67 #define socketcall_cp __socketcall_cp
54 68
55 #define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0) 69 #define __syscall_cp0(n) (__syscall_cp)(n, 0, 0, 0, 0, 0, 0)
56 #define __syscall_cp1(n,a) (__syscall_cp)(n,__scc(a),0,0,0,0,0) 70 #define __syscall_cp1(n, a) (__syscall_cp)(n, __scc(a), 0, 0, 0, 0, 0)
57 #define __syscall_cp2(n,a,b) (__syscall_cp)(n,__scc(a),__scc(b),0,0,0,0) 71 #define __syscall_cp2(n, a, b) (__syscall_cp)(n, __scc(a), __scc(b), 0, 0, 0, 0)
58 #define __syscall_cp3(n,a,b,c) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),0,0,0 ) 72 #define __syscall_cp3(n, a, b, c) \
59 #define __syscall_cp4(n,a,b,c,d) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__s cc(d),0,0) 73 (__syscall_cp)(n, __scc(a), __scc(b), __scc(c), 0, 0, 0)
60 #define __syscall_cp5(n,a,b,c,d,e) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),_ _scc(d),__scc(e),0) 74 #define __syscall_cp4(n, a, b, c, d) \
61 #define __syscall_cp6(n,a,b,c,d,e,f) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c) ,__scc(d),__scc(e),__scc(f)) 75 (__syscall_cp)(n, __scc(a), __scc(b), __scc(c), __scc(d), 0, 0)
76 #define __syscall_cp5(n, a, b, c, d, e) \
77 (__syscall_cp)(n, __scc(a), __scc(b), __scc(c), __scc(d), __scc(e), 0)
78 #define __syscall_cp6(n, a, b, c, d, e, f) \
79 (__syscall_cp)(n, __scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
62 80
63 #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__) 81 #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp, __VA_ARGS__)
64 #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) 82 #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))
65 83
66 #ifndef SYSCALL_USE_SOCKETCALL 84 #ifndef SYSCALL_USE_SOCKETCALL
67 #define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_##nm, a, b, c, d, e, f) 85 #define __socketcall(nm, a, b, c, d, e, f) syscall(SYS_##nm, a, b, c, d, e, f)
68 #define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_##nm, a, b, c, d, e, f) 86 #define __socketcall_cp(nm, a, b, c, d, e, f) \
87 syscall_cp(SYS_##nm, a, b, c, d, e, f)
69 #else 88 #else
70 #define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_socketcall, __SC_##nm, \ 89 #define __socketcall(nm, a, b, c, d, e, f) \
71 ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) 90 syscall(SYS_socketcall, __SC_##nm, \
72 #define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_socketcall, __SC_##nm, \ 91 ((long[6]){(long)a, (long)b, (long)c, (long)d, (long)e, (long)f}))
73 ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) 92 #define __socketcall_cp(nm, a, b, c, d, e, f) \
93 syscall_cp( \
94 SYS_socketcall, __SC_##nm, \
95 ((long[6]){(long)a, (long)b, (long)c, (long)d, (long)e, (long)f}))
74 #endif 96 #endif
75 97
76 /* fixup legacy 16-bit junk */ 98 /* fixup legacy 16-bit junk */
77 99
78 #ifdef SYS_getuid32 100 #ifdef SYS_getuid32
79 #undef SYS_lchown 101 #undef SYS_lchown
80 #undef SYS_getuid 102 #undef SYS_getuid
81 #undef SYS_getgid 103 #undef SYS_getgid
82 #undef SYS_geteuid 104 #undef SYS_geteuid
83 #undef SYS_getegid 105 #undef SYS_getegid
(...skipping 25 matching lines...) Expand all
109 #define SYS_getresuid SYS_getresuid32 131 #define SYS_getresuid SYS_getresuid32
110 #define SYS_setresgid SYS_setresgid32 132 #define SYS_setresgid SYS_setresgid32
111 #define SYS_getresgid SYS_getresgid32 133 #define SYS_getresgid SYS_getresgid32
112 #define SYS_chown SYS_chown32 134 #define SYS_chown SYS_chown32
113 #define SYS_setuid SYS_setuid32 135 #define SYS_setuid SYS_setuid32
114 #define SYS_setgid SYS_setgid32 136 #define SYS_setgid SYS_setgid32
115 #define SYS_setfsuid SYS_setfsuid32 137 #define SYS_setfsuid SYS_setfsuid32
116 #define SYS_setfsgid SYS_setfsgid32 138 #define SYS_setfsgid SYS_setfsgid32
117 #endif 139 #endif
118 140
119
120 /* fixup legacy 32-bit-vs-lfs64 junk */ 141 /* fixup legacy 32-bit-vs-lfs64 junk */
121 142
122 #ifdef SYS_fcntl64 143 #ifdef SYS_fcntl64
123 #undef SYS_fcntl 144 #undef SYS_fcntl
124 #define SYS_fcntl SYS_fcntl64 145 #define SYS_fcntl SYS_fcntl64
125 #endif 146 #endif
126 147
127 #ifdef SYS_getdents64 148 #ifdef SYS_getdents64
128 #undef SYS_getdents 149 #undef SYS_getdents
129 #define SYS_getdents SYS_getdents64 150 #define SYS_getdents SYS_getdents64
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 #define SYS_fadvise SYS_fadvise64 215 #define SYS_fadvise SYS_fadvise64
195 #endif 216 #endif
196 217
197 #ifdef SYS_sendfile64 218 #ifdef SYS_sendfile64
198 #undef SYS_sendfile 219 #undef SYS_sendfile
199 #define SYS_sendfile SYS_sendfile64 220 #define SYS_sendfile SYS_sendfile64
200 #endif 221 #endif
201 222
202 /* socketcall calls */ 223 /* socketcall calls */
203 224
204 #define __SC_socket 1 225 #define __SC_socket 1
205 #define __SC_bind 2 226 #define __SC_bind 2
206 #define __SC_connect 3 227 #define __SC_connect 3
207 #define __SC_listen 4 228 #define __SC_listen 4
208 #define __SC_accept 5 229 #define __SC_accept 5
209 #define __SC_getsockname 6 230 #define __SC_getsockname 6
210 #define __SC_getpeername 7 231 #define __SC_getpeername 7
211 #define __SC_socketpair 8 232 #define __SC_socketpair 8
212 #define __SC_send 9 233 #define __SC_send 9
213 #define __SC_recv 10 234 #define __SC_recv 10
214 #define __SC_sendto 11 235 #define __SC_sendto 11
215 #define __SC_recvfrom 12 236 #define __SC_recvfrom 12
216 #define __SC_shutdown 13 237 #define __SC_shutdown 13
217 #define __SC_setsockopt 14 238 #define __SC_setsockopt 14
218 #define __SC_getsockopt 15 239 #define __SC_getsockopt 15
219 #define __SC_sendmsg 16 240 #define __SC_sendmsg 16
220 #define __SC_recvmsg 17 241 #define __SC_recvmsg 17
221 #define __SC_accept4 18 242 #define __SC_accept4 18
222 #define __SC_recvmmsg 19 243 #define __SC_recvmmsg 19
223 #define __SC_sendmmsg 20 244 #define __SC_sendmmsg 20
224 245
225 #ifdef SYS_open 246 #ifdef SYS_open
226 #define __sys_open2(x,pn,fl) __syscall2(SYS_open, pn, (fl)|O_LARGEFILE) 247 #define __sys_open2(x, pn, fl) __syscall2(SYS_open, pn, (fl) | O_LARGEFILE)
227 #define __sys_open3(x,pn,fl,mo) __syscall3(SYS_open, pn, (fl)|O_LARGEFILE, mo) 248 #define __sys_open3(x, pn, fl, mo) \
228 #define __sys_open_cp2(x,pn,fl) __syscall_cp2(SYS_open, pn, (fl)|O_LARGEFILE) 249 __syscall3(SYS_open, pn, (fl) | O_LARGEFILE, mo)
229 #define __sys_open_cp3(x,pn,fl,mo) __syscall_cp3(SYS_open, pn, (fl)|O_LARGEFILE, mo) 250 #define __sys_open_cp2(x, pn, fl) \
251 __syscall_cp2(SYS_open, pn, (fl) | O_LARGEFILE)
252 #define __sys_open_cp3(x, pn, fl, mo) \
253 __syscall_cp3(SYS_open, pn, (fl) | O_LARGEFILE, mo)
230 #else 254 #else
231 #define __sys_open2(x,pn,fl) __syscall3(SYS_openat, AT_FDCWD, pn, (fl)|O_LARGEFI LE) 255 #define __sys_open2(x, pn, fl) \
232 #define __sys_open3(x,pn,fl,mo) __syscall4(SYS_openat, AT_FDCWD, pn, (fl)|O_LARG EFILE, mo) 256 __syscall3(SYS_openat, AT_FDCWD, pn, (fl) | O_LARGEFILE)
233 #define __sys_open_cp2(x,pn,fl) __syscall_cp3(SYS_openat, AT_FDCWD, pn, (fl)|O_L ARGEFILE) 257 #define __sys_open3(x, pn, fl, mo) \
234 #define __sys_open_cp3(x,pn,fl,mo) __syscall_cp4(SYS_openat, AT_FDCWD, pn, (fl)| O_LARGEFILE, mo) 258 __syscall4(SYS_openat, AT_FDCWD, pn, (fl) | O_LARGEFILE, mo)
259 #define __sys_open_cp2(x, pn, fl) \
260 __syscall_cp3(SYS_openat, AT_FDCWD, pn, (fl) | O_LARGEFILE)
261 #define __sys_open_cp3(x, pn, fl, mo) \
262 __syscall_cp4(SYS_openat, AT_FDCWD, pn, (fl) | O_LARGEFILE, mo)
235 #endif 263 #endif
236 264
237 #define __sys_open(...) __SYSCALL_DISP(__sys_open,,__VA_ARGS__) 265 #define __sys_open(...) __SYSCALL_DISP(__sys_open, , __VA_ARGS__)
238 #define sys_open(...) __syscall_ret(__sys_open(__VA_ARGS__)) 266 #define sys_open(...) __syscall_ret(__sys_open(__VA_ARGS__))
239 267
240 #define __sys_open_cp(...) __SYSCALL_DISP(__sys_open_cp,,__VA_ARGS__) 268 #define __sys_open_cp(...) __SYSCALL_DISP(__sys_open_cp, , __VA_ARGS__)
241 #define sys_open_cp(...) __syscall_ret(__sys_open_cp(__VA_ARGS__)) 269 #define sys_open_cp(...) __syscall_ret(__sys_open_cp(__VA_ARGS__))
242 270
243 #endif 271 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698