1 /* Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Brendan Kehoe (brendan@zen.org).
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <sysdeps/unix/sysdep.h>
25 # include <alpha/regdef.h>
31 #define __LABEL(x) x##:
33 #define __LABEL(x) x/**/:
36 #define LEAF(name, framesize) \
41 .frame sp, framesize, ra
50 /* Mark the end of function SYM. */
52 #define END(sym) .end sym
54 /* Note that PSEUDO/PSEUDO_END use label number 1996---do not use a
55 label of that number between those two macros! */
58 #define PSEUDO(name, syscall_name, args) \
67 jsr AT,(AT),_mcount; \
70 ldiq v0, SYS_ify(syscall_name); \
72 call_pal PAL_callsys; \
77 #define PSEUDO(name, syscall_name, args) \
84 ldiq v0, SYS_ify(syscall_name); \
86 call_pal PAL_callsys; \
94 #define PSEUDO_END(sym) \
96 jmp zero, __syscall_error; \
99 #define PSEUDO_END(sym) \
103 jmp zero, __syscall_error; \
110 #define MOVE(x,y) mov x,y
112 #else /* !ASSEMBLER */
114 /* Define a macro which expands inline into the wrapper code for a
117 #undef INLINE_SYSCALL
118 #define INLINE_SYSCALL(name, nr, args...) INLINE_SYSCALL1(name, nr, args)
120 #define INLINE_SYSCALL1(name, nr, args...) \
122 long _sc_ret, _sc_err; \
123 inline_syscall##nr(name, args); \
126 __set_errno (_sc_ret); \
132 #define inline_syscall_clobbers \
133 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
134 "$22", "$23", "$24", "$25", "$27", "$28"
136 /* It is moderately important optimization-wise to limit the lifetime
137 of the hard-register variables as much as possible. Thus we copy
138 in/out as close to the asm as possible. */
140 #define inline_syscall0(name) \
142 register long _sc_0 __asm__("$0"); \
143 register long _sc_19 __asm__("$19"); \
145 _sc_0 = __NR_##name; \
146 __asm__("callsys # %0 %1 <= %2" \
147 : "=r"(_sc_0), "=r"(_sc_19) \
149 : inline_syscall_clobbers); \
150 _sc_ret = _sc_0, _sc_err = _sc_19; \
153 #define inline_syscall1(name,arg1) \
155 register long _sc_0 __asm__("$0"); \
156 register long _sc_16 __asm__("$16"); \
157 register long _sc_19 __asm__("$19"); \
159 _sc_0 = __NR_##name; \
160 _sc_16 = (long) (arg1); \
161 __asm__("callsys # %0 %1 <= %2 %3" \
162 : "=r"(_sc_0), "=r"(_sc_19) \
163 : "0"(_sc_0), "r"(_sc_16) \
164 : inline_syscall_clobbers); \
165 _sc_ret = _sc_0, _sc_err = _sc_19; \
168 #define inline_syscall2(name,arg1,arg2) \
170 register long _sc_0 __asm__("$0"); \
171 register long _sc_16 __asm__("$16"); \
172 register long _sc_17 __asm__("$17"); \
173 register long _sc_19 __asm__("$19"); \
175 _sc_0 = __NR_##name; \
176 _sc_16 = (long) (arg1); \
177 _sc_17 = (long) (arg2); \
178 __asm__("callsys # %0 %1 <= %2 %3 %4" \
179 : "=r"(_sc_0), "=r"(_sc_19) \
180 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17) \
181 : inline_syscall_clobbers); \
182 _sc_ret = _sc_0, _sc_err = _sc_19; \
185 #define inline_syscall3(name,arg1,arg2,arg3) \
187 register long _sc_0 __asm__("$0"); \
188 register long _sc_16 __asm__("$16"); \
189 register long _sc_17 __asm__("$17"); \
190 register long _sc_18 __asm__("$18"); \
191 register long _sc_19 __asm__("$19"); \
193 _sc_0 = __NR_##name; \
194 _sc_16 = (long) (arg1); \
195 _sc_17 = (long) (arg2); \
196 _sc_18 = (long) (arg3); \
197 __asm__("callsys # %0 %1 <= %2 %3 %4 %5" \
198 : "=r"(_sc_0), "=r"(_sc_19) \
199 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
201 : inline_syscall_clobbers); \
202 _sc_ret = _sc_0, _sc_err = _sc_19; \
205 #define inline_syscall4(name,arg1,arg2,arg3,arg4) \
207 register long _sc_0 __asm__("$0"); \
208 register long _sc_16 __asm__("$16"); \
209 register long _sc_17 __asm__("$17"); \
210 register long _sc_18 __asm__("$18"); \
211 register long _sc_19 __asm__("$19"); \
213 _sc_0 = __NR_##name; \
214 _sc_16 = (long) (arg1); \
215 _sc_17 = (long) (arg2); \
216 _sc_18 = (long) (arg3); \
217 _sc_19 = (long) (arg4); \
218 __asm__("callsys # %0 %1 <= %2 %3 %4 %5 %6" \
219 : "=r"(_sc_0), "=r"(_sc_19) \
220 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
221 "r"(_sc_18), "1"(_sc_19) \
222 : inline_syscall_clobbers); \
223 _sc_ret = _sc_0, _sc_err = _sc_19; \
226 #define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
228 register long _sc_0 __asm__("$0"); \
229 register long _sc_16 __asm__("$16"); \
230 register long _sc_17 __asm__("$17"); \
231 register long _sc_18 __asm__("$18"); \
232 register long _sc_19 __asm__("$19"); \
233 register long _sc_20 __asm__("$20"); \
235 _sc_0 = __NR_##name; \
236 _sc_16 = (long) (arg1); \
237 _sc_17 = (long) (arg2); \
238 _sc_18 = (long) (arg3); \
239 _sc_19 = (long) (arg4); \
240 _sc_20 = (long) (arg5); \
241 __asm__("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \
242 : "=r"(_sc_0), "=r"(_sc_19) \
243 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
244 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20) \
245 : inline_syscall_clobbers); \
246 _sc_ret = _sc_0, _sc_err = _sc_19; \
249 #define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
251 register long _sc_0 __asm__("$0"); \
252 register long _sc_16 __asm__("$16"); \
253 register long _sc_17 __asm__("$17"); \
254 register long _sc_18 __asm__("$18"); \
255 register long _sc_19 __asm__("$19"); \
256 register long _sc_20 __asm__("$20"); \
257 register long _sc_21 __asm__("$21"); \
259 _sc_0 = __NR_##name; \
260 _sc_16 = (long) (arg1); \
261 _sc_17 = (long) (arg2); \
262 _sc_18 = (long) (arg3); \
263 _sc_19 = (long) (arg4); \
264 _sc_20 = (long) (arg5); \
265 _sc_21 = (long) (arg6); \
266 __asm__("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \
267 : "=r"(_sc_0), "=r"(_sc_19) \
268 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
269 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20), \
271 : inline_syscall_clobbers); \
272 _sc_ret = _sc_0, _sc_err = _sc_19; \
275 #endif /* ASSEMBLER */