1 /* Copyright (C) 1997-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, January 1997.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _LINUX_SPARC32_SYSDEP_H
20 #define _LINUX_SPARC32_SYSDEP_H 1
22 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
25 # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
30 #define SYS_ify(syscall_name) __NR_##syscall_name
34 #define LOADSYSCALL(x) mov __NR_##x, %g1
37 #define PSEUDO(name, syscall_name, args) \
40 LOADSYSCALL(syscall_name); \
44 SYSCALL_ERROR_HANDLER \
48 #define PSEUDO_NOERRNO(name, syscall_name, args)\
51 LOADSYSCALL(syscall_name); \
55 #define PSEUDO_ERRVAL(name, syscall_name, args) \
58 LOADSYSCALL(syscall_name); \
62 #define PSEUDO_END(name) \
66 # define SYSCALL_ERROR_HANDLER \
68 call __syscall_error; \
71 # if RTLD_PRIVATE_ERRNO
72 # define SYSCALL_ERROR_HANDLER \
73 0: SETUP_PIC_REG_LEAF(o2,g1) \
74 sethi %gdop_hix22(rtld_errno), %g1; \
75 xor %g1, %gdop_lox10(rtld_errno), %g1;\
76 ld [%o2 + %g1], %g1, %gdop(rtld_errno); \
80 # elif defined _LIBC_REENTRANT
83 # define SYSCALL_ERROR_ERRNO __libc_errno
85 # define SYSCALL_ERROR_ERRNO errno
87 # define SYSCALL_ERROR_HANDLER \
88 0: SETUP_PIC_REG_LEAF(o2,g1) \
89 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
90 add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
91 ld [%o2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO); \
92 st %o0, [%g7 + %g1]; \
96 # define SYSCALL_ERROR_HANDLER \
97 0: SETUP_PIC_REG_LEAF(o2,g1) \
98 sethi %gdop_hix22(errno), %g1;\
99 xor %g1, %gdop_lox10(errno), %g1;\
100 ld [%o2 + %g1], %g1, %gdop(errno);\
104 # endif /* _LIBC_REENTRANT */
108 #else /* __ASSEMBLER__ */
110 #define __SYSCALL_STRING \
114 "sub %%g0, %%o0, %%o0;" \
118 #define __SYSCALL_CLOBBERS \
119 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
120 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
121 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
122 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
125 #endif /* __ASSEMBLER__ */
127 /* Pointer mangling support. */
129 /* We cannot use the thread descriptor because in ld.so we use setjmp
130 earlier than the descriptor is initialized. */
132 # ifdef __ASSEMBLER__
133 # define PTR_MANGLE(dreg, reg, tmpreg) \
134 ld [%g7 + POINTER_GUARD], tmpreg; \
135 xor reg, tmpreg, dreg
136 # define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
137 # define PTR_MANGLE2(dreg, reg, tmpreg) \
138 xor reg, tmpreg, dreg
139 # define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
141 # define PTR_MANGLE(var) \
142 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
143 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
147 #endif /* linux/sparc/sysdep.h */