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
21 #ifndef _LINUX_SPARC32_SYSDEP_H
22 #define _LINUX_SPARC32_SYSDEP_H 1
24 #include <sysdeps/unix/sparc/sysdep.h>
27 # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
32 #define SYS_ify(syscall_name) __NR_##syscall_name
36 #define LOADSYSCALL(x) mov __NR_##x, %g1
38 /* Linux/SPARC uses a different trap number */
49 .global C_SYMBOL_NAME(name); \
50 .type name, @function; \
58 #define LOC(name) .L##name
60 #define PSEUDO(name, syscall_name, args) \
63 LOADSYSCALL(syscall_name); \
67 SYSCALL_ERROR_HANDLER \
70 #define PSEUDO_NOERRNO(name, syscall_name, args)\
73 LOADSYSCALL(syscall_name); \
76 #define PSEUDO_ERRVAL(name, syscall_name, args) \
79 LOADSYSCALL(syscall_name); \
82 #define PSEUDO_END(name) \
86 # define SYSCALL_ERROR_HANDLER \
88 call __syscall_error; \
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; \
100 # elif defined _LIBC_REENTRANT
104 # define SYSCALL_ERROR_ERRNO __libc_errno
106 # define SYSCALL_ERROR_ERRNO errno
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]; \
117 # define SYSCALL_ERROR_HANDLER \
118 0: save %sp, -96, %sp; \
119 cfi_def_cfa_register(%fp); \
121 cfi_register (%o7, %i7); \
122 call __errno_location; \
126 restore %g0, -1, %o0;
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; \
137 # endif /* _LIBC_REENTRANT */
141 #else /* __ASSEMBLER__ */
143 #define __SYSCALL_STRING \
147 "sub %%g0, %%o0, %%o0;" \
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", \
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. */
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)
176 # define PTR_MANGLE(var) \
177 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
178 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
182 #endif /* linux/sparc/sysdep.h */