Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sysdep.h
blob8cfc9c562b2e168cb533f4bedef26f018936f5e4
1 /* Copyright (C) 2000-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
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_SPARC_SYSDEP_H
20 #define _LINUX_SPARC_SYSDEP_H 1
22 #include <sysdeps/unix/sysdep.h>
23 #include <sysdeps/sparc/sysdep.h>
25 #ifdef __ASSEMBLER__
27 #define ret retl; nop
28 #define ret_NOERRNO retl; nop
29 #define ret_ERRVAL retl; nop
30 #define r0 %o0
31 #define r1 %o1
32 #define MOVE(x,y) mov x, y
34 #else /* __ASSEMBLER__ */
36 #undef INLINE_SYSCALL
37 #define INLINE_SYSCALL(name, nr, args...) \
38 ({ INTERNAL_SYSCALL_DECL(err); \
39 unsigned long resultvar = INTERNAL_SYSCALL(name, err, nr, args);\
40 if (INTERNAL_SYSCALL_ERROR_P (resultvar, err)) \
41 { \
42 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err)); \
43 resultvar = (unsigned long) -1; \
44 } \
45 (long) resultvar; \
48 #undef INTERNAL_SYSCALL_DECL
49 #define INTERNAL_SYSCALL_DECL(err) \
50 register long err __asm__("g1");
52 #undef INTERNAL_SYSCALL
53 #define INTERNAL_SYSCALL(name, err, nr, args...) \
54 inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
56 #undef INTERNAL_SYSCALL_NCS
57 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
58 inline_syscall##nr(__SYSCALL_STRING, err, name, args)
60 #undef INTERNAL_SYSCALL_ERROR_P
61 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
62 ((void) (val), __builtin_expect((err) != 0, 0))
64 #undef INTERNAL_SYSCALL_ERRNO
65 #define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
67 #define inline_syscall0(string,err,name,dummy...) \
68 ({ \
69 register long __o0 __asm__ ("o0"); \
70 err = name; \
71 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
72 "0" (err) : \
73 __SYSCALL_CLOBBERS); \
74 __o0; \
77 #define inline_syscall1(string,err,name,arg1) \
78 ({ \
79 register long __o0 __asm__ ("o0") = (long)(arg1); \
80 err = name; \
81 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
82 "0" (err), "1" (__o0) : \
83 __SYSCALL_CLOBBERS); \
84 __o0; \
87 #define inline_syscall2(string,err,name,arg1,arg2) \
88 ({ \
89 register long __o0 __asm__ ("o0") = (long)(arg1); \
90 register long __o1 __asm__ ("o1") = (long)(arg2); \
91 err = name; \
92 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
93 "0" (err), "1" (__o0), "r" (__o1) : \
94 __SYSCALL_CLOBBERS); \
95 __o0; \
98 #define inline_syscall3(string,err,name,arg1,arg2,arg3) \
99 ({ \
100 register long __o0 __asm__ ("o0") = (long)(arg1); \
101 register long __o1 __asm__ ("o1") = (long)(arg2); \
102 register long __o2 __asm__ ("o2") = (long)(arg3); \
103 err = name; \
104 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
105 "0" (err), "1" (__o0), "r" (__o1), \
106 "r" (__o2) : \
107 __SYSCALL_CLOBBERS); \
108 __o0; \
111 #define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4) \
112 ({ \
113 register long __o0 __asm__ ("o0") = (long)(arg1); \
114 register long __o1 __asm__ ("o1") = (long)(arg2); \
115 register long __o2 __asm__ ("o2") = (long)(arg3); \
116 register long __o3 __asm__ ("o3") = (long)(arg4); \
117 err = name; \
118 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
119 "0" (err), "1" (__o0), "r" (__o1), \
120 "r" (__o2), "r" (__o3) : \
121 __SYSCALL_CLOBBERS); \
122 __o0; \
125 #define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5) \
126 ({ \
127 register long __o0 __asm__ ("o0") = (long)(arg1); \
128 register long __o1 __asm__ ("o1") = (long)(arg2); \
129 register long __o2 __asm__ ("o2") = (long)(arg3); \
130 register long __o3 __asm__ ("o3") = (long)(arg4); \
131 register long __o4 __asm__ ("o4") = (long)(arg5); \
132 err = name; \
133 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
134 "0" (err), "1" (__o0), "r" (__o1), \
135 "r" (__o2), "r" (__o3), "r" (__o4) : \
136 __SYSCALL_CLOBBERS); \
137 __o0; \
140 #define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6) \
141 ({ \
142 register long __o0 __asm__ ("o0") = (long)(arg1); \
143 register long __o1 __asm__ ("o1") = (long)(arg2); \
144 register long __o2 __asm__ ("o2") = (long)(arg3); \
145 register long __o3 __asm__ ("o3") = (long)(arg4); \
146 register long __o4 __asm__ ("o4") = (long)(arg5); \
147 register long __o5 __asm__ ("o5") = (long)(arg6); \
148 err = name; \
149 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
150 "0" (err), "1" (__o0), "r" (__o1), \
151 "r" (__o2), "r" (__o3), "r" (__o4), \
152 "r" (__o5) : \
153 __SYSCALL_CLOBBERS); \
154 __o0; \
157 #define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \
158 ({ \
159 register long __o0 __asm__ ("o0") = (long)(arg1); \
160 register long __o1 __asm__ ("o1") = (long)(arg2); \
161 register long __o2 __asm__ ("o2") = (long)(arg3); \
162 register long __o3 __asm__ ("o3") = (long)(arg4); \
163 register long __o4 __asm__ ("o4") = (long)(arg5); \
164 register long __g1 __asm__ ("g1") = __NR_clone; \
165 __asm __volatile (__SYSCALL_STRING : \
166 "=r" (__g1), "=r" (__o0), "=r" (__o1) : \
167 "0" (__g1), "1" (__o0), "2" (__o1), \
168 "r" (__o2), "r" (__o3), "r" (__o4) : \
169 __SYSCALL_CLOBBERS); \
170 if (INTERNAL_SYSCALL_ERROR_P (__o0, __g1)) \
172 __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1)); \
173 __o0 = -1L; \
175 else \
177 __o0 &= (__o1 - 1); \
179 __o0; \
182 #endif /* __ASSEMBLER__ */
184 #endif /* _LINUX_SPARC_SYSDEP_H */