]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/vax/bits/syscalls.h
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / vax / bits / syscalls.h
1 #ifndef _BITS_SYSCALLS_H
2 #define _BITS_SYSCALLS_H
3 #ifndef _SYSCALL_H
4 # error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
5 #endif
6
7 #ifndef __ASSEMBLER__
8
9 #include <errno.h>
10
11 #define SYS_ify(syscall_name)  (__NR_##syscall_name)
12
13 #undef _syscall_return
14 #define _syscall_return(type)                                                   \
15         do {                                                                    \
16                 if ((unsigned long) (_sc_ret) >= (unsigned long) (-125)) {      \
17                         __set_errno(-_sc_ret);                                  \
18                         _sc_ret = -1;                                           \
19                 }                                                               \
20                                                                                 \
21                 return (type) (_sc_ret);                                        \
22         } while (0)
23
24 #define _syscall_clobbers               \
25         "r1",  "r2",  "r3",  "r4",      \
26         "r5",  "r6",  "r7",  "r8",      \
27         "r9", "r10", "r11"
28
29 #ifdef _syscall0
30 #       undef _syscall0
31 #endif
32 #define _syscall0(type, name)                                           \
33 type name (void)                                                        \
34 {                                                                       \
35         register long _sc_0 __asm__("r0") = SYS_ify (name);             \
36         long _sc_ret;                                                   \
37                                                                         \
38         __asm__ __volatile__ (                                          \
39         "       pushl   %%ap            \n"                             \
40         "       pushl   $0x0            \n"                             \
41         "       movl    %%sp, %%ap      \n"                             \
42         "       chmk    %%r0            \n"                             \
43         "       addl2   $4, %%sp        \n"                             \
44         "       movl    (%%sp)+, %%ap   \n"                             \
45         : "=r" (_sc_0)                                                  \
46         : "0" (_sc_0)                                                   \
47         : _syscall_clobbers);                                           \
48                                                                         \
49         _sc_ret = _sc_0;                                                \
50         _syscall_return (type);                                         \
51 }
52
53 #ifdef _syscall1
54 #       undef _syscall1
55 #endif
56 #define _syscall1(type, name, type1, arg1)                              \
57 type name (type1 arg1)                                                  \
58 {                                                                       \
59         register long _sc_0 __asm__("r0") = SYS_ify (name);             \
60         long _sc_ret;                                                   \
61                                                                         \
62         __asm__ __volatile__ (                                          \
63         "       pushl   %%ap            \n"                             \
64         "       pushl   %2              \n"                             \
65         "       pushl   $0x1            \n"                             \
66         "       movl    %%sp, %%ap      \n"                             \
67         "       chmk    %%r0            \n"                             \
68         "       addl2   $8, %%sp        \n"                             \
69         "       movl    (%%sp)+, %%ap   \n"                             \
70         : "=r" (_sc_0)                                                  \
71         : "0" (_sc_0),                                                  \
72           "m" (arg1)                                                    \
73         : _syscall_clobbers);                                           \
74                                                                         \
75         _sc_ret = _sc_0;                                                \
76         _syscall_return (type);                                         \
77 }
78
79 #ifdef _syscall2
80 #       undef _syscall2
81 #endif
82 #define _syscall2(type, name, type1, arg1, type2, arg2)                 \
83 type name (type1 arg1,                                                  \
84            type2 arg2)                                                  \
85 {                                                                       \
86         register long _sc_0 __asm__("r0") = SYS_ify (name);             \
87         long _sc_ret;                                                   \
88                                                                         \
89         __asm__ __volatile__ (                                          \
90         "       pushl   %%ap            \n"                             \
91         "       pushl   %3              \n"                             \
92         "       pushl   %2              \n"                             \
93         "       pushl   $0x2            \n"                             \
94         "       movl    %%sp, %%ap      \n"                             \
95         "       chmk    %%r0            \n"                             \
96         "       addl2   $12, %%sp       \n"                             \
97         "       movl    (%%sp)+, %%ap   \n"                             \
98         : "=r" (_sc_0)                                                  \
99         : "0" (_sc_0),                                                  \
100           "m" (arg1),                                                   \
101           "m" (arg2)                                                    \
102         : _syscall_clobbers);                                           \
103                                                                         \
104         _sc_ret = _sc_0;                                                \
105         _syscall_return (type);                                         \
106 }
107
108 #ifdef _syscall3
109 #       undef _syscall3
110 #endif
111 #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3)    \
112 type name (type1 arg1,                                                  \
113            type2 arg2,                                                  \
114            type3 arg3)                                                  \
115 {                                                                       \
116         register long _sc_0 __asm__("r0") = SYS_ify (name);             \
117         long _sc_ret;                                                   \
118                                                                         \
119         __asm__ __volatile__ (                                          \
120         "       pushl   %%ap            \n"                             \
121         "       pushl   %4              \n"                             \
122         "       pushl   %3              \n"                             \
123         "       pushl   %2              \n"                             \
124         "       pushl   $0x3            \n"                             \
125         "       movl    %%sp, %%ap      \n"                             \
126         "       chmk    %%r0            \n"                             \
127         "       addl2   $16, %%sp       \n"                             \
128         "       movl    (%%sp)+, %%ap   \n"                             \
129         : "=r" (_sc_0)                                                  \
130         : "0" (_sc_0),                                                  \
131           "m" (arg1),                                                   \
132           "m" (arg2),                                                   \
133           "m" (arg3)                                                    \
134         : _syscall_clobbers);                                           \
135                                                                         \
136         _sc_ret = _sc_0;                                                \
137         _syscall_return (type);                                         \
138 }
139
140 #ifdef _syscall4
141 #       undef _syscall4
142 #endif
143 #define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3,    \
144                 type4, arg4)                                            \
145 type name (type1 arg1,                                                  \
146            type2 arg2,                                                  \
147            type3 arg3,                                                  \
148            type4 arg4)                                                  \
149 {                                                                       \
150         register long _sc_0 __asm__("r0") = SYS_ify (name);             \
151         long _sc_ret;                                                   \
152                                                                         \
153         __asm__ __volatile__ (                                          \
154         "       pushl   %%ap            \n"                             \
155         "       pushl   %5              \n"                             \
156         "       pushl   %4              \n"                             \
157         "       pushl   %3              \n"                             \
158         "       pushl   %2              \n"                             \
159         "       pushl   $0x4            \n"                             \
160         "       movl    %%sp, %%ap      \n"                             \
161         "       chmk    %%r0            \n"                             \
162         "       addl2   $20, %%sp       \n"                             \
163         "       movl    (%%sp)+, %%ap   \n"                             \
164         : "=r" (_sc_0)                                                  \
165         : "0" (_sc_0),                                                  \
166           "m" (arg1),                                                   \
167           "m" (arg2),                                                   \
168           "m" (arg3),                                                   \
169           "m" (arg4)                                                    \
170         : _syscall_clobbers);                                           \
171                                                                         \
172         _sc_ret = _sc_0;                                                \
173         _syscall_return (type);                                         \
174 }
175
176 #ifdef _syscall5
177 #       undef _syscall5
178 #endif
179 #define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3,    \
180                 type4, arg4, type5, arg5)                               \
181 type name (type1 arg1,                                                  \
182            type2 arg2,                                                  \
183            type3 arg3,                                                  \
184            type4 arg4,                                                  \
185            type5 arg5)                                                  \
186 {                                                                       \
187         register long _sc_0 __asm__("r0") = SYS_ify (name);             \
188         long _sc_ret;                                                   \
189                                                                         \
190         __asm__ __volatile__ (                                          \
191         "       pushl   %%ap            \n"                             \
192         "       pushl   %6              \n"                             \
193         "       pushl   %5              \n"                             \
194         "       pushl   %4              \n"                             \
195         "       pushl   %3              \n"                             \
196         "       pushl   %2              \n"                             \
197         "       pushl   $0x5            \n"                             \
198         "       movl    %%sp, %%ap      \n"                             \
199         "       chmk    %%r0            \n"                             \
200         "       addl2   $24, %%sp       \n"                             \
201         "       movl    (%%sp)+, %%ap   \n"                             \
202         : "=r" (_sc_0)                                                  \
203         : "0" (_sc_0),                                                  \
204           "m" (arg1),                                                   \
205           "m" (arg2),                                                   \
206           "m" (arg3),                                                   \
207           "m" (arg4),                                                   \
208           "m" (arg5)                                                    \
209         : _syscall_clobbers);                                           \
210                                                                         \
211         _sc_ret = _sc_0;                                                \
212         _syscall_return (type);                                         \
213 }
214
215 #ifdef _syscall6
216 #       undef _syscall6
217 #endif
218 #define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3,    \
219                 type4, arg4, type5, arg5, type6, arg6)                  \
220 type name (type1 arg1,                                                  \
221            type2 arg2,                                                  \
222            type3 arg3,                                                  \
223            type4 arg4,                                                  \
224            type5 arg5,                                                  \
225            type6 arg6)                                                  \
226 {                                                                       \
227         register long _sc_0 __asm__("r0") = SYS_ify (name);             \
228         long _sc_ret;                                                   \
229                                                                         \
230         __asm__ __volatile__ (                                          \
231         "       pushl   %%ap            \n"                             \
232         "       pushl   %7              \n"                             \
233         "       pushl   %6              \n"                             \
234         "       pushl   %5              \n"                             \
235         "       pushl   %4              \n"                             \
236         "       pushl   %3              \n"                             \
237         "       pushl   %2              \n"                             \
238         "       pushl   $0x6            \n"                             \
239         "       movl    %%sp, %%ap      \n"                             \
240         "       chmk    %%r0            \n"                             \
241         "       addl2   $28, %%sp       \n"                             \
242         "       movl    (%%sp)+, %%ap   \n"                             \
243         : "=r" (_sc_0)                                                  \
244         : "0" (_sc_0),                                                  \
245           "m" (arg1),                                                   \
246           "m" (arg2),                                                   \
247           "m" (arg3),                                                   \
248           "m" (arg4),                                                   \
249           "m" (arg5),                                                   \
250           "m" (arg6)                                                    \
251         : _syscall_clobbers);                                           \
252                                                                         \
253         _sc_ret = _sc_0;                                                \
254         _syscall_return (type);                                         \
255 }
256
257 #endif /* __ASSEMBLER__ */
258 #endif /* _BITS_SYSCALLS_H */