]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
1 /* Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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_MIPS_SYSDEP_H
21 #define _LINUX_MIPS_SYSDEP_H 1
23 /* There is some commonality. */
24 #include <sysdeps/unix/mips/mips64/n32/sysdep.h>
26 /* For Linux we can use the system call table in the header file
27 /usr/include/asm/unistd.h
28 of the kernel. But these symbols do not follow the SYS_* syntax
29 so we have to redefine the `SYS_ify' macro here. */
32 # define SYS_ify(syscall_name) __NR_##syscall_name
34 # define SYS_ify(syscall_name) __NR_/**/syscall_name
39 /* We don't want the label for the error handler to be visible in the symbol
40 table when we define it here. */
42 # define SYSCALL_ERROR_LABEL 99b
45 #else /* ! __ASSEMBLER__ */
47 /* Define a macro which expands into the inline wrapper code for a system
50 #define INLINE_SYSCALL(name, nr, args...) \
51 ({ INTERNAL_SYSCALL_DECL(err); \
52 long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
53 if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
55 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
60 #undef INTERNAL_SYSCALL_DECL
61 #define INTERNAL_SYSCALL_DECL(err) long err
63 #undef INTERNAL_SYSCALL_ERROR_P
64 #define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))
66 #undef INTERNAL_SYSCALL_ERRNO
67 #define INTERNAL_SYSCALL_ERRNO(val, err) (val)
69 #undef INTERNAL_SYSCALL
70 #define INTERNAL_SYSCALL(name, err, nr, args...) \
71 internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \
72 "i" (SYS_ify (name)), err, args)
74 #undef INTERNAL_SYSCALL_NCS
75 #define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
76 internal_syscall##nr (= number, , "r" (__v0), err, args)
78 #define internal_syscall0(ncs_init, cs_init, input, err, dummy...) \
83 register long long __v0 asm("$2") ncs_init; \
84 register long long __a3 asm("$7"); \
86 ".set\tnoreorder\n\t" \
90 : "=r" (__v0), "=r" (__a3) \
92 : __SYSCALL_CLOBBERS); \
99 #define internal_syscall1(ncs_init, cs_init, input, err, arg1) \
104 register long long __v0 asm("$2") ncs_init; \
105 register long long __a0 asm("$4") = (long long) arg1; \
106 register long long __a3 asm("$7"); \
108 ".set\tnoreorder\n\t" \
112 : "=r" (__v0), "=r" (__a3) \
113 : input, "r" (__a0) \
114 : __SYSCALL_CLOBBERS); \
116 _sys_result = __v0; \
121 #define internal_syscall2(ncs_init, cs_init, input, err, arg1, arg2) \
126 register long long __v0 asm("$2") ncs_init; \
127 register long long __a0 asm("$4") = (long long) arg1; \
128 register long long __a1 asm("$5") = (long long) arg2; \
129 register long long __a3 asm("$7"); \
131 ".set\tnoreorder\n\t" \
135 : "=r" (__v0), "=r" (__a3) \
136 : input, "r" (__a0), "r" (__a1) \
137 : __SYSCALL_CLOBBERS); \
139 _sys_result = __v0; \
144 #define internal_syscall3(ncs_init, cs_init, input, err, arg1, arg2, arg3) \
149 register long long __v0 asm("$2") ncs_init; \
150 register long long __a0 asm("$4") = (long long) arg1; \
151 register long long __a1 asm("$5") = (long long) arg2; \
152 register long long __a2 asm("$6") = (long long) arg3; \
153 register long long __a3 asm("$7"); \
155 ".set\tnoreorder\n\t" \
159 : "=r" (__v0), "=r" (__a3) \
160 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
161 : __SYSCALL_CLOBBERS); \
163 _sys_result = __v0; \
168 #define internal_syscall4(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4) \
173 register long long __v0 asm("$2") ncs_init; \
174 register long long __a0 asm("$4") = (long long) arg1; \
175 register long long __a1 asm("$5") = (long long) arg2; \
176 register long long __a2 asm("$6") = (long long) arg3; \
177 register long long __a3 asm("$7") = (long long) arg4; \
179 ".set\tnoreorder\n\t" \
183 : "=r" (__v0), "+r" (__a3) \
184 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
185 : __SYSCALL_CLOBBERS); \
187 _sys_result = __v0; \
192 #define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5) \
197 register long long __v0 asm("$2") ncs_init; \
198 register long long __a0 asm("$4") = (long long) arg1; \
199 register long long __a1 asm("$5") = (long long) arg2; \
200 register long long __a2 asm("$6") = (long long) arg3; \
201 register long long __a3 asm("$7") = (long long) arg4; \
202 register long long __a4 asm("$8") = (long long) arg5; \
204 ".set\tnoreorder\n\t" \
208 : "=r" (__v0), "+r" (__a3) \
209 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
210 : __SYSCALL_CLOBBERS); \
212 _sys_result = __v0; \
217 #define internal_syscall6(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6) \
222 register long long __v0 asm("$2") ncs_init; \
223 register long long __a0 asm("$4") = (long long) arg1; \
224 register long long __a1 asm("$5") = (long long) arg2; \
225 register long long __a2 asm("$6") = (long long) arg3; \
226 register long long __a3 asm("$7") = (long long) arg4; \
227 register long long __a4 asm("$8") = (long long) arg5; \
228 register long long __a5 asm("$9") = (long long) arg6; \
230 ".set\tnoreorder\n\t" \
234 : "=r" (__v0), "+r" (__a3) \
235 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \
237 : __SYSCALL_CLOBBERS); \
239 _sys_result = __v0; \
244 #define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
245 "$14", "$15", "$24", "$25", "memory"
246 #endif /* __ASSEMBLER__ */
248 #endif /* linux/mips/sysdep.h */