Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc32 / sysdep.h
blob8b0d0807f4d3b2f2a28bd612621612ea0b405346
1 /* Copyright (C) 1997-2014 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>
24 #ifdef IS_IN_rtld
25 # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
26 #endif
27 #include <tls.h>
29 #undef SYS_ify
30 #define SYS_ify(syscall_name) __NR_##syscall_name
32 #ifdef __ASSEMBLER__
34 #define LOADSYSCALL(x) mov __NR_##x, %g1
36 #undef PSEUDO
37 #define PSEUDO(name, syscall_name, args) \
38 .text; \
39 ENTRY(name); \
40 LOADSYSCALL(syscall_name); \
41 ta 0x10; \
42 bcc 1f; \
43 nop; \
44 SYSCALL_ERROR_HANDLER \
47 #undef PSEUDO_NOERRNO
48 #define PSEUDO_NOERRNO(name, syscall_name, args)\
49 .text; \
50 ENTRY(name); \
51 LOADSYSCALL(syscall_name); \
52 ta 0x10;
54 #undef PSEUDO_ERRVAL
55 #define PSEUDO_ERRVAL(name, syscall_name, args) \
56 .text; \
57 ENTRY(name); \
58 LOADSYSCALL(syscall_name); \
59 ta 0x10;
61 #undef PSEUDO_END
62 #define PSEUDO_END(name) \
63 END(name)
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
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); \
77 st %o0, [%g1]; \
78 jmp %o7 + 8; \
79 mov -1, %o0;
80 # elif defined _LIBC_REENTRANT
82 # ifndef NOT_IN_libc
83 # define SYSCALL_ERROR_ERRNO __libc_errno
84 # else
85 # define SYSCALL_ERROR_ERRNO errno
86 # endif
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]; \
93 jmp %o7 + 8; \
94 mov -1, %o0;
95 # else
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);\
101 st %o0, [%g1]; \
102 jmp %o7 + 8; \
103 mov -1, %o0;
104 # endif /* _LIBC_REENTRANT */
105 #endif /* PIC */
108 #else /* __ASSEMBLER__ */
110 #define __SYSCALL_STRING \
111 "ta 0x10;" \
112 "bcc 1f;" \
113 " mov 0, %%g1;" \
114 "sub %%g0, %%o0, %%o0;" \
115 "mov 1, %%g1;" \
116 "1:"
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", \
123 "cc", "memory"
125 #endif /* __ASSEMBLER__ */
127 /* Pointer mangling support. */
128 #if defined NOT_IN_libc && defined IS_IN_rtld
129 /* We cannot use the thread descriptor because in ld.so we use setjmp
130 earlier than the descriptor is initialized. */
131 #else
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)
140 # else
141 # define PTR_MANGLE(var) \
142 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
143 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
144 # endif
145 #endif
147 #endif /* linux/sparc/sysdep.h */