1 /* Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 /* Alan Modra <amodra@bigpond.net.au> rewrote the INLINE_SYSCALL macro */
22 #ifndef _LINUX_POWERPC_SYSDEP_H
23 #define _LINUX_POWERPC_SYSDEP_H 1
25 #include <sysdeps/unix/powerpc/sysdep.h>
27 /* Define __set_errno() for INLINE_SYSCALL macro below. */
32 /* Some systen calls got renamed over time, but retained the same semantics.
33 Handle them here so they can be catched by both C and assembler stubs in
38 # error "__NR_pread and __NR_pread64 both defined???"
40 # define __NR_pread __NR_pread64
45 # error "__NR_pwrite and __NR_pwrite64 both defined???"
47 # define __NR_pwrite __NR_pwrite64
50 /* For Linux we can use the system call table in the header file
51 /usr/include/asm/unistd.h
52 of the kernel. But these symbols do not follow the SYS_* syntax
53 so we have to redefine the `SYS_ify' macro here. */
56 # define SYS_ify(syscall_name) __NR_##syscall_name
58 # define SYS_ify(syscall_name) __NR_/**/syscall_name
63 /* This seems to always be the case on PPC. */
64 #define ALIGNARG(log2) log2
65 /* For ELF we need the `.type' directive to make shared libs work right. */
66 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
67 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
69 #endif /* __ASSEMBLER__ */
73 /* This version is for kernels that implement system calls that
74 behave like function calls as far as register saving. */
75 #define INLINE_SYSCALL(name, nr, args...) \
77 INTERNAL_SYSCALL_DECL (sc_err); \
78 long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
79 if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
81 __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
87 /* Define a macro which expands inline into the wrapper code for a system
88 call. This use is for internal calls that do not need to handle errors
89 normally. It will never touch errno. This returns just what the kernel
90 gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
91 the negation of the return value in the kernel gets reverted. */
93 #undef INTERNAL_SYSCALL
94 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
96 register long int r0 __asm__ ("r0"); \
97 register long int r3 __asm__ ("r3"); \
98 register long int r4 __asm__ ("r4"); \
99 register long int r5 __asm__ ("r5"); \
100 register long int r6 __asm__ ("r6"); \
101 register long int r7 __asm__ ("r7"); \
102 register long int r8 __asm__ ("r8"); \
103 LOADARGS_##nr(name, args); \
104 __asm__ __volatile__ \
109 "=&r" (r3), "=&r" (r4), "=&r" (r5), \
110 "=&r" (r6), "=&r" (r7), "=&r" (r8) \
112 : "r9", "r10", "r11", "r12", \
113 "cr0", "ctr", "memory"); \
117 #define INTERNAL_SYSCALL(name, err, nr, args...) \
118 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
120 #undef INTERNAL_SYSCALL_DECL
121 #define INTERNAL_SYSCALL_DECL(err) long int err
123 #undef INTERNAL_SYSCALL_ERROR_P
124 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
125 (__builtin_expect (err & (1 << 28), 0))
127 #undef INTERNAL_SYSCALL_ERRNO
128 #define INTERNAL_SYSCALL_ERRNO(val, err) (val)
130 #define LOADARGS_0(name, dummy) \
132 #define LOADARGS_1(name, __arg1) \
133 long int arg1 = (long int) (__arg1); \
134 LOADARGS_0(name, 0); \
135 extern void __illegally_sized_syscall_arg1 (void); \
136 if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 8) \
137 __illegally_sized_syscall_arg1 (); \
139 #define LOADARGS_2(name, __arg1, __arg2) \
140 long int arg2 = (long int) (__arg2); \
141 LOADARGS_1(name, __arg1); \
142 extern void __illegally_sized_syscall_arg2 (void); \
143 if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 8) \
144 __illegally_sized_syscall_arg2 (); \
146 #define LOADARGS_3(name, __arg1, __arg2, __arg3) \
147 long int arg3 = (long int) (__arg3); \
148 LOADARGS_2(name, __arg1, __arg2); \
149 extern void __illegally_sized_syscall_arg3 (void); \
150 if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 8) \
151 __illegally_sized_syscall_arg3 (); \
153 #define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
154 long int arg4 = (long int) (__arg4); \
155 LOADARGS_3(name, __arg1, __arg2, __arg3); \
156 extern void __illegally_sized_syscall_arg4 (void); \
157 if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 8) \
158 __illegally_sized_syscall_arg4 (); \
160 #define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
161 long int arg5 = (long int) (__arg5); \
162 LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
163 extern void __illegally_sized_syscall_arg5 (void); \
164 if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 8) \
165 __illegally_sized_syscall_arg5 (); \
167 #define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
168 long int arg6 = (long int) (__arg6); \
169 LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
170 extern void __illegally_sized_syscall_arg6 (void); \
171 if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 8) \
172 __illegally_sized_syscall_arg6 (); \
175 #define ASM_INPUT_0 "0" (r0)
176 #define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
177 #define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
178 #define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
179 #define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
180 #define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
181 #define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
183 #endif /* linux/powerpc/powerpc64/sysdep.h */