(INTERNAL_SYSCALL, INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO):
[kopensolaris-gnu/glibc.git] / sysdeps / unix / sysv / linux / sparc / sysdep.h
1 /* Copyright (C) 2000, 2002, 2003 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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #ifndef _LINUX_SPARC_SYSDEP_H
21 #define _LINUX_SPARC_SYSDEP_H 1
22
23 #undef INLINE_SYSCALL
24 #define INLINE_SYSCALL(name, nr, args...) \
25   inline_syscall##nr(__SYSCALL_STRING, name, args)
26
27 #undef INTERNAL_SYSCALL_DECL
28 #define INTERNAL_SYSCALL_DECL(err) do { } while (0)
29
30 #undef INTERNAL_SYSCALL
31 #define INTERNAL_SYSCALL(name, err, nr, args...) \
32   inline_syscall##nr(__INTERNAL_SYSCALL_STRING, name, args)
33
34 #undef INTERNAL_SYSCALL_ERROR_P
35 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
36   ((unsigned long) (val) >= -515L)
37
38 #undef INTERNAL_SYSCALL_ERRNO
39 #define INTERNAL_SYSCALL_ERRNO(val, err)        (-(val))
40
41 #define inline_syscall0(string,name,dummy...)                           \
42 ({                                                                      \
43         register long __o0 __asm__ ("o0");                              \
44         register long __g1 __asm__ ("g1") = __NR_##name;                \
45         __asm __volatile (string : "=r" (__g1), "=r" (__o0) :           \
46                           "0" (__g1) :                                  \
47                           __SYSCALL_CLOBBERS);                          \
48         __o0;                                                           \
49 })
50
51 #define inline_syscall1(string,name,arg1)                               \
52 ({                                                                      \
53         register long __o0 __asm__ ("o0") = (long)(arg1);               \
54         register long __g1 __asm__ ("g1") = __NR_##name;                \
55         __asm __volatile (string : "=r" (__g1), "=r" (__o0) :           \
56                           "0" (__g1), "1" (__o0) :                      \
57                           __SYSCALL_CLOBBERS);                          \
58         __o0;                                                           \
59 })
60
61 #define inline_syscall2(string,name,arg1,arg2)                          \
62 ({                                                                      \
63         register long __o0 __asm__ ("o0") = (long)(arg1);               \
64         register long __o1 __asm__ ("o1") = (long)(arg2);               \
65         register long __g1 __asm__ ("g1") = __NR_##name;                \
66         __asm __volatile (string : "=r" (__g1), "=r" (__o0) :           \
67                           "0" (__g1), "1" (__o0), "r" (__o1) :          \
68                           __SYSCALL_CLOBBERS);                          \
69         __o0;                                                           \
70 })
71
72 #define inline_syscall3(string,name,arg1,arg2,arg3)                     \
73 ({                                                                      \
74         register long __o0 __asm__ ("o0") = (long)(arg1);               \
75         register long __o1 __asm__ ("o1") = (long)(arg2);               \
76         register long __o2 __asm__ ("o2") = (long)(arg3);               \
77         register long __g1 __asm__ ("g1") = __NR_##name;                \
78         __asm __volatile (string : "=r" (__g1), "=r" (__o0) :           \
79                           "0" (__g1), "1" (__o0), "r" (__o1),           \
80                           "r" (__o2) :                                  \
81                           __SYSCALL_CLOBBERS);                          \
82         __o0;                                                           \
83 })
84
85 #define inline_syscall4(string,name,arg1,arg2,arg3,arg4)                \
86 ({                                                                      \
87         register long __o0 __asm__ ("o0") = (long)(arg1);               \
88         register long __o1 __asm__ ("o1") = (long)(arg2);               \
89         register long __o2 __asm__ ("o2") = (long)(arg3);               \
90         register long __o3 __asm__ ("o3") = (long)(arg4);               \
91         register long __g1 __asm__ ("g1") = __NR_##name;                \
92         __asm __volatile (string : "=r" (__g1), "=r" (__o0) :           \
93                           "0" (__g1), "1" (__o0), "r" (__o1),           \
94                           "r" (__o2), "r" (__o3) :                      \
95                           __SYSCALL_CLOBBERS);                          \
96         __o0;                                                           \
97 })
98
99 #define inline_syscall5(string,name,arg1,arg2,arg3,arg4,arg5)           \
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         register long __o3 __asm__ ("o3") = (long)(arg4);               \
105         register long __o4 __asm__ ("o4") = (long)(arg5);               \
106         register long __g1 __asm__ ("g1") = __NR_##name;                \
107         __asm __volatile (string : "=r" (__g1), "=r" (__o0) :           \
108                           "0" (__g1), "1" (__o0), "r" (__o1),           \
109                           "r" (__o2), "r" (__o3), "r" (__o4) :          \
110                           __SYSCALL_CLOBBERS);                          \
111         __o0;                                                           \
112 })
113
114 #define inline_syscall6(string,name,arg1,arg2,arg3,arg4,arg5,arg6)      \
115 ({                                                                      \
116         register long __o0 __asm__ ("o0") = (long)(arg1);               \
117         register long __o1 __asm__ ("o1") = (long)(arg2);               \
118         register long __o2 __asm__ ("o2") = (long)(arg3);               \
119         register long __o3 __asm__ ("o3") = (long)(arg4);               \
120         register long __o4 __asm__ ("o4") = (long)(arg5);               \
121         register long __o5 __asm__ ("o5") = (long)(arg6);               \
122         register long __g1 __asm__ ("g1") = __NR_##name;                \
123         __asm __volatile (string : "=r" (__g1), "=r" (__o0) :           \
124                           "0" (__g1), "1" (__o0), "r" (__o1),           \
125                           "r" (__o2), "r" (__o3), "r" (__o4),           \
126                           "r" (__o5) :                                  \
127                           __SYSCALL_CLOBBERS);                          \
128         __o0;                                                           \
129 })
130
131 #endif /* _LINUX_SPARC_SYSDEP_H */