|
45 | 45 | * @param t Type of the function arguments |
46 | 46 | * @param n name of the function arguments |
47 | 47 | */ |
48 | | -#define __MAP1(m,t,n) m(t,n) |
49 | | -#define __MAP2(m,t,n,...) m(t,n), __MAP1(m,__VA_ARGS__) |
50 | | -#define __MAP3(m,t,n,...) m(t,n), __MAP2(m,__VA_ARGS__) |
51 | | -#define __MAP4(m,t,n,...) m(t,n), __MAP3(m,__VA_ARGS__) |
52 | | -#define __MAP5(m,t,n,...) m(t,n), __MAP4(m,__VA_ARGS__) |
53 | | -#define __MAP6(m,t,n,...) m(t,n), __MAP5(m,__VA_ARGS__) |
54 | | -#define __MAP(x,m,...) __MAP##x(m,__VA_ARGS__) |
| 48 | +#define __MAP1(m, t, n) m(t, n) |
| 49 | +#define __MAP2(m, t, n, ...) m(t, n), __MAP1(m, __VA_ARGS__) |
| 50 | +#define __MAP3(m, t, n, ...) m(t, n), __MAP2(m, __VA_ARGS__) |
| 51 | +#define __MAP4(m, t, n, ...) m(t, n), __MAP3(m, __VA_ARGS__) |
| 52 | +#define __MAP5(m, t, n, ...) m(t, n), __MAP4(m, __VA_ARGS__) |
| 53 | +#define __MAP6(m, t, n, ...) m(t, n), __MAP5(m, __VA_ARGS__) |
| 54 | +#define __MAP(x, m, ...) __MAP##x(m, __VA_ARGS__) |
55 | 55 |
|
56 | 56 | /** Macros to map type and name with __MAP */ |
57 | | -#define __M_DECL(t,n) t n |
58 | | -#define __M_LONG(t,n) long n |
59 | | -#define __M_ARGS(t,n) n |
| 57 | +#define __M_DECL(t, n) t n |
| 58 | +#define __M_LONG(t, n) long n |
| 59 | +#define __M_ARGS(t, n) n |
60 | 60 |
|
61 | 61 | /** |
62 | 62 | * Map syscall arguments by casting them for function call. |
|
68 | 68 | * @param n name of the function arguments, not use but allow |
69 | 69 | * to use same __VA_ARGS__ as in __MAP() |
70 | 70 | */ |
71 | | -#define __MAP_ARGS1(x,args,t,n) (t)args[x-1] |
72 | | -#define __MAP_ARGS2(x,args,t,n,...) (t)args[x-2], __MAP_ARGS1(x,args,__VA_ARGS__) |
73 | | -#define __MAP_ARGS3(x,args,t,n,...) (t)args[x-3], __MAP_ARGS2(x,args,__VA_ARGS__) |
74 | | -#define __MAP_ARGS4(x,args,t,n,...) (t)args[x-4], __MAP_ARGS3(x,args,__VA_ARGS__) |
75 | | -#define __MAP_ARGS5(x,args,t,n,...) (t)args[x-5], __MAP_ARGS4(x,args,__VA_ARGS__) |
76 | | -#define __MAP_ARGS6(x,args,t,n,...) (t)args[x-6], __MAP_ARGS5(x,args,__VA_ARGS__) |
77 | | -#define __MAP_ARGS(x,args,...) __MAP_ARGS##x((x),(args),__VA_ARGS__) |
| 71 | +#define __MAP_ARGS1(x, args, t, n) (t) args[x - 1] |
| 72 | +#define __MAP_ARGS2(x, args, t, n, ...) (t) args[x - 2], __MAP_ARGS1(x, args, __VA_ARGS__) |
| 73 | +#define __MAP_ARGS3(x, args, t, n, ...) (t) args[x - 3], __MAP_ARGS2(x, args, __VA_ARGS__) |
| 74 | +#define __MAP_ARGS4(x, args, t, n, ...) (t) args[x - 4], __MAP_ARGS3(x, args, __VA_ARGS__) |
| 75 | +#define __MAP_ARGS5(x, args, t, n, ...) (t) args[x - 5], __MAP_ARGS4(x, args, __VA_ARGS__) |
| 76 | +#define __MAP_ARGS6(x, args, t, n, ...) (t) args[x - 6], __MAP_ARGS5(x, args, __VA_ARGS__) |
| 77 | +#define __MAP_ARGS(x, args, ...) __MAP_ARGS##x((x), (args), __VA_ARGS__) |
78 | 78 |
|
79 | 79 | /** |
80 | 80 | * Syscall functions declaration and definitions helper. |
|
88 | 88 | * arguments define like a normal function. That function is automatically |
89 | 89 | * called by __sys_SYCALL_NAME with the correct argument number and cast. |
90 | 90 | */ |
91 | | -#define SYSCALL_DECLARE(name,...) \ |
| 91 | +#define SYSCALL_DECLARE(name, ...) \ |
92 | 92 | long __sys_##name(syscall_args_t *args); \ |
93 | 93 | inline long do_##name(__VA_ARGS__); |
94 | 94 |
|
95 | | -#define SYSCALL_DEFINE0(name) \ |
96 | | - long __sys_##name(syscall_args_t *unused) { return do_##name(); } \ |
| 95 | +#define SYSCALL_DEFINE0(name) \ |
| 96 | + long __sys_##name(syscall_args_t *unused) \ |
| 97 | + { \ |
| 98 | + return do_##name(); \ |
| 99 | + } \ |
97 | 100 | inline long do_##name(void) |
98 | | -#define SYSCALL_DEFINE1(...) __SYSCALL_DEFINEx(1,__VA_ARGS__) |
99 | | -#define SYSCALL_DEFINE2(...) __SYSCALL_DEFINEx(2,__VA_ARGS__) |
100 | | -#define SYSCALL_DEFINE3(...) __SYSCALL_DEFINEx(3,__VA_ARGS__) |
101 | | -#define SYSCALL_DEFINE4(...) __SYSCALL_DEFINEx(4,__VA_ARGS__) |
102 | | -#define SYSCALL_DEFINE5(...) __SYSCALL_DEFINEx(5,__VA_ARGS__) |
103 | | -#define SYSCALL_DEFINE6(...) __SYSCALL_DEFINEx(6,__VA_ARGS__) |
104 | | - |
105 | | -#define __SYSCALL_DEFINEx(x,name,...) \ |
106 | | - long __sys_##name(syscall_args_t *args) \ |
107 | | - { \ |
108 | | - return do_##name(__MAP_ARGS(x,args->args,__VA_ARGS__)); \ |
109 | | - } \ |
110 | | - inline long do_##name(__MAP(x,__M_DECL,__VA_ARGS__)) |
| 101 | +#define SYSCALL_DEFINE1(...) __SYSCALL_DEFINEx(1, __VA_ARGS__) |
| 102 | +#define SYSCALL_DEFINE2(...) __SYSCALL_DEFINEx(2, __VA_ARGS__) |
| 103 | +#define SYSCALL_DEFINE3(...) __SYSCALL_DEFINEx(3, __VA_ARGS__) |
| 104 | +#define SYSCALL_DEFINE4(...) __SYSCALL_DEFINEx(4, __VA_ARGS__) |
| 105 | +#define SYSCALL_DEFINE5(...) __SYSCALL_DEFINEx(5, __VA_ARGS__) |
| 106 | +#define SYSCALL_DEFINE6(...) __SYSCALL_DEFINEx(6, __VA_ARGS__) |
| 107 | + |
| 108 | +#define __SYSCALL_DEFINEx(x, name, ...) \ |
| 109 | + long __sys_##name(syscall_args_t *args) \ |
| 110 | + { \ |
| 111 | + return do_##name(__MAP_ARGS(x, args->args, __VA_ARGS__)); \ |
| 112 | + } \ |
| 113 | + inline long do_##name(__MAP(x, __M_DECL, __VA_ARGS__)) |
111 | 114 |
|
112 | 115 | typedef struct { |
113 | 116 | unsigned long args[6]; |
|
0 commit comments