]>
sourceware.org Git - glibc.git/blob - sysdeps/unix/sysv/linux/m68k/sysdep.h
1 /* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2010
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Written by Andreas Schwab, <schwab@issan.informatik.uni-dortmund.de>,
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #ifndef _LINUX_M68K_SYSDEP_H
23 #define _LINUX_M68K_SYSDEP_H 1
25 #include <sysdeps/unix/sysdep.h>
26 #include <sysdeps/m68k/sysdep.h>
29 /* Defines RTLD_PRIVATE_ERRNO. */
30 #include <dl-sysdep.h>
32 /* For Linux we can use the system call table in the header file
33 /usr/include/asm/unistd.h
34 of the kernel. But these symbols do not follow the SYS_* syntax
35 so we have to redefine the `SYS_ify' macro here. */
38 # define SYS_ify(syscall_name) __NR_##syscall_name
40 # define SYS_ify(syscall_name) __NR_/**/syscall_name
45 /* Linux uses a negative return value to indicate syscall errors, unlike
46 most Unices, which use the condition codes' carry flag.
48 Since version 2.1 the return value of a system call might be negative
49 even if the call succeeded. E.g., the `lseek' system call might return
50 a large offset. Therefore we must not anymore test for < 0, but test
51 for a real error by making sure the value in %d0 is a real error
52 number. Linus said he will make sure the no syscall returns a value
53 in -1 .. -4095 as a valid result so we can savely test with -4095. */
55 /* We don't want the label for the error handler to be visible in the symbol
56 table when we define it here. */
58 #define SYSCALL_ERROR_LABEL .Lsyscall_error
60 #define SYSCALL_ERROR_LABEL __syscall_error
64 #define PSEUDO(name, syscall_name, args) \
67 DO_CALL (syscall_name, args); \
69 jcc SYSCALL_ERROR_LABEL
72 #define PSEUDO_END(name) \
73 SYSCALL_ERROR_HANDLER; \
77 #define PSEUDO_NOERRNO(name, syscall_name, args) \
80 DO_CALL (syscall_name, args)
82 #undef PSEUDO_END_NOERRNO
83 #define PSEUDO_END_NOERRNO(name) \
86 #define ret_NOERRNO rts
88 /* The function has to return the error code. */
90 #define PSEUDO_ERRVAL(name, syscall_name, args) \
93 DO_CALL (syscall_name, args); \
96 #undef PSEUDO_END_ERRVAL
97 #define PSEUDO_END_ERRVAL(name) \
100 #define ret_ERRVAL rts
103 # if RTLD_PRIVATE_ERRNO
104 # define SYSCALL_ERROR_HANDLER \
105 SYSCALL_ERROR_LABEL: \
106 PCREL_OP (lea, rtld_errno, %a0, %a0); \
110 /* Copy return value to %a0 for syscalls that are declared to return \
111 a pointer (e.g., mmap). */ \
114 # else /* !RTLD_PRIVATE_ERRNO */
115 /* Store (- %d0) into errno through the GOT. */
116 # if defined _LIBC_REENTRANT
117 # define SYSCALL_ERROR_HANDLER \
118 SYSCALL_ERROR_LABEL: \
120 move.l %d0, -(%sp); \
121 jbsr __errno_location@PLTPC; \
122 move.l (%sp)+, (%a0); \
124 /* Copy return value to %a0 for syscalls that are declared to return \
125 a pointer (e.g., mmap). */ \
128 # else /* !_LIBC_REENTRANT */
129 # define SYSCALL_ERROR_HANDLER \
130 SYSCALL_ERROR_LABEL: \
131 move.l (errno@GOTPC, %pc), %a0; \
135 /* Copy return value to %a0 for syscalls that are declared to return \
136 a pointer (e.g., mmap). */ \
139 # endif /* _LIBC_REENTRANT */
140 # endif /* RTLD_PRIVATE_ERRNO */
142 # define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
145 /* Linux takes system call arguments in registers:
147 syscall number %d0 call-clobbered
148 arg 1 %d1 call-clobbered
153 arg 6 %a0 call-clobbered
155 The stack layout upon entering the function is:
165 (Of course a function with say 3 arguments does not have entries for
168 Separate move's are faster than movem, but need more space. Since
169 speed is more important, we don't use movem. Since %a0 and %a1 are
170 scratch registers, we can use them for saving as well. */
172 #define DO_CALL(syscall_name, args) \
173 move.l &SYS_ify(syscall_name), %d0; \
178 #define DOARGS_0 /* No arguments to frob. */
179 #define UNDOARGS_0 /* No arguments to unfrob. */
180 #define _DOARGS_0(n) /* No arguments to frob. */
182 #define DOARGS_1 _DOARGS_1 (4)
183 #define _DOARGS_1(n) move.l n(%sp), %d1; _DOARGS_0 (n)
184 #define UNDOARGS_1 UNDOARGS_0
186 #define DOARGS_2 _DOARGS_2 (8)
187 #define _DOARGS_2(n) move.l %d2, %a0; move.l n(%sp), %d2; _DOARGS_1 (n-4)
188 #define UNDOARGS_2 UNDOARGS_1; move.l %a0, %d2
190 #define DOARGS_3 _DOARGS_3 (12)
191 #define _DOARGS_3(n) move.l %d3, %a1; move.l n(%sp), %d3; _DOARGS_2 (n-4)
192 #define UNDOARGS_3 UNDOARGS_2; move.l %a1, %d3
194 #define DOARGS_4 _DOARGS_4 (16)
195 #define _DOARGS_4(n) move.l %d4, -(%sp); move.l n+4(%sp), %d4; _DOARGS_3 (n)
196 #define UNDOARGS_4 UNDOARGS_3; move.l (%sp)+, %d4
198 #define DOARGS_5 _DOARGS_5 (20)
199 #define _DOARGS_5(n) move.l %d5, -(%sp); move.l n+4(%sp), %d5; _DOARGS_4 (n)
200 #define UNDOARGS_5 UNDOARGS_4; move.l (%sp)+, %d5
202 #define DOARGS_6 _DOARGS_6 (24)
203 #define _DOARGS_6(n) _DOARGS_5 (n-4); move.l %a0, -(%sp); move.l n+12(%sp), %a0;
204 #define UNDOARGS_6 move.l (%sp)+, %a0; UNDOARGS_5
208 #if 0 /* Not used by Linux */
211 #define MOVE(x,y) movel x , y
214 #else /* not __ASSEMBLER__ */
216 /* Define a macro which expands into the inline wrapper code for a system
218 #undef INLINE_SYSCALL
219 #define INLINE_SYSCALL(name, nr, args...) \
220 ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
221 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
223 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
224 _sys_result = (unsigned int) -1; \
226 (int) _sys_result; })
228 #undef INTERNAL_SYSCALL_DECL
229 #define INTERNAL_SYSCALL_DECL(err) do { } while (0)
231 /* Define a macro which expands inline into the wrapper code for a system
232 call. This use is for internal calls that do not need to handle errors
233 normally. It will never touch errno. This returns just what the kernel
235 #undef INTERNAL_SYSCALL
236 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
237 ({ unsigned int _sys_result; \
239 /* Load argument values in temporary variables
240 to perform side effects like function calls
241 before the call used registers are set. */ \
242 LOAD_ARGS_##nr (args) \
244 register int _d0 asm ("%d0") = name; \
245 asm volatile ("trap #0" \
247 : "0" (_d0) ASM_ARGS_##nr \
251 (int) _sys_result; })
252 #define INTERNAL_SYSCALL(name, err, nr, args...) \
253 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
255 #undef INTERNAL_SYSCALL_ERROR_P
256 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
257 ((unsigned int) (val) >= -4095U)
259 #undef INTERNAL_SYSCALL_ERRNO
260 #define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
262 #define LOAD_ARGS_0()
265 #define LOAD_ARGS_1(a1) \
267 int __arg1 = (int) (a1);
268 #define LOAD_REGS_1 \
269 register int _d1 asm ("d1") = __arg1; \
271 #define ASM_ARGS_1 ASM_ARGS_0, "d" (_d1)
272 #define LOAD_ARGS_2(a1, a2) \
274 int __arg2 = (int) (a2);
275 #define LOAD_REGS_2 \
276 register int _d2 asm ("d2") = __arg2; \
278 #define ASM_ARGS_2 ASM_ARGS_1, "d" (_d2)
279 #define LOAD_ARGS_3(a1, a2, a3) \
280 LOAD_ARGS_2 (a1, a2) \
281 int __arg3 = (int) (a3);
282 #define LOAD_REGS_3 \
283 register int _d3 asm ("d3") = __arg3; \
285 #define ASM_ARGS_3 ASM_ARGS_2, "d" (_d3)
286 #define LOAD_ARGS_4(a1, a2, a3, a4) \
287 LOAD_ARGS_3 (a1, a2, a3) \
288 int __arg4 = (int) (a4);
289 #define LOAD_REGS_4 \
290 register int _d4 asm ("d4") = __arg4; \
292 #define ASM_ARGS_4 ASM_ARGS_3, "d" (_d4)
293 #define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
294 LOAD_ARGS_4 (a1, a2, a3, a4) \
295 int __arg5 = (int) (a5);
296 #define LOAD_REGS_5 \
297 register int _d5 asm ("d5") = __arg5; \
299 #define ASM_ARGS_5 ASM_ARGS_4, "d" (_d5)
300 #define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
301 LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
302 int __arg6 = (int) (a6);
303 #define LOAD_REGS_6 \
304 register int _a0 asm ("a0") = __arg6; \
306 #define ASM_ARGS_6 ASM_ARGS_5, "a" (_a0)
308 #endif /* not __ASSEMBLER__ */
310 /* Pointer mangling is not yet supported for M68K. */
311 #define PTR_MANGLE(var) (void) (var)
312 #define PTR_DEMANGLE(var) (void) (var)
314 #if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
315 /* M68K needs system-supplied DSO to access TLS helpers
316 even when statically linked. */
317 # define NEED_STATIC_SYSINFO_DSO 1
This page took 0.052102 seconds and 5 git commands to generate.