2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc32 / sysdep.h
blob3cb0a48c9503241529d8d88fc6505f0d6964c3a3
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 /* If the offset to __syscall_error fits into a signed 22-bit
61 * immediate branch offset, the linker will relax the call into
62 * a normal branch.
64 #define PSEUDO(name, syscall_name, args) \
65 .text; \
66 .globl __syscall_error; \
67 ENTRY(name); \
68 LOADSYSCALL(syscall_name); \
69 ta 0x10; \
70 bcc 1f; \
71 mov %o7, %g1; \
72 call __syscall_error; \
73 mov %g1, %o7; \
76 #define PSEUDO_NOERRNO(name, syscall_name, args)\
77 .text; \
78 ENTRY(name); \
79 LOADSYSCALL(syscall_name); \
80 ta 0x10;
82 #define PSEUDO_ERRVAL(name, syscall_name, args) \
83 .text; \
84 ENTRY(name); \
85 LOADSYSCALL(syscall_name); \
86 ta 0x10;
88 #define PSEUDO_END(name) \
89 END(name)
91 #else /* __ASSEMBLER__ */
93 #if defined SHARED && defined DO_VERSIONING && defined PIC \
94 && !defined NO_HIDDEN && !defined NOT_IN_libc
95 # define CALL_ERRNO_LOCATION "call __GI___errno_location;"
96 #else
97 # define CALL_ERRNO_LOCATION "call __errno_location;"
98 #endif
100 #define __SYSCALL_STRING \
101 "ta 0x10;" \
102 "bcs 2f;" \
103 " nop;" \
104 "1:" \
105 ".subsection 2;" \
106 "2:" \
107 "save %%sp, -192, %%sp;" \
108 CALL_ERRNO_LOCATION \
109 " nop;" \
110 "st %%i0,[%%o0];" \
111 "ba 1b;" \
112 " restore %%g0, -1, %%o0;" \
113 ".previous;"
115 #define __CLONE_SYSCALL_STRING \
116 "ta 0x10;" \
117 "bcs 2f;" \
118 " sub %%o1, 1, %%o1;" \
119 "and %%o0, %%o1, %%o0;" \
120 "1:" \
121 ".subsection 2;" \
122 "2:" \
123 "save %%sp, -192, %%sp;" \
124 CALL_ERRNO_LOCATION \
125 " nop;" \
126 "st %%i0, [%%o0];" \
127 "ba 1b;" \
128 " restore %%g0, -1, %%o0;" \
129 ".previous;"
131 #define __INTERNAL_SYSCALL_STRING \
132 "ta 0x10;" \
133 "bcs,a 1f;" \
134 " sub %%g0, %%o0, %%o0;" \
135 "1:"
137 #define __SYSCALL_CLOBBERS \
138 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
139 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
140 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
141 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
142 "cc", "memory"
144 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
146 #endif /* __ASSEMBLER__ */
148 /* Pointer mangling support. */
149 #if defined NOT_IN_libc && defined IS_IN_rtld
150 /* We cannot use the thread descriptor because in ld.so we use setjmp
151 earlier than the descriptor is initialized. */
152 #else
153 # ifdef __ASSEMBLER__
154 # define PTR_MANGLE(dreg, reg, tmpreg) \
155 ld [%g7 + POINTER_GUARD], tmpreg; \
156 xor reg, tmpreg, dreg
157 # define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
158 # define PTR_MANGLE2(dreg, reg, tmpreg) \
159 xor reg, tmpreg, dreg
160 # define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
161 # else
162 # define PTR_MANGLE(var) \
163 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
164 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
165 # endif
166 #endif
168 #endif /* linux/sparc/sysdep.h */