Fix sparc localplt testcase failures.
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc32 / sysdep.h
blob8af045dc2bee7b5f890cec793f1c09e6c77e8be0
1 /* Copyright (C) 1997, 2002, 2003, 2004, 2006, 2008
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, January 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_SPARC32_SYSDEP_H
22 #define _LINUX_SPARC32_SYSDEP_H 1
24 #include <sysdeps/unix/sparc/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 #ifdef __ASSEMBLER__
36 #define LOADSYSCALL(x) mov __NR_##x, %g1
38 /* Linux/SPARC uses a different trap number */
39 #undef PSEUDO
40 #undef PSEUDO_NOERRNO
41 #undef PSEUDO_ERRVAL
42 #undef PSEUDO_END
43 #undef ENTRY
44 #undef END
45 #undef LOC
47 #define ENTRY(name) \
48 .align 4; \
49 .global C_SYMBOL_NAME(name); \
50 .type name, @function; \
51 C_LABEL(name) \
52 cfi_startproc;
54 #define END(name) \
55 cfi_endproc; \
56 .size name, . - name
58 #define LOC(name) .L##name
60 #define PSEUDO(name, syscall_name, args) \
61 .text; \
62 ENTRY(name); \
63 LOADSYSCALL(syscall_name); \
64 ta 0x10; \
65 bcc 1f; \
66 nop; \
67 SYSCALL_ERROR_HANDLER \
70 #define PSEUDO_NOERRNO(name, syscall_name, args)\
71 .text; \
72 ENTRY(name); \
73 LOADSYSCALL(syscall_name); \
74 ta 0x10;
76 #define PSEUDO_ERRVAL(name, syscall_name, args) \
77 .text; \
78 ENTRY(name); \
79 LOADSYSCALL(syscall_name); \
80 ta 0x10;
82 #define PSEUDO_END(name) \
83 END(name)
85 #ifndef PIC
86 # define SYSCALL_ERROR_HANDLER \
87 mov %o7, %g1; \
88 call __syscall_error; \
89 mov %g1, %o7;
90 #else
91 # if RTLD_PRIVATE_ERRNO
92 # define SYSCALL_ERROR_HANDLER \
93 0: SETUP_PIC_REG(o2,g1) \
94 sethi %hi(rtld_errno), %g1; \
95 or %g1, %lo(rtld_errno), %g1; \
96 ld [%o2 + %g1], %g1; \
97 st %o0, [%g1]; \
98 jmp %o7 + 8; \
99 mov -1, %o0;
100 # elif defined _LIBC_REENTRANT
102 # if USE___THREAD
103 # ifndef NOT_IN_libc
104 # define SYSCALL_ERROR_ERRNO __libc_errno
105 # else
106 # define SYSCALL_ERROR_ERRNO errno
107 # endif
108 # define SYSCALL_ERROR_HANDLER \
109 0: SETUP_PIC_REG(o2,g1) \
110 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
111 add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
112 ld [%o2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO); \
113 st %o0, [%g7 + %g1]; \
114 jmp %o7 + 8; \
115 mov -1, %o0;
116 # else
117 # define SYSCALL_ERROR_HANDLER \
118 0: save %sp, -96, %sp; \
119 cfi_def_cfa_register(%fp); \
120 cfi_window_save; \
121 cfi_register (%o7, %i7); \
122 call __errno_location; \
123 nop; \
124 st %i0, [%o0]; \
125 jmp %i7 + 8; \
126 restore %g0, -1, %o0;
127 # endif
128 # else
129 # define SYSCALL_ERROR_HANDLER \
130 0: SETUP_PIC_REG(o2,g1) \
131 sethi %hi(errno), %g1; \
132 or %g1, %lo(errno), %g1; \
133 ld [%o2 + %g1], %g1; \
134 st %o0, [%g1]; \
135 jmp %o7 + 8; \
136 mov -1, %o0;
137 # endif /* _LIBC_REENTRANT */
138 #endif /* PIC */
141 #else /* __ASSEMBLER__ */
143 #define __SYSCALL_STRING \
144 "ta 0x10;" \
145 "bcc 1f;" \
146 " mov 0, %%g1;" \
147 "sub %%g0, %%o0, %%o0;" \
148 "mov 1, %%g1;" \
149 "1:"
151 #define __SYSCALL_CLOBBERS \
152 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
153 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
154 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
155 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
156 "cc", "memory"
158 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
160 #endif /* __ASSEMBLER__ */
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 ld [%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/sparc/sysdep.h */