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