2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc64 / sysdep.h
blob79fa13de75a87749c1864697fc51012995d665bf
1 /* Copyright (C) 1997, 2000, 2002, 2003, 2004, 2006, 2008
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
6 The GNU C Library is free software; you can redistribute it and/or
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.
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
14 Lesser General Public License for more details.
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. */
21 #ifndef _LINUX_SPARC64_SYSDEP_H
22 #define _LINUX_SPARC64_SYSDEP_H 1
24 #include <sysdeps/unix/sysdep.h>
26 #ifdef IS_IN_rtld
27 # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
28 #endif
29 #include <tls.h>
31 #undef SYS_ify
32 #define SYS_ify(syscall_name) __NR_##syscall_name
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
44 #ifdef __ASSEMBLER__
46 #define LOADSYSCALL(x) mov __NR_##x, %g1
48 /* Linux/SPARC uses a different trap number */
49 #undef PSEUDO
50 #undef PSEUDO_NOERRNO
51 #undef PSEUDO_ERRVAL
52 #undef PSEUDO_END
53 #undef ENTRY
54 #undef END
56 #define ENTRY(name) \
57 .align 4; \
58 .global C_SYMBOL_NAME(name); \
59 .type name, @function; \
60 C_LABEL(name) \
61 cfi_startproc;
63 #define END(name) \
64 cfi_endproc; \
65 .size name, . - name
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.
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; \
83 #define PSEUDO_NOERRNO(name, syscall_name, args)\
84 .text; \
85 ENTRY(name); \
86 LOADSYSCALL(syscall_name); \
87 ta 0x6d;
89 #define PSEUDO_ERRVAL(name, syscall_name, args) \
90 .text; \
91 ENTRY(name); \
92 LOADSYSCALL(syscall_name); \
93 ta 0x6d;
95 #define PSEUDO_END(name) \
96 END(name)
99 /* Careful here! This "ret" define can interfere; use jmpl if unsure. */
100 #define ret retl; nop
101 #define ret_NOERRNO retl; nop
102 #define ret_ERRVAL retl; nop
103 #define r0 %o0
104 #define r1 %o1
105 #define MOVE(x,y) mov x, y
107 #else /* __ASSEMBLER__ */
109 #if defined SHARED && defined DO_VERSIONING && defined PIC \
110 && !defined NO_HIDDEN && !defined NOT_IN_libc
111 # define CALL_ERRNO_LOCATION "call __GI___errno_location;"
112 #else
113 # define CALL_ERRNO_LOCATION "call __errno_location;"
114 #endif
116 #define __SYSCALL_STRING \
117 "ta 0x6d;" \
118 "bcc,pt %%xcc, 1f;" \
119 " nop;" \
120 "save %%sp, -192, %%sp;" \
121 CALL_ERRNO_LOCATION \
122 " nop;" \
123 "st %%i0,[%%o0];" \
124 "restore %%g0, -1, %%o0;" \
125 "1:"
127 #define __CLONE_SYSCALL_STRING \
128 "ta 0x6d;" \
129 "bcc,pt %%xcc, 1f;" \
130 " sub %%o1, 1, %%o1;" \
131 "save %%sp, -192, %%sp;" \
132 CALL_ERRNO_LOCATION \
133 " mov -1, %%i1;" \
134 "st %%i0,[%%o0];" \
135 "restore %%g0, -1, %%o0;" \
136 "1:" \
137 "and %%o0, %%o1, %%o0"
139 #define __INTERNAL_SYSCALL_STRING \
140 "ta 0x6d;" \
141 "bcs,a,pt %%xcc, 1f;" \
142 " sub %%g0, %%o0, %%o0;" \
143 "1:"
145 #define __SYSCALL_CLOBBERS \
146 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
147 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
148 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
149 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
150 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
151 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \
152 "cc", "memory"
154 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
156 #endif /* __ASSEMBLER__ */
158 /* This is the offset from the %sp to the backing store above the
159 register windows. So if you poke stack memory directly you add this. */
160 #define STACK_BIAS 2047
162 /* Pointer mangling support. */
163 #if defined NOT_IN_libc && defined IS_IN_rtld
164 /* We cannot use the thread descriptor because in ld.so we use setjmp
165 earlier than the descriptor is initialized. */
166 #else
167 # ifdef __ASSEMBLER__
168 # define PTR_MANGLE(dreg, reg, tmpreg) \
169 ldx [%g7 + POINTER_GUARD], tmpreg; \
170 xor reg, tmpreg, dreg
171 # define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
172 # define PTR_MANGLE2(dreg, reg, tmpreg) \
173 xor reg, tmpreg, dreg
174 # define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
175 # else
176 # define PTR_MANGLE(var) \
177 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
178 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
179 # endif
180 #endif
182 #endif /* linux/sparc64/sysdep.h */