summaryrefslogtreecommitdiffstats
path: root/include/asm-mips/unistd.h
blob: 0776f3fdb208fc096c2db457f72393e3157e0016 (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef _ASM_MIPS_UNISTD_H_
#define _ASM_MIPS_UNISTD_H_

/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
#define _syscall0(type,name) \
type name(void) \
{ \
register long __res __asm__ ("$2"); \
__asm__ volatile (".set\tnoat\n\t" \
                  "li\t$1,%1\n\t" \
                  ".set\tat\n\t" \
                  "syscall\n\t" \
                  : "=d" (__res) \
                  : "i" (__NR_##name) \
                  : "$1"); \
if (__res >= 0) \
	return (type) __res; \
errno = -__res; \
return -1; \
}

#define _syscall1(type,name,atype,a) \
type name(atype a) \
{ \
register long __res __asm__ ("$2"); \
__asm__ volatile ("move\t$2,%2\n\t" \
                  ".set\tnoat\n\t" \
                  "li\t$1,%1\n\t" \
                  ".set\tat\n\t" \
                  "syscall" \
                  : "=d" (__res) \
                  : "i" (__NR_##name),"d" ((long)(a)) \
                  : "$1","$2"); \
if (__res >= 0) \
	return (type) __res; \
errno = -__res; \
return -1; \
}

#define _syscall2(type,name,atype,a,btype,b) \
type name(atype a,btype b) \
{ \
register long __res __asm__ ("$2"); \
__asm__ volatile ("move\t$2,%2\n\t" \
                  "move\t$3,%3\n\t" \
                  ".set\tnoat\n\t" \
                  "li\t$1,%1\n\t" \
                  ".set\tat\n\t" \
                  "syscall" \
                  : "=d" (__res) \
                  : "i" (__NR_##name),"d" ((long)(a)), \
                                      "d" ((long)(b))); \
                  : "$1","$2","$3"); \
if (__res >= 0) \
	return (type) __res; \
errno = -__res; \
return -1; \
}

#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
type name (atype a, btype b, ctype c) \
{ \
register long __res __asm__ ("$2"); \
__asm__ volatile ("move\t$2,%2\n\t" \
                  "move\t$3,%3\n\t" \
                  "move\t$4,%4\n\t" \
                  ".set\tnoat\n\t" \
                  "li\t$1,%1\n\t" \
                  ".set\tat\n\t" \
                  "syscall" \
                  : "=d" (__res) \
                  : "i" (__NR_##name),"d" ((long)(a)), \
                                      "d" ((long)(b)), \
                                      "d" ((long)(c)) \
                  : "$1","$2","$3","$4"); \
if (__res>=0) \
	return (type) __res; \
errno=-__res; \
return -1; \
}

#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
type name (atype a, btype b, ctype c, dtype d) \
{ \
register long __res __asm__ ("$2"); \
__asm__ volatile (".set\tnoat\n\t" \
                  "move\t$2,%2\n\t" \
                  "move\t$3,%3\n\t" \
                  "move\t$4,%4\n\t" \
                  "move\t$5,%5\n\t" \
                  ".set\tnoat\n\t" \
                  "li\t$1,%1\n\t" \
                  ".set\tat\n\t" \
                  "syscall" \
                  : "=d" (__res) \
                  : "i" (__NR_##name),"d" ((long)(a)), \
                                      "d" ((long)(b)), \
                                      "d" ((long)(c)), \
                                      "d" ((long)(d)) \
                  : "$1","$2","$3","$4","$5"); \
if (__res>=0) \
	return (type) __res; \
errno=-__res; \
return -1; \
}

#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
type name (atype a,btype b,ctype c,dtype d,etype e) \
{ \
register long __res __asm__ ("$2"); \
__asm__ volatile (".set\tnoat\n\t" \
                  "move\t$2,%2\n\t" \
                  "move\t$3,%3\n\t" \
                  "move\t$4,%4\n\t" \
                  "move\t$5,%5\n\t" \
                  "move\t$6,%6\n\t" \
                  ".set\tnoat\n\t" \
                  "li\t$1,%1\n\t" \
                  ".set\tat\n\t" \
                  "syscall" \
                  : "=d" (__res) \
                  : "i" (__NR_##name),"d" ((long)(a)), \
                                      "d" ((long)(b)), \
                                      "d" ((long)(c)), \
                                      "d" ((long)(d)), \
                                      "d" ((long)(e)) \
                  : "$1","$2","$3","$4","$5","$6"); \
if (__res>=0) \
	return (type) __res; \
errno=-__res; \
return -1; \
}

#endif /* _ASM_MIPS_UNISTD_H_ */