]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/powerpc/sysdep.h
linux: Remove INTERNAL_SYSCALL_DECL
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / powerpc / sysdep.h
1 /* Syscall definitions, Linux PowerPC generic version.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19 #ifndef _LINUX_POWERPC_SYSDEP_H
20 #define _LINUX_POWERPC_SYSDEP_H 1
21
22 #include <sysdeps/unix/sysv/linux/sysdep.h>
23 #include <sysdeps/unix/powerpc/sysdep.h>
24 #include <tls.h>
25 /* Define __set_errno() for INLINE_SYSCALL macro below. */
26 #include <errno.h>
27
28 /* For Linux we can use the system call table in the header file
29 /usr/include/asm/unistd.h
30 of the kernel. But these symbols do not follow the SYS_* syntax
31 so we have to redefine the `SYS_ify' macro here. */
32 #undef SYS_ify
33 #define SYS_ify(syscall_name) __NR_##syscall_name
34
35 /* Define a macro which expands inline into the wrapper code for a system
36 call. This use is for internal calls that do not need to handle errors
37 normally. It will never touch errno. This returns just what the kernel
38 gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
39 the negation of the return value in the kernel gets reverted. */
40
41 #define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, type, nr, args...) \
42 ({ \
43 register void *r0 __asm__ ("r0"); \
44 register long int r3 __asm__ ("r3"); \
45 register long int r4 __asm__ ("r4"); \
46 register long int r5 __asm__ ("r5"); \
47 register long int r6 __asm__ ("r6"); \
48 register long int r7 __asm__ ("r7"); \
49 register long int r8 __asm__ ("r8"); \
50 register type rval __asm__ ("r3"); \
51 LOADARGS_##nr (funcptr, args); \
52 __asm__ __volatile__ \
53 ("mtctr %0\n\t" \
54 "bctrl\n\t" \
55 "mfcr %0\n\t" \
56 "0:" \
57 : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), \
58 "+r" (r7), "+r" (r8) \
59 : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory"); \
60 __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3)); \
61 (long int) r0 & (1 << 28) ? -rval : rval; \
62 })
63
64 #define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...) \
65 INTERNAL_VSYSCALL_CALL_TYPE(funcptr, long int, nr, args)
66
67
68 #undef INTERNAL_SYSCALL
69 #define INTERNAL_SYSCALL_NCS(name, nr, args...) \
70 ({ \
71 register long int r0 __asm__ ("r0"); \
72 register long int r3 __asm__ ("r3"); \
73 register long int r4 __asm__ ("r4"); \
74 register long int r5 __asm__ ("r5"); \
75 register long int r6 __asm__ ("r6"); \
76 register long int r7 __asm__ ("r7"); \
77 register long int r8 __asm__ ("r8"); \
78 LOADARGS_##nr (name, ##args); \
79 __asm__ __volatile__ \
80 ("sc\n\t" \
81 "mfcr %0\n\t" \
82 "0:" \
83 : "=&r" (r0), \
84 "=&r" (r3), "=&r" (r4), "=&r" (r5), \
85 "=&r" (r6), "=&r" (r7), "=&r" (r8) \
86 : ASM_INPUT_##nr \
87 : "r9", "r10", "r11", "r12", \
88 "cr0", "ctr", "memory"); \
89 r0 & (1 << 28) ? -r3 : r3; \
90 })
91 #define INTERNAL_SYSCALL(name, nr, args...) \
92 INTERNAL_SYSCALL_NCS (__NR_##name, nr, args)
93
94 #if defined(__PPC64__) || defined(__powerpc64__)
95 # define SYSCALL_ARG_SIZE 8
96 #else
97 # define SYSCALL_ARG_SIZE 4
98 #endif
99
100 #define LOADARGS_0(name, dummy) \
101 r0 = name
102 #define LOADARGS_1(name, __arg1) \
103 long int arg1 = (long int) (__arg1); \
104 LOADARGS_0(name, 0); \
105 extern void __illegally_sized_syscall_arg1 (void); \
106 if (__builtin_classify_type (__arg1) != 5 \
107 && sizeof (__arg1) > SYSCALL_ARG_SIZE) \
108 __illegally_sized_syscall_arg1 (); \
109 r3 = arg1
110 #define LOADARGS_2(name, __arg1, __arg2) \
111 long int arg2 = (long int) (__arg2); \
112 LOADARGS_1(name, __arg1); \
113 extern void __illegally_sized_syscall_arg2 (void); \
114 if (__builtin_classify_type (__arg2) != 5 \
115 && sizeof (__arg2) > SYSCALL_ARG_SIZE) \
116 __illegally_sized_syscall_arg2 (); \
117 r4 = arg2
118 #define LOADARGS_3(name, __arg1, __arg2, __arg3) \
119 long int arg3 = (long int) (__arg3); \
120 LOADARGS_2(name, __arg1, __arg2); \
121 extern void __illegally_sized_syscall_arg3 (void); \
122 if (__builtin_classify_type (__arg3) != 5 \
123 && sizeof (__arg3) > SYSCALL_ARG_SIZE) \
124 __illegally_sized_syscall_arg3 (); \
125 r5 = arg3
126 #define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
127 long int arg4 = (long int) (__arg4); \
128 LOADARGS_3(name, __arg1, __arg2, __arg3); \
129 extern void __illegally_sized_syscall_arg4 (void); \
130 if (__builtin_classify_type (__arg4) != 5 \
131 && sizeof (__arg4) > SYSCALL_ARG_SIZE) \
132 __illegally_sized_syscall_arg4 (); \
133 r6 = arg4
134 #define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
135 long int arg5 = (long int) (__arg5); \
136 LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
137 extern void __illegally_sized_syscall_arg5 (void); \
138 if (__builtin_classify_type (__arg5) != 5 \
139 && sizeof (__arg5) > SYSCALL_ARG_SIZE) \
140 __illegally_sized_syscall_arg5 (); \
141 r7 = arg5
142 #define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
143 long int arg6 = (long int) (__arg6); \
144 LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
145 extern void __illegally_sized_syscall_arg6 (void); \
146 if (__builtin_classify_type (__arg6) != 5 \
147 && sizeof (__arg6) > SYSCALL_ARG_SIZE) \
148 __illegally_sized_syscall_arg6 (); \
149 r8 = arg6
150
151 #define ASM_INPUT_0 "0" (r0)
152 #define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
153 #define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
154 #define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
155 #define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
156 #define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
157 #define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
158
159
160 /* Pointer mangling support. */
161 #if IS_IN (rtld)
162 /* We cannot use the thread descriptor because in ld.so we use setjmp
163 earlier than the descriptor is initialized. */
164 #else
165 # ifdef __ASSEMBLER__
166 # if defined(__PPC64__) || defined(__powerpc64__)
167 # define LOAD ld
168 # define TPREG r13
169 # else
170 # define LOAD lwz
171 # define TPREG r2
172 # endif
173 # define PTR_MANGLE(reg, tmpreg) \
174 LOAD tmpreg,POINTER_GUARD(TPREG); \
175 xor reg,tmpreg,reg
176 # define PTR_MANGLE2(reg, tmpreg) \
177 xor reg,tmpreg,reg
178 # define PTR_MANGLE3(destreg, reg, tmpreg) \
179 LOAD tmpreg,POINTER_GUARD(TPREG); \
180 xor destreg,tmpreg,reg
181 # define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
182 # define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
183 # define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
184 # else
185 # define PTR_MANGLE(var) \
186 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
187 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
188 # endif
189 #endif
190
191 /* List of system calls which are supported as vsyscalls. */
192 #define VDSO_NAME "LINUX_2.6.15"
193 #define VDSO_HASH 123718565
194
195 #if defined(__PPC64__) || defined(__powerpc64__)
196 #define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres"
197 #define HAVE_CLOCK_GETTIME64_VSYSCALL "__kernel_clock_gettime"
198 #else
199 #define HAVE_CLOCK_GETRES_VSYSCALL "__kernel_clock_getres"
200 #define HAVE_CLOCK_GETTIME_VSYSCALL "__kernel_clock_gettime"
201 #endif
202 #define HAVE_GETCPU_VSYSCALL "__kernel_getcpu"
203 #define HAVE_TIME_VSYSCALL "__kernel_time"
204 #define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday"
205 #define HAVE_GET_TBFREQ "__kernel_get_tbfreq"
206
207 #if defined(__PPC64__) || defined(__powerpc64__)
208 # define HAVE_SIGTRAMP_RT64 "__kernel_sigtramp_rt64"
209 #else
210 # define HAVE_SIGTRAMP_32 "__kernel_sigtramp32"
211 # define HAVE_SIGTRAMP_RT32 "__kernel_sigtramp_rt32"
212 #endif
213
214 #endif /* _LINUX_POWERPC_SYSDEP_H */