]>
Commit | Line | Data |
---|---|---|
bfff8b1b | 1 | /* Copyright (C) 1997-2017 Free Software Foundation, Inc. |
5ae3e846 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
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. | |
5ae3e846 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
5ae3e846 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
5ae3e846 UD |
18 | |
19 | #ifndef _LINUX_SPARC64_SYSDEP_H | |
20 | #define _LINUX_SPARC64_SYSDEP_H 1 | |
21 | ||
aab39a09 | 22 | #include <sysdeps/unix/sysv/linux/sparc/sysdep.h> |
5ae3e846 | 23 | |
a3848485 | 24 | #if IS_IN (rtld) |
369b849f RM |
25 | # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */ |
26 | #endif | |
ced368f7 | 27 | #include <tls.h> |
369b849f | 28 | |
5ae3e846 UD |
29 | #undef SYS_ify |
30 | #define SYS_ify(syscall_name) __NR_##syscall_name | |
31 | ||
66cc4d07 RM |
32 | /* This is a kludge to make syscalls.list find these under the names |
33 | pread and pwrite, since some kernel headers define those names | |
34 | and some define the *64 names for the same system calls. */ | |
35 | #if !defined __NR_pread && defined __NR_pread64 | |
36 | # define __NR_pread __NR_pread64 | |
37 | #endif | |
38 | #if !defined __NR_pwrite && defined __NR_pwrite64 | |
39 | # define __NR_pwrite __NR_pwrite64 | |
40 | #endif | |
41 | ||
66715f83 | 42 | #ifdef __ASSEMBLER__ |
5ae3e846 | 43 | |
131fd126 | 44 | #define LOADSYSCALL(x) mov __NR_##x, %g1 |
5ae3e846 | 45 | |
5ae3e846 | 46 | #undef PSEUDO |
043cee37 RM |
47 | #define PSEUDO(name, syscall_name, args) \ |
48 | .text; \ | |
043cee37 RM |
49 | ENTRY(name); \ |
50 | LOADSYSCALL(syscall_name); \ | |
51 | ta 0x6d; \ | |
52 | bcc,pt %xcc, 1f; \ | |
3ba57516 DM |
53 | nop; \ |
54 | SYSCALL_ERROR_HANDLER \ | |
043cee37 RM |
55 | 1: |
56 | ||
aab39a09 | 57 | #undef PSEUDO_NOERRNO |
043cee37 RM |
58 | #define PSEUDO_NOERRNO(name, syscall_name, args)\ |
59 | .text; \ | |
60 | ENTRY(name); \ | |
61 | LOADSYSCALL(syscall_name); \ | |
62 | ta 0x6d; | |
63 | ||
aab39a09 | 64 | #undef PSEUDO_ERRVAL |
043cee37 RM |
65 | #define PSEUDO_ERRVAL(name, syscall_name, args) \ |
66 | .text; \ | |
67 | ENTRY(name); \ | |
68 | LOADSYSCALL(syscall_name); \ | |
69 | ta 0x6d; | |
70 | ||
aab39a09 | 71 | #undef PSEUDO_END |
043cee37 RM |
72 | #define PSEUDO_END(name) \ |
73 | END(name) | |
a334319f | 74 | |
3ba57516 DM |
75 | #ifndef PIC |
76 | # define SYSCALL_ERROR_HANDLER \ | |
77 | mov %o7, %g1; \ | |
78 | call __syscall_error; \ | |
79 | mov %g1, %o7; | |
80 | #else | |
81 | # if RTLD_PRIVATE_ERRNO | |
53362a4b | 82 | # define SYSCALL_ERROR_HANDLER \ |
3d2b3019 DM |
83 | 0: SETUP_PIC_REG_LEAF(o2,g1) \ |
84 | sethi %gdop_hix22(rtld_errno), %g1; \ | |
85 | xor %g1, %gdop_lox10(rtld_errno), %g1;\ | |
86 | ldx [%o2 + %g1], %g1, %gdop(rtld_errno); \ | |
87 | st %o0, [%g1]; \ | |
88 | jmp %o7 + 8; \ | |
89 | mov -1, %o0; | |
3ba57516 DM |
90 | # elif defined _LIBC_REENTRANT |
91 | ||
4f41c682 | 92 | # if IS_IN (libc) |
d063d164 UD |
93 | # define SYSCALL_ERROR_ERRNO __libc_errno |
94 | # else | |
95 | # define SYSCALL_ERROR_ERRNO errno | |
96 | # endif | |
dd54084d DM |
97 | # define SYSCALL_ERROR_HANDLER \ |
98 | 0: SETUP_PIC_REG_LEAF(o2,g1) \ | |
3ba57516 DM |
99 | sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \ |
100 | add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \ | |
101 | ldx [%o2 + %g1], %g1, %tie_ldx(SYSCALL_ERROR_ERRNO);\ | |
d063d164 UD |
102 | st %o0, [%g7 + %g1]; \ |
103 | jmp %o7 + 8; \ | |
3ba57516 | 104 | mov -1, %o0; |
3ba57516 | 105 | # else |
53362a4b | 106 | # define SYSCALL_ERROR_HANDLER \ |
3d2b3019 DM |
107 | 0: SETUP_PIC_REG_LEAF(o2,g1) \ |
108 | sethi %gdop_hix22(errno), %g1;\ | |
109 | xor %g1, %gdop_lox10(errno), %g1;\ | |
110 | ldx [%o2 + %g1], %g1, %gdop(errno);\ | |
111 | st %o0, [%g1]; \ | |
112 | jmp %o7 + 8; \ | |
113 | mov -1, %o0; | |
3ba57516 DM |
114 | # endif /* _LIBC_REENTRANT */ |
115 | #endif /* PIC */ | |
5ae3e846 | 116 | |
4d76a0ec UD |
117 | #else /* __ASSEMBLER__ */ |
118 | ||
119 | #define __SYSCALL_STRING \ | |
120 | "ta 0x6d;" \ | |
121 | "bcc,pt %%xcc, 1f;" \ | |
3ba57516 DM |
122 | " mov 0, %%g1;" \ |
123 | "sub %%g0, %%o0, %%o0;" \ | |
124 | "mov 1, %%g1;" \ | |
369b849f RM |
125 | "1:" |
126 | ||
86746abb | 127 | #define __SYSCALL_CLOBBERS \ |
4d76a0ec UD |
128 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ |
129 | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ | |
130 | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ | |
131 | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ | |
132 | "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \ | |
133 | "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \ | |
134 | "cc", "memory" | |
135 | ||
66715f83 | 136 | #endif /* __ASSEMBLER__ */ |
5ae3e846 | 137 | |
9bd9c815 | 138 | /* This is the offset from the %sp to the backing store above the |
5ae3e846 UD |
139 | register windows. So if you poke stack memory directly you add this. */ |
140 | #define STACK_BIAS 2047 | |
141 | ||
305bb37e | 142 | /* Pointer mangling support. */ |
a3848485 | 143 | #if IS_IN (rtld) |
305bb37e UD |
144 | /* We cannot use the thread descriptor because in ld.so we use setjmp |
145 | earlier than the descriptor is initialized. */ | |
146 | #else | |
147 | # ifdef __ASSEMBLER__ | |
148 | # define PTR_MANGLE(dreg, reg, tmpreg) \ | |
149 | ldx [%g7 + POINTER_GUARD], tmpreg; \ | |
150 | xor reg, tmpreg, dreg | |
151 | # define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg) | |
152 | # define PTR_MANGLE2(dreg, reg, tmpreg) \ | |
153 | xor reg, tmpreg, dreg | |
154 | # define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg) | |
155 | # else | |
156 | # define PTR_MANGLE(var) \ | |
157 | (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ()) | |
158 | # define PTR_DEMANGLE(var) PTR_MANGLE (var) | |
159 | # endif | |
160 | #endif | |
161 | ||
5ae3e846 | 162 | #endif /* linux/sparc64/sysdep.h */ |