summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/vax/bits/syscalls.h
blob: f80b40539ece4c5b73d4d049c28a75556524a661 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H
#ifndef _SYSCALL_H
# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
#endif

/* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
 * header files.  It also defines the traditional `SYS_<name>' macros for older
 * programs.  */
#include <bits/sysnum.h>

#ifndef __ASSEMBLER__

#include <errno.h>

#define SYS_ify(syscall_name)  (__NR_##syscall_name)

#undef _syscall_return
#define _syscall_return(type)							\
	do {									\
		if ((unsigned long) (_sc_ret) >= (unsigned long) (-125)) {	\
			__set_errno(-_sc_ret);					\
			_sc_ret = -1;						\
		}								\
										\
		return (type) (_sc_ret);					\
	} while (0)

#define _syscall_clobbers		\
	"r1",  "r2",  "r3",  "r4",	\
	"r5",  "r6",  "r7",  "r8",	\
	"r9", "r10", "r11"

#ifdef _syscall0
#	undef _syscall0
#endif
#define _syscall0(type, name)						\
type name (void)							\
{									\
	register long _sc_0 __asm__("r0") = SYS_ify (name);		\
	long _sc_ret;							\
									\
	__asm__ __volatile__ (						\
	"	pushl	%%ap		\n"				\
	"	pushl	$0x0		\n"				\
	"	movl	%%sp, %%ap	\n"				\
	"	chmk	%%r0		\n"				\
	"	addl2	$4, %%sp	\n"				\
	"	movl	(%%sp)+, %%ap	\n"				\
	: "=r" (_sc_0)							\
	: "0" (_sc_0)							\
	: _syscall_clobbers);						\
									\
	_sc_ret = _sc_0;						\
	_syscall_return (type);						\
}

#ifdef _syscall1
#	undef _syscall1
#endif
#define _syscall1(type, name, type1, arg1)				\
type name (type1 arg1)							\
{									\
	register long _sc_0 __asm__("r0") = SYS_ify (name);		\
	long _sc_ret;							\
									\
	__asm__ __volatile__ (						\
	"	pushl	%%ap		\n"				\
	"	pushl	%2		\n"				\
	"	pushl	$0x1		\n"				\
	"	movl	%%sp, %%ap	\n"				\
	"	chmk	%%r0		\n"				\
	"	addl2	$8, %%sp	\n"				\
	"	movl	(%%sp)+, %%ap	\n"				\
	: "=r" (_sc_0)							\
	: "0" (_sc_0),							\
	  "m" (arg1)							\
	: _syscall_clobbers);						\
									\
	_sc_ret = _sc_0;						\
	_syscall_return (type);						\
}

#ifdef _syscall2
#	undef _syscall2
#endif
#define _syscall2(type, name, type1, arg1, type2, arg2)			\
type name (type1 arg1,							\
	   type2 arg2)							\
{									\
	register long _sc_0 __asm__("r0") = SYS_ify (name);		\
	long _sc_ret;							\
									\
	__asm__ __volatile__ (						\
	"	pushl	%%ap		\n"				\
	"	pushl	%3		\n"				\
	"	pushl	%2		\n"				\
	"	pushl	$0x2		\n"				\
	"	movl	%%sp, %%ap	\n"				\
	"	chmk	%%r0		\n"				\
	"	addl2	$12, %%sp	\n"				\
	"	movl	(%%sp)+, %%ap	\n"				\
	: "=r" (_sc_0)							\
	: "0" (_sc_0),							\
	  "m" (arg1),							\
	  "m" (arg2)							\
	: _syscall_clobbers);						\
									\
	_sc_ret = _sc_0;						\
	_syscall_return (type);						\
}

#ifdef _syscall3
#	undef _syscall3
#endif
#define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3)	\
type name (type1 arg1,							\
	   type2 arg2,							\
	   type3 arg3)							\
{									\
	register long _sc_0 __asm__("r0") = SYS_ify (name);		\
	long _sc_ret;							\
									\
	__asm__ __volatile__ (						\
	"	pushl	%%ap		\n"				\
	"	pushl	%4		\n"				\
	"	pushl	%3		\n"				\
	"	pushl	%2		\n"				\
	"	pushl	$0x3		\n"				\
	"	movl	%%sp, %%ap	\n"				\
	"	chmk	%%r0		\n"				\
	"	addl2	$16, %%sp	\n"				\
	"	movl	(%%sp)+, %%ap	\n"				\
	: "=r" (_sc_0)							\
	: "0" (_sc_0),							\
	  "m" (arg1),							\
	  "m" (arg2),							\
	  "m" (arg3)							\
	: _syscall_clobbers);						\
									\
	_sc_ret = _sc_0;						\
	_syscall_return (type);						\
}

