]>
git.ipfire.org Git - thirdparty/glibc.git/blob - 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.
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, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _LINUX_POWERPC_SYSDEP_H
20 #define _LINUX_POWERPC_SYSDEP_H 1
22 #include <sysdeps/unix/sysv/linux/sysdep.h>
23 #include <sysdeps/unix/powerpc/sysdep.h>
25 /* Define __set_errno() for INLINE_SYSCALL macro below. */
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. */
33 #define SYS_ify(syscall_name) __NR_##syscall_name
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. */
41 #define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, type, nr, args...) \
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__ \
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; \
64 #define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...) \
65 INTERNAL_VSYSCALL_CALL_TYPE(funcptr, long int, nr, args)
68 #undef INTERNAL_SYSCALL
69 #define INTERNAL_SYSCALL_NCS(name, nr, args...) \
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__ \
84 "=&r" (r3), "=&r" (r4), "=&r" (r5), \
85 "=&r" (r6), "=&r" (r7), "=&r" (r8) \
87 : "r9", "r10", "r11", "r12", \
88 "cr0", "ctr", "memory"); \
89 r0 & (1 << 28) ? -r3 : r3; \
91 #define INTERNAL_SYSCALL(name, nr, args...) \
92 INTERNAL_SYSCALL_NCS (__NR_##name, nr, args)
94 #if defined(__PPC64__) || defined(__powerpc64__)
95 # define SYSCALL_ARG_SIZE 8
97 # define SYSCALL_ARG_SIZE 4
100 #define LOADARGS_0(name, dummy) \
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 (); \
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 (); \
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 (); \
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 (); \
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 (); \
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 (); \
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)
160 /* Pointer mangling support. */
162 /* We cannot use the thread descriptor because in ld.so we use setjmp
163 earlier than the descriptor is initialized. */
165 # ifdef __ASSEMBLER__
166 # if defined(__PPC64__) || defined(__powerpc64__)
173 # define PTR_MANGLE(reg, tmpreg) \
174 LOAD tmpreg,POINTER_GUARD(TPREG); \
176 # define PTR_MANGLE2(reg, tmpreg) \
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)
185 # define PTR_MANGLE(var) \
186 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
187 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
191 /* List of system calls which are supported as vsyscalls. */
192 #define VDSO_NAME "LINUX_2.6.15"
193 #define VDSO_HASH 123718565
195 #if defined(__PPC64__) || defined(__powerpc64__)
196 #define HAVE_CLOCK_GETRES64_VSYSCALL "__kernel_clock_getres"
197 #define HAVE_CLOCK_GETTIME64_VSYSCALL "__kernel_clock_gettime"
199 #define HAVE_CLOCK_GETRES_VSYSCALL "__kernel_clock_getres"
200 #define HAVE_CLOCK_GETTIME_VSYSCALL "__kernel_clock_gettime"
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"
207 #if defined(__PPC64__) || defined(__powerpc64__)
208 # define HAVE_SIGTRAMP_RT64 "__kernel_sigtramp_rt64"
210 # define HAVE_SIGTRAMP_32 "__kernel_sigtramp32"
211 # define HAVE_SIGTRAMP_RT32 "__kernel_sigtramp_rt32"
214 #endif /* _LINUX_POWERPC_SYSDEP_H */