-
Notifications
You must be signed in to change notification settings - Fork 13
/
syscall.c
63 lines (56 loc) · 2.52 KB
/
syscall.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "syscall.h"
#include "usyscall.h"
#include <unistd.h>
#include <stdlib.h>
typedef unsigned long (*sys_call_t)(
unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4,
void *rest);
#define SC_TRAMPOLINE0(ret, name) \
static unsigned long sys_tr_ ## name(unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, void *rest) { \
return (ret) sys_ ## name(); \
}
#define SC_TRAMPOLINE1(ret, name, type1, name1) \
static unsigned long sys_tr_ ## name(unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, void *rest) { \
return (ret) sys_ ## name((type1)arg1); \
}
#define SC_TRAMPOLINE2(ret, name, type1, name1, type2, name2) \
static unsigned long sys_tr_ ## name(unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, void *rest) { \
return (ret) sys_ ## name((type1)arg1, (type2)arg2); \
}
#define SC_TRAMPOLINE3(ret, name, type1, name1, type2, name2, type3, name3) \
static unsigned long sys_tr_ ## name(unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, void *rest) { \
return (ret) sys_ ## name((type1)arg1, (type2)arg2, (type3)arg3); \
}
#define SC_TRAMPOLINE4(ret, name, type1, name1, type2, name2, type3, name3, type4, name4) \
static unsigned long sys_tr_ ## name(unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, void *rest) { \
return (ret) sys_ ## name((type1)arg1, (type2)arg2, (type3)arg3, (type4)arg4); \
}
#define SC_TRAMPOLINE5(ret, name, type1, name1, type2, name2, type3, name3, type4, name4, type5, name5) \
static unsigned long sys_tr_ ## name(unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4, void *rest) { \
return (ret) sys_ ## name((type1)arg1, (type2)arg2, (type3)arg3, (type4)arg4, rest); \
}
#define SC_TRAMPOLINE(name, ret, n, ...) \
SC_TRAMPOLINE ## n (ret, name, ## __VA_ARGS__)
SYSCALL_X(SC_TRAMPOLINE)
#undef SC_TRAMPOLINE0
#undef SC_TRAMPOLINE1
#undef SC_TRAMPOLINE2
#undef SC_TRAMPOLINE3
#undef SC_TRAMPOLINE4
#undef SC_TRAMPOLINE5
#undef SC_TRAMPOLINE
#define SC_TABLE_ITEM(name, ...) sys_tr_## name,
static const sys_call_t sys_table[] = {
SYSCALL_X(SC_TABLE_ITEM)
};
#undef SC_TABLE_ITEM
unsigned long syscall_do(int sysnum,
unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4,
void *rest) {
return sys_table[sysnum](arg1, arg2, arg3, arg4, rest);
}
int sys_fork(void) {
abort();
}