]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
Fix powl inaccuracy for ldbl-128ibm (bug 14914).
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / powerpc / powerpc32 / sysdep.h
CommitLineData
965a54a4 1/* Copyright (C) 1992,1997-2006,2012 Free Software Foundation, Inc.
4cca6b86
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
4cca6b86
UD
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
4cca6b86 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
4cca6b86 17
924102e7
UD
18#ifndef _LINUX_POWERPC_SYSDEP_H
19#define _LINUX_POWERPC_SYSDEP_H 1
20
be9cd93a 21#include <sysdeps/unix/powerpc/sysdep.h>
00c2b3b9 22#include <tls.h>
4cca6b86 23
5bfed16d
UD
24/* Some systen calls got renamed over time, but retained the same semantics.
25 Handle them here so they can be catched by both C and assembler stubs in
26 glibc. */
27
28#ifdef __NR_pread64
29# ifdef __NR_pread
30# error "__NR_pread and __NR_pread64 both defined???"
31# endif
32# define __NR_pread __NR_pread64
33#endif
34
35#ifdef __NR_pwrite64
36# ifdef __NR_pwrite
37# error "__NR_pwrite and __NR_pwrite64 both defined???"
38# endif
39# define __NR_pwrite __NR_pwrite64
40#endif
41
4cca6b86
UD
42/* For Linux we can use the system call table in the header file
43 /usr/include/asm/unistd.h
44 of the kernel. But these symbols do not follow the SYS_* syntax
45 so we have to redefine the `SYS_ify' macro here. */
46#undef SYS_ify
965a54a4 47#define SYS_ify(syscall_name) __NR_##syscall_name
4cca6b86 48
735d67f2
RM
49#ifndef __ASSEMBLER__
50
51# include <errno.h>
52
8c2e201b
UD
53# ifdef SHARED
54# define INLINE_VSYSCALL(name, nr, args...) \
55 ({ \
56 __label__ out; \
57 __label__ iserr; \
58 INTERNAL_SYSCALL_DECL (sc_err); \
59 long int sc_ret; \
60 \
61 if (__vdso_##name != NULL) \
62 { \
63 sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, nr, ##args); \
64 if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
65 goto out; \
66 if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \
67 goto iserr; \
68 } \
69 \
70 sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \
71 if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
72 { \
73 iserr: \
74 __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
75 sc_ret = -1L; \
76 } \
77 out: \
78 sc_ret; \
79 })
80# else
81# define INLINE_VSYSCALL(name, nr, args...) \
82 INLINE_SYSCALL (name, nr, ##args)
83# endif
84
85# ifdef SHARED
86# define INTERNAL_VSYSCALL(name, err, nr, args...) \
87 ({ \
88 __label__ out; \
89 long int v_ret; \
90 \
91 if (__vdso_##name != NULL) \
92 { \
93 v_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \
94 if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \
95 || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \
96 goto out; \
97 } \
98 v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \
99 out: \
100 v_ret; \
101 })
102# else
103# define INTERNAL_VSYSCALL(name, err, nr, args...) \
104 INTERNAL_SYSCALL (name, err, nr, ##args)
105# endif
106
107# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \
108 ({ \
109 long int sc_ret = ENOSYS; \
110 \
111 if (__vdso_##name != NULL) \
112 sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \
113 else \
114 err = 1 << 28; \
115 sc_ret; \
116 })
117
118/* List of system calls which are supported as vsyscalls. */
119# define HAVE_CLOCK_GETRES_VSYSCALL 1
120# define HAVE_CLOCK_GETTIME_VSYSCALL 1
121
122/* Define a macro which expands inline into the wrapper code for a VDSO
123 call. This use is for internal calls that do not need to handle errors
124 normally. It will never touch errno.
125 On powerpc a system call basically clobbers the same registers like a
126 function call, with the exception of LR (which is needed for the
127 "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
128 an error return status). */
129# define INTERNAL_VSYSCALL_NCS(funcptr, err, nr, args...) \
130 ({ \
131 register void *r0 __asm__ ("r0"); \
132 register long int r3 __asm__ ("r3"); \
133 register long int r4 __asm__ ("r4"); \
134 register long int r5 __asm__ ("r5"); \
135 register long int r6 __asm__ ("r6"); \
136 register long int r7 __asm__ ("r7"); \
137 register long int r8 __asm__ ("r8"); \
138 register long int r9 __asm__ ("r9"); \
139 register long int r10 __asm__ ("r10"); \
140 register long int r11 __asm__ ("r11"); \
141 register long int r12 __asm__ ("r12"); \
142 LOADARGS_##nr (funcptr, args); \
143 __asm__ __volatile__ \
144 ("mtctr %0\n\t" \
145 "bctrl\n\t" \
146 "mfcr %0" \
147 : "=&r" (r0), \
148 "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
149 "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
150 : ASM_INPUT_##nr \
151 : "cr0", "ctr", "lr", "memory"); \
152 err = (long int) r0; \
153 (int) r3; \
154 })
155
735d67f2 156# undef INLINE_SYSCALL
704bb2fd
RM
157# define INLINE_SYSCALL(name, nr, args...) \
158 ({ \
b398ae3c 159 INTERNAL_SYSCALL_DECL (sc_err); \
c67a469f 160 long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
b398ae3c 161 if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
704bb2fd 162 { \
b398ae3c
UD
163 __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
164 sc_ret = -1L; \
704bb2fd 165 } \
b398ae3c 166 sc_ret; \
735d67f2
RM
167 })
168
73e9ae88
UD
169/* Define a macro which expands inline into the wrapper code for a system
170 call. This use is for internal calls that do not need to handle errors
b398ae3c
UD
171 normally. It will never touch errno.
172 On powerpc a system call basically clobbers the same registers like a
173 function call, with the exception of LR (which is needed for the
174 "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
175 an error return status). */
73e9ae88 176
6aca81bb 177# undef INTERNAL_SYSCALL_DECL
c67a469f 178# define INTERNAL_SYSCALL_DECL(err) long int err
6aca81bb 179
52f3d213 180# undef INTERNAL_SYSCALL
2edb61e3 181# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
73e9ae88 182 ({ \
c67a469f
UD
183 register long int r0 __asm__ ("r0"); \
184 register long int r3 __asm__ ("r3"); \
185 register long int r4 __asm__ ("r4"); \
186 register long int r5 __asm__ ("r5"); \
187 register long int r6 __asm__ ("r6"); \
188 register long int r7 __asm__ ("r7"); \
189 register long int r8 __asm__ ("r8"); \
190 register long int r9 __asm__ ("r9"); \
191 register long int r10 __asm__ ("r10"); \
192 register long int r11 __asm__ ("r11"); \
193 register long int r12 __asm__ ("r12"); \
8c2e201b 194 LOADARGS_##nr(name, args); \
73e9ae88 195 __asm__ __volatile__ \
b398ae3c
UD
196 ("sc \n\t" \
197 "mfcr %0" \
73e9ae88
UD
198 : "=&r" (r0), \
199 "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
200 "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
201 : ASM_INPUT_##nr \
202 : "cr0", "ctr", "memory"); \
b398ae3c 203 err = r0; \
73e9ae88
UD
204 (int) r3; \
205 })
2edb61e3
UD
206# define INTERNAL_SYSCALL(name, err, nr, args...) \
207 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
6aca81bb 208
52f3d213 209# undef INTERNAL_SYSCALL_ERROR_P
6aca81bb 210# define INTERNAL_SYSCALL_ERROR_P(val, err) \
a2274a08 211 ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
6aca81bb 212
52f3d213 213# undef INTERNAL_SYSCALL_ERRNO
b398ae3c 214# define INTERNAL_SYSCALL_ERRNO(val, err) (val)
73e9ae88 215
8c2e201b 216# define LOADARGS_0(name, dummy) \
2edb61e3 217 r0 = name
c67a469f
UD
218# define LOADARGS_1(name, __arg1) \
219 long int arg1 = (long int) (__arg1); \
8c2e201b 220 LOADARGS_0(name, 0); \
2edb61e3 221 extern void __illegally_sized_syscall_arg1 (void); \
c67a469f 222 if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
2edb61e3 223 __illegally_sized_syscall_arg1 (); \
c67a469f
UD
224 r3 = arg1
225# define LOADARGS_2(name, __arg1, __arg2) \
226 long int arg2 = (long int) (__arg2); \
227 LOADARGS_1(name, __arg1); \
2edb61e3 228 extern void __illegally_sized_syscall_arg2 (void); \
c67a469f 229 if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
2edb61e3 230 __illegally_sized_syscall_arg2 (); \
c67a469f
UD
231 r4 = arg2
232# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
233 long int arg3 = (long int) (__arg3); \
234 LOADARGS_2(name, __arg1, __arg2); \
2edb61e3 235 extern void __illegally_sized_syscall_arg3 (void); \
c67a469f 236 if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
2edb61e3 237 __illegally_sized_syscall_arg3 (); \
c67a469f
UD
238 r5 = arg3
239# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
240 long int arg4 = (long int) (__arg4); \
241 LOADARGS_3(name, __arg1, __arg2, __arg3); \
2edb61e3 242 extern void __illegally_sized_syscall_arg4 (void); \
c67a469f 243 if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
2edb61e3 244 __illegally_sized_syscall_arg4 (); \
c67a469f
UD
245 r6 = arg4
246# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
247 long int arg5 = (long int) (__arg5); \
248 LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
2edb61e3 249 extern void __illegally_sized_syscall_arg5 (void); \
c67a469f 250 if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
2edb61e3 251 __illegally_sized_syscall_arg5 (); \
c67a469f
UD
252 r7 = arg5
253# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
254 long int arg6 = (long int) (__arg6); \
255 LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
2edb61e3 256 extern void __illegally_sized_syscall_arg6 (void); \
c67a469f 257 if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
2edb61e3 258 __illegally_sized_syscall_arg6 (); \
c67a469f 259 r8 = arg6
735d67f2 260
704bb2fd
RM
261# define ASM_INPUT_0 "0" (r0)
262# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
263# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
264# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
265# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
266# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
267# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
735d67f2
RM
268
269#endif /* __ASSEMBLER__ */
270
271
00c2b3b9
UD
272/* Pointer mangling support. */
273#if defined NOT_IN_libc && defined IS_IN_rtld
274/* We cannot use the thread descriptor because in ld.so we use setjmp
275 earlier than the descriptor is initialized. */
276#else
277# ifdef __ASSEMBLER__
278# define PTR_MANGLE(reg, tmpreg) \
279 lwz tmpreg,POINTER_GUARD(r2); \
280 xor reg,tmpreg,reg
5ad77144 281# define PTR_MANGLE2(reg, tmpreg) \
4e54d7e4 282 xor reg,tmpreg,reg
4a132246
UD
283# define PTR_MANGLE3(destreg, reg, tmpreg) \
284 lwz tmpreg,POINTER_GUARD(r2); \
285 xor destreg,tmpreg,reg
5ad77144
UD
286# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
287# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
4a132246 288# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
00c2b3b9
UD
289# else
290# define PTR_MANGLE(var) \
db169ed5 291 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
00c2b3b9
UD
292# define PTR_DEMANGLE(var) PTR_MANGLE (var)
293# endif
294#endif
295
b398ae3c 296#endif /* linux/powerpc/powerpc32/sysdep.h */