]>
Commit | Line | Data |
---|---|---|
0ecb606c JJ |
1 | /* Copyright (C) 1997, 2000, 2002, 2003, 2004, 2006 |
2 | Free Software Foundation, Inc. | |
5ae3e846 UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
5ae3e846 UD |
10 | |
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
5ae3e846 | 15 | |
41bdb6e2 AJ |
16 | You should have received a copy of the GNU Lesser General Public |
17 | License along with the GNU C Library; if not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
19 | 02111-1307 USA. */ | |
5ae3e846 UD |
20 | |
21 | #ifndef _LINUX_SPARC64_SYSDEP_H | |
22 | #define _LINUX_SPARC64_SYSDEP_H 1 | |
23 | ||
24 | #include <sysdeps/unix/sysdep.h> | |
25 | ||
369b849f RM |
26 | #ifdef IS_IN_rtld |
27 | # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */ | |
28 | #endif | |
0ecb606c | 29 | #include <tls.h> |
369b849f | 30 | |
5ae3e846 UD |
31 | #undef SYS_ify |
32 | #define SYS_ify(syscall_name) __NR_##syscall_name | |
33 | ||
66cc4d07 RM |
34 | /* This is a kludge to make syscalls.list find these under the names |
35 | pread and pwrite, since some kernel headers define those names | |
36 | and some define the *64 names for the same system calls. */ | |
37 | #if !defined __NR_pread && defined __NR_pread64 | |
38 | # define __NR_pread __NR_pread64 | |
39 | #endif | |
40 | #if !defined __NR_pwrite && defined __NR_pwrite64 | |
41 | # define __NR_pwrite __NR_pwrite64 | |
42 | #endif | |
43 | ||
66715f83 | 44 | #ifdef __ASSEMBLER__ |
5ae3e846 | 45 | |
131fd126 | 46 | #define LOADSYSCALL(x) mov __NR_##x, %g1 |
5ae3e846 UD |
47 | |
48 | /* Linux/SPARC uses a different trap number */ | |
49 | #undef PSEUDO | |
da058e45 | 50 | #undef PSEUDO_NOERRNO |
137ffcdc | 51 | #undef PSEUDO_ERRVAL |
5ae3e846 | 52 | #undef PSEUDO_END |
0ecb606c JJ |
53 | #undef ENTRY |
54 | #undef END | |
da058e45 | 55 | |
0ecb606c JJ |
56 | #define ENTRY(name) \ |
57 | .align 4; \ | |
58 | .global C_SYMBOL_NAME(name); \ | |
59 | .type name, @function; \ | |
60 | C_LABEL(name) \ | |
61 | cfi_startproc; | |
62 | ||
63 | #define END(name) \ | |
64 | cfi_endproc; \ | |
65 | .size name, . - name | |
66 | ||
67 | /* If the offset to __syscall_error fits into a signed 22-bit | |
68 | * immediate branch offset, the linker will relax the call into | |
69 | * a normal branch. | |
70 | */ | |
71 | #define PSEUDO(name, syscall_name, args) \ | |
72 | .text; \ | |
73 | .globl __syscall_error; \ | |
74 | ENTRY(name); \ | |
75 | LOADSYSCALL(syscall_name); \ | |
76 | ta 0x6d; \ | |
77 | bcc,pt %xcc, 1f; \ | |
78 | mov %o7, %g1; \ | |
79 | call __syscall_error; \ | |
80 | mov %g1, %o7; \ | |
81 | 1: | |
82 | ||
83 | #define PSEUDO_NOERRNO(name, syscall_name, args)\ | |
84 | .text; \ | |
85 | ENTRY(name); \ | |
86 | LOADSYSCALL(syscall_name); \ | |
87 | ta 0x6d; | |
88 | ||
89 | #define PSEUDO_ERRVAL(name, syscall_name, args) \ | |
90 | .text; \ | |
91 | ENTRY(name); \ | |
92 | LOADSYSCALL(syscall_name); \ | |
93 | ta 0x6d; | |
94 | ||
95 | #define PSEUDO_END(name) \ | |
96 | END(name) | |
137ffcdc | 97 | |
5ae3e846 UD |
98 | |
99 | /* Careful here! This "ret" define can interfere; use jmpl if unsure. */ | |
bd4f43b4 UD |
100 | #define ret retl; nop |
101 | #define ret_NOERRNO retl; nop | |
137ffcdc | 102 | #define ret_ERRVAL retl; nop |
5ae3e846 UD |
103 | #define r0 %o0 |
104 | #define r1 %o1 | |
105 | #define MOVE(x,y) mov x, y | |
106 | ||
4d76a0ec UD |
107 | #else /* __ASSEMBLER__ */ |
108 | ||
109 | #define __SYSCALL_STRING \ | |
110 | "ta 0x6d;" \ | |
111 | "bcc,pt %%xcc, 1f;" \ | |
112 | " nop;" \ | |
113 | "save %%sp, -192, %%sp;" \ | |
114 | "call __errno_location;" \ | |
115 | " nop;" \ | |
116 | "st %%i0,[%%o0];" \ | |
117 | "restore %%g0, -1, %%o0;" \ | |
118 | "1:" | |
119 | ||
b5bc52ef UD |
120 | #define __CLONE_SYSCALL_STRING \ |
121 | "ta 0x6d;" \ | |
122 | "bcc,pt %%xcc, 1f;" \ | |
123 | " sub %%o1, 1, %%o1;" \ | |
124 | "save %%sp, -192, %%sp;" \ | |
125 | "call __errno_location;" \ | |
126 | " mov -1, %%i1;" \ | |
127 | "st %%i0,[%%o0];" \ | |
128 | "restore %%g0, -1, %%o0;" \ | |
129 | "1:" \ | |
130 | "and %%o0, %%o1, %%o0" | |
131 | ||
369b849f RM |
132 | #define __INTERNAL_SYSCALL_STRING \ |
133 | "ta 0x6d;" \ | |
134 | "bcs,a,pt %%xcc, 1f;" \ | |
135 | " sub %%g0, %%o0, %%o0;" \ | |
136 | "1:" | |
137 | ||
62f29da7 | 138 | #define __SYSCALL_CLOBBERS "g2", "g3", "g4", "g5", "g6", \ |
4d76a0ec UD |
139 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ |
140 | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ | |
141 | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ | |
142 | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ | |
143 | "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \ | |
144 | "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \ | |
145 | "cc", "memory" | |
146 | ||
147 | #include <sysdeps/unix/sysv/linux/sparc/sysdep.h> | |
148 | ||
66715f83 | 149 | #endif /* __ASSEMBLER__ */ |
5ae3e846 | 150 | |
9bd9c815 | 151 | /* This is the offset from the %sp to the backing store above the |
5ae3e846 UD |
152 | register windows. So if you poke stack memory directly you add this. */ |
153 | #define STACK_BIAS 2047 | |
154 | ||
0ecb606c JJ |
155 | /* Pointer mangling support. */ |
156 | #if defined NOT_IN_libc && defined IS_IN_rtld | |
157 | /* We cannot use the thread descriptor because in ld.so we use setjmp | |
158 | earlier than the descriptor is initialized. */ | |
159 | #else | |
160 | # ifdef __ASSEMBLER__ | |
161 | # define PTR_MANGLE(dreg, reg, tmpreg) \ | |
162 | ldx [%g7 + POINTER_GUARD], tmpreg; \ | |
163 | xor reg, tmpreg, dreg | |
164 | # define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg) | |
165 | # define PTR_MANGLE2(dreg, reg, tmpreg) \ | |
166 | xor reg, tmpreg, dreg | |
167 | # define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg) | |
168 | # else | |
169 | # define PTR_MANGLE(var) \ | |
170 | (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ()) | |
171 | # define PTR_DEMANGLE(var) PTR_MANGLE (var) | |
172 | # endif | |
173 | #endif | |
174 | ||
5ae3e846 | 175 | #endif /* linux/sparc64/sysdep.h */ |