#ifdef _syscall4
#	undef _syscall4
#endif
#define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3,	\
		type4, arg4)						\
type name (type1 arg1,							\
	   type2 arg2,							\
	   type3 arg3,							\
	   type4 arg4)							\
{									\
	register long _sc_0 __asm__("r0") = SYS_ify (name);		\
	long _sc_ret;							\
									\
	__asm__ __volatile__ (						\
	"	pushl	%%ap		\n"				\
	"	pushl	%5		\n"				\
	"	pushl	%4		\n"				\
	"	pushl	%3		\n"				\
	"	pushl	%2		\n"				\
	"	pushl	$0x4		\n"				\
	"	movl	%%sp, %%ap	\n"				\
	"	chmk	%%r0		\n"				\
	"	addl2	$20, %%sp	\n"				\
	"	movl	(%%sp)+, %%ap	\n"				\
	: "=r" (_sc_0)							\
	: "0" (_sc_0),							\
	  "m" (arg1),							\
	  "m" (arg2),							\
	  "m" (arg3),							\
	  "m" (arg4)							\
	: _syscall_clobbers);						\
									\
	_sc_ret = _sc_0;						\
	_syscall_return (type);						\
}

#ifdef _syscall5
#	undef _syscall5
#endif
#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3,	\
		type4, arg4, type5, arg5)				\
type name (type1 arg1,							\
	   type2 arg2,							\
	   type3 arg3,							\
	   type4 arg4,							\
	   type5 arg5)							\
{									\
	register long _sc_0 __asm__("r0") = SYS_ify (name);		\
	long _sc_ret;							\
									\
	__asm__ __volatile__ (						\
	"	pushl	%%ap		\n"				\
	"	pushl	%6		\n"				\
	"	pushl	%5		\n"				\
	"	pushl	%4		\n"				\
	"	pushl	%3		\n"				\
	"	pushl	%2		\n"				\
	"	pushl	$0x5		\n"				\
	"	movl	%%sp, %%ap	\n"				\
	"	chmk	%%r0		\n"				\
	"	addl2	$24, %%sp	\n"				\
	"	movl	(%%sp)+, %%ap	\n"				\
	: "=r" (_sc_0)							\
	: "0" (_sc_0),							\
	  "m" (arg1),							\
	  "m" (arg2),							\
	  "m" (arg3),							\
	  "m" (arg4),							\
	  "m" (arg5)							\
	: _syscall_clobbers);						\
									\
	_sc_ret = _sc_0;						\
	_syscall_return (type);						\
}

#ifdef _syscall6
#	undef _syscall6
#endif
#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3,	\
		type4, arg4, type5, arg5, type6, arg6)			\
type name (type1 arg1,							\
	   type2 arg2,							\
	   type3 arg3,							\
	   type4 arg4,							\
	   type5 arg5,							\
	   type6 arg6)							\
{									\
	register long _sc_0 __asm__("r0") = SYS_ify (name);		\
	long _sc_ret;							\
									\
	__asm__ __volatile__ (						\
	"	pushl	%%ap		\n"				\
	"	pushl	%7		\n"				\
	"	pushl	%6		\n"				\
	"	pushl	%5		\n"				\
	"	pushl	%4		\n"				\
	"	pushl	%3		\n"				\
	"	pushl	%2		\n"				\
	"	pushl	$0x6		\n"				\
	"	movl	%%sp, %%ap	\n"				\
	"	chmk	%%r0		\n"				\
	"	addl2	$28, %%sp	\n"				\
	"	movl	(%%sp)+, %%ap	\n"				\
	: "=r" (_sc_0)							\
	: "0" (_sc_0),							\
	  "m" (arg1),							\
	  "m" (arg2),							\
	  "m" (arg3),							\
	  "m" (arg4),							\
	  "m" (arg5),							\
	  "m" (arg6)							\
	: _syscall_clobbers);						\
									\
	_sc_ret = _sc_0;						\
	_syscall_return (type);						\
}

#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */