1 /* Copyright (C) 1997, 2002, 2003, 2004 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
20 #ifndef _LINUX_SPARC32_SYSDEP_H
21 #define _LINUX_SPARC32_SYSDEP_H 1
23 #include <sysdeps/unix/sparc/sysdep.h>
26 # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
31 #define SYS_ify(syscall_name) __NR_##syscall_name
35 #define LOADSYSCALL(x) mov __NR_##x, %g1
37 /* Linux/SPARC uses a different trap number */
46 .global C_SYMBOL_NAME(name); \
54 #define LOC(name) .L##name
56 #ifdef LINKER_HANDLES_R_SPARC_WDISP22
57 /* Unfortunately, we cannot do this yet. Linker doesn't seem to
58 handle R_SPARC_WDISP22 against non-STB_LOCAL symbols properly . */
59 # define SYSCALL_ERROR_HANDLER_ENTRY(handler) \
60 .section .gnu.linkonce.t.handler,"ax",@progbits; \
63 .type handler,@function; \
66 # define SYSCALL_ERROR_HANDLER_ENTRY(handler) \
71 #if RTLD_PRIVATE_ERRNO
72 # define SYSCALL_ERROR_HANDLER \
73 .section .gnu.linkonce.t.__sparc_get_pic_l7,"ax",@progbits; \
74 .globl __sparc_get_pic_l7; \
75 .hidden __sparc_get_pic_l7; \
76 .type __sparc_get_pic_l7,@function; \
81 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler) \
83 sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7; \
84 call __sparc_get_pic_l7; \
85 add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7; \
86 ld [%l7 + errno], %l0; \
89 restore %g0, -1, %o0; \
93 # define SYSCALL_ERROR_ERRNO __libc_errno
95 # define SYSCALL_ERROR_ERRNO errno
98 # define SYSCALL_ERROR_HANDLER \
99 .section .gnu.linkonce.t.__sparc_get_pic_l7,"ax",@progbits; \
100 .globl __sparc_get_pic_l7; \
101 .hidden __sparc_get_pic_l7; \
102 .type __sparc_get_pic_l7,@function; \
103 __sparc_get_pic_l7: \
107 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler) \
109 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %l1; \
110 sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7; \
111 call __sparc_get_pic_l7; \
112 add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7; \
113 add %l1, %tie_lo10(SYSCALL_ERROR_ERRNO), %l1; \
114 ld [%l7 + %l1], %l1, %tie_ld(SYSCALL_ERROR_ERRNO); \
115 st %i0, [%g7 + %l1], %tie_add(SYSCALL_ERROR_ERRNO); \
117 restore %g0, -1, %o0; \
120 # define SYSCALL_ERROR_HANDLER \
121 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler) \
122 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \
123 sethi %hi(_GLOBAL_OFFSET_TABLE_), %g2; \
124 add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \
125 add %g2, %lo(_GLOBAL_OFFSET_TABLE_), %g2; \
126 ld [%g2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO); \
127 st %o0, [%g7 + %g1], %tie_add(SYSCALL_ERROR_ERRNO); \
133 # define SYSCALL_ERROR_HANDLER \
134 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler) \
135 .global __errno_location; \
136 .type __errno_location,@function; \
137 save %sp, -96, %sp; \
138 call __errno_location; \
142 restore %g0, -1, %o0; \
146 #define PSEUDO(name, syscall_name, args) \
149 LOADSYSCALL(syscall_name); \
151 bcs __syscall_error_handler; \
153 SYSCALL_ERROR_HANDLER
155 #define PSEUDO_NOERRNO(name, syscall_name, args) \
158 LOADSYSCALL(syscall_name); \
161 #define PSEUDO_ERRVAL(name, syscall_name, args) \
164 LOADSYSCALL(syscall_name); \
167 #else /* __ASSEMBLER__ */
169 #define __SYSCALL_STRING \
176 "save %%sp, -192, %%sp;" \
177 "call __errno_location;" \
181 " restore %%g0, -1, %%o0;" \
184 #define __CLONE_SYSCALL_STRING \
187 " sub %%o1, 1, %%o1;" \
188 "and %%o0, %%o1, %%o0;" \
192 "save %%sp, -192, %%sp;" \
193 "call __errno_location;" \
197 " restore %%g0, -1, %%o0;" \
200 #define __INTERNAL_SYSCALL_STRING \
203 " sub %%g0, %%o0, %%o0;" \
206 #define __SYSCALL_CLOBBERS "g2", "g3", "g4", "g5", "g6", \
207 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
208 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
209 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
210 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
213 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
215 #endif /* __ASSEMBLER__ */
217 #endif /* linux/sparc/sysdep.h */