]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc64 / sysdep.h
CommitLineData
2b778ceb 1/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
5ae3e846
UD
2 This file is part of the GNU C Library.
3 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
5ae3e846
UD
9
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
41bdb6e2 13 Lesser General Public License for more details.
5ae3e846 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
5ae3e846
UD
18
19#ifndef _LINUX_SPARC64_SYSDEP_H
20#define _LINUX_SPARC64_SYSDEP_H 1
21
aab39a09 22#include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
5ae3e846 23
a3848485 24#if IS_IN (rtld)
369b849f
RM
25# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
26#endif
ced368f7 27#include <tls.h>
369b849f 28
5ae3e846
UD
29#undef SYS_ify
30#define SYS_ify(syscall_name) __NR_##syscall_name
31
66715f83 32#ifdef __ASSEMBLER__
5ae3e846 33
131fd126 34#define LOADSYSCALL(x) mov __NR_##x, %g1
5ae3e846 35
5ae3e846 36#undef PSEUDO
043cee37
RM
37#define PSEUDO(name, syscall_name, args) \
38 .text; \
043cee37
RM
39ENTRY(name); \
40 LOADSYSCALL(syscall_name); \
41 ta 0x6d; \
42 bcc,pt %xcc, 1f; \
3ba57516
DM
43 nop; \
44 SYSCALL_ERROR_HANDLER \
043cee37
RM
451:
46
aab39a09 47#undef PSEUDO_NOERRNO
043cee37
RM
48#define PSEUDO_NOERRNO(name, syscall_name, args)\
49 .text; \
50ENTRY(name); \
51 LOADSYSCALL(syscall_name); \
52 ta 0x6d;
53
aab39a09 54#undef PSEUDO_ERRVAL
043cee37
RM
55#define PSEUDO_ERRVAL(name, syscall_name, args) \
56 .text; \
57ENTRY(name); \
58 LOADSYSCALL(syscall_name); \
59 ta 0x6d;
60
aab39a09 61#undef PSEUDO_END
043cee37
RM
62#define PSEUDO_END(name) \
63 END(name)
a334319f 64
3ba57516
DM
65#ifndef PIC
66# define SYSCALL_ERROR_HANDLER \
67 mov %o7, %g1; \
68 call __syscall_error; \
69 mov %g1, %o7;
70#else
71# if RTLD_PRIVATE_ERRNO
53362a4b 72# define SYSCALL_ERROR_HANDLER \
3d2b3019
DM
730: SETUP_PIC_REG_LEAF(o2,g1) \
74 sethi %gdop_hix22(rtld_errno), %g1; \
75 xor %g1, %gdop_lox10(rtld_errno), %g1;\
76 ldx [%o2 + %g1], %g1, %gdop(rtld_errno); \
77 st %o0, [%g1]; \
78 jmp %o7 + 8; \
79 mov -1, %o0;
3ba57516
DM
80# elif defined _LIBC_REENTRANT
81
4f41c682 82# if IS_IN (libc)
d063d164
UD
83# define SYSCALL_ERROR_ERRNO __libc_errno
84# else
85# define SYSCALL_ERROR_ERRNO errno
86# endif
dd54084d
DM
87# define SYSCALL_ERROR_HANDLER \
880: SETUP_PIC_REG_LEAF(o2,g1) \
3ba57516
DM
89 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
90 add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
91 ldx [%o2 + %g1], %g1, %tie_ldx(SYSCALL_ERROR_ERRNO);\
d063d164
UD
92 st %o0, [%g7 + %g1]; \
93 jmp %o7 + 8; \
3ba57516 94 mov -1, %o0;
3ba57516 95# else
53362a4b 96# define SYSCALL_ERROR_HANDLER \
3d2b3019
DM
970: SETUP_PIC_REG_LEAF(o2,g1) \
98 sethi %gdop_hix22(errno), %g1;\
99 xor %g1, %gdop_lox10(errno), %g1;\
100 ldx [%o2 + %g1], %g1, %gdop(errno);\
101 st %o0, [%g1]; \
102 jmp %o7 + 8; \
103 mov -1, %o0;
3ba57516
DM
104# endif /* _LIBC_REENTRANT */
105#endif /* PIC */
5ae3e846 106
4d76a0ec
UD
107#else /* __ASSEMBLER__ */
108
109#define __SYSCALL_STRING \
110 "ta 0x6d;" \
111 "bcc,pt %%xcc, 1f;" \
86c5d2cf 112 " nop;" \
3ba57516 113 "sub %%g0, %%o0, %%o0;" \
369b849f
RM
114 "1:"
115
86746abb 116#define __SYSCALL_CLOBBERS \
4d76a0ec
UD
117 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
118 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
119 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
120 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
121 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \
122 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \
123 "cc", "memory"
124
66715f83 125#endif /* __ASSEMBLER__ */
5ae3e846 126
9bd9c815 127/* This is the offset from the %sp to the backing store above the
5ae3e846
UD
128 register windows. So if you poke stack memory directly you add this. */
129#define STACK_BIAS 2047
130
305bb37e 131/* Pointer mangling support. */
a3848485 132#if IS_IN (rtld)
305bb37e
UD
133/* We cannot use the thread descriptor because in ld.so we use setjmp
134 earlier than the descriptor is initialized. */
135#else
136# ifdef __ASSEMBLER__
137# define PTR_MANGLE(dreg, reg, tmpreg) \
138 ldx [%g7 + POINTER_GUARD], tmpreg; \
139 xor reg, tmpreg, dreg
140# define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
141# define PTR_MANGLE2(dreg, reg, tmpreg) \
142 xor reg, tmpreg, dreg
143# define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
144# else
145# define PTR_MANGLE(var) \
146 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
147# define PTR_DEMANGLE(var) PTR_MANGLE (var)
148# endif
149#endif
150
5ae3e846 151#endif /* linux/sparc64/sysdep.h */