2.5-18.1
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc32 / sysdep.h
blobc808a97fc55bb6402944abf9165ef553cb85c323
1 /* Copyright (C) 1997, 2002, 2003, 2004, 2006 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _LINUX_SPARC32_SYSDEP_H
21 #define _LINUX_SPARC32_SYSDEP_H 1
23 #include <sysdeps/unix/sparc/sysdep.h>
25 #ifdef IS_IN_rtld
26 # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
27 #endif
28 #include <tls.h>
30 #undef SYS_ify
31 #define SYS_ify(syscall_name) __NR_##syscall_name
33 #ifdef __ASSEMBLER__
35 #define LOADSYSCALL(x) mov __NR_##x, %g1
37 /* Linux/SPARC uses a different trap number */
38 #undef PSEUDO
39 #undef PSEUDO_NOERRNO
40 #undef PSEUDO_ERRVAL
41 #undef PSEUDO_END
42 #undef ENTRY
43 #undef END
44 #undef LOC
46 #define ENTRY(name) \
47 .align 4; \
48 .global C_SYMBOL_NAME(name); \
49 .type name, @function; \
50 C_LABEL(name) \
51 cfi_startproc;
53 #define END(name) \
54 cfi_endproc; \
55 .size name, . - name
57 #define LOC(name) .L##name
59 /* If the offset to __syscall_error fits into a signed 22-bit
60 * immediate branch offset, the linker will relax the call into
61 * a normal branch.
63 #define PSEUDO(name, syscall_name, args) \
64 .text; \
65 .globl __syscall_error; \
66 ENTRY(name); \
67 LOADSYSCALL(syscall_name); \
68 ta 0x10; \
69 bcc 1f; \
70 mov %o7, %g1; \
71 call __syscall_error; \
72 mov %g1, %o7; \
75 #define PSEUDO_NOERRNO(name, syscall_name, args)\
76 .text; \
77 ENTRY(name); \
78 LOADSYSCALL(syscall_name); \
79 ta 0x10;
81 #define PSEUDO_ERRVAL(name, syscall_name, args) \
82 .text; \
83 ENTRY(name); \
84 LOADSYSCALL(syscall_name); \
85 ta 0x10;
87 #define PSEUDO_END(name) \
88 END(name)
90 #else /* __ASSEMBLER__ */
92 #define __SYSCALL_STRING \
93 "ta 0x10;" \
94 "bcs 2f;" \
95 " nop;" \
96 "1:" \
97 ".subsection 2;" \
98 "2:" \
99 "save %%sp, -192, %%sp;" \
100 "call __errno_location;" \
101 " nop;" \
102 "st %%i0,[%%o0];" \
103 "ba 1b;" \
104 " restore %%g0, -1, %%o0;" \
105 ".previous;"
107 #define __CLONE_SYSCALL_STRING \
108 "ta 0x10;" \
109 "bcs 2f;" \
110 " sub %%o1, 1, %%o1;" \
111 "and %%o0, %%o1, %%o0;" \
112 "1:" \
113 ".subsection 2;" \
114 "2:" \
115 "save %%sp, -192, %%sp;" \
116 "call __errno_location;" \
117 " nop;" \
118 "st %%i0, [%%o0];" \
119 "ba 1b;" \
120 " restore %%g0, -1, %%o0;" \
121 ".previous;"
123 #define __INTERNAL_SYSCALL_STRING \
124 "ta 0x10;" \
125 "bcs,a 1f;" \
126 " sub %%g0, %%o0, %%o0;" \
127 "1:"
129 #define __SYSCALL_CLOBBERS "g2", "g3", "g4", "g5", "g6", \
130 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
131 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
132 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
133 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
134 "cc", "memory"
136 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
138 #endif /* __ASSEMBLER__ */
140 /* Pointer mangling support. */
141 #if defined NOT_IN_libc && defined IS_IN_rtld
142 /* We cannot use the thread descriptor because in ld.so we use setjmp
143 earlier than the descriptor is initialized. */
144 #else
145 # ifdef __ASSEMBLER__
146 # define PTR_MANGLE(dreg, reg, tmpreg) \
147 ld [%g7 + POINTER_GUARD], tmpreg; \
148 xor reg, tmpreg, dreg
149 # define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
150 # define PTR_MANGLE2(dreg, reg, tmpreg) \
151 xor reg, tmpreg, dreg
152 # define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
153 # else
154 # define PTR_MANGLE(var) \
155 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
156 # define PTR_DEMANGLE(var) PTR_MANGLE (var)
157 # endif
158 #endif
160 #endif /* linux/sparc/sysdep.h */