blob: 0051114c63c7004f404b3f6d46f47bf3593c2971 [file] [log] [blame]
Mikael Starvik51533b62005-07-27 11:44:44 -07001#ifndef _ASM_CRIS_ARCH_UNISTD_H_
2#define _ASM_CRIS_ARCH_UNISTD_H_
3
4/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
5/*
6 * Don't remove the .ifnc tests; they are an insurance against
7 * any hard-to-spot gcc register allocation bugs.
8 */
9#define _syscall0(type,name) \
10type name(void) \
11{ \
12 register long __a __asm__ ("r10"); \
13 register long __n_ __asm__ ("r9") = (__NR_##name); \
14 __asm__ __volatile__ (".ifnc %0%1,$r10$r9\n\t" \
15 ".err\n\t" \
16 ".endif\n\t" \
17 "break 13" \
18 : "=r" (__a) \
Jesper Nilsson57e6f962008-01-28 18:11:29 +010019 : "r" (__n_) \
20 : "memory"); \
Mikael Starvik51533b62005-07-27 11:44:44 -070021 if (__a >= 0) \
22 return (type) __a; \
23 errno = -__a; \
24 return (type) -1; \
25}
26
27#define _syscall1(type,name,type1,arg1) \
28type name(type1 arg1) \
29{ \
30 register long __a __asm__ ("r10") = (long) arg1; \
31 register long __n_ __asm__ ("r9") = (__NR_##name); \
32 __asm__ __volatile__ (".ifnc %0%1,$r10$r9\n\t" \
33 ".err\n\t" \
34 ".endif\n\t" \
35 "break 13" \
36 : "=r" (__a) \
Jesper Nilsson57e6f962008-01-28 18:11:29 +010037 : "r" (__n_), "0" (__a) \
38 : "memory"); \
Mikael Starvik51533b62005-07-27 11:44:44 -070039 if (__a >= 0) \
40 return (type) __a; \
41 errno = -__a; \
42 return (type) -1; \
43}
44
45#define _syscall2(type,name,type1,arg1,type2,arg2) \
46type name(type1 arg1,type2 arg2) \
47{ \
48 register long __a __asm__ ("r10") = (long) arg1; \
49 register long __b __asm__ ("r11") = (long) arg2; \
50 register long __n_ __asm__ ("r9") = (__NR_##name); \
51 __asm__ __volatile__ (".ifnc %0%1%3,$r10$r9$r11\n\t" \
52 ".err\n\t" \
53 ".endif\n\t" \
54 "break 13" \
55 : "=r" (__a) \
Jesper Nilsson57e6f962008-01-28 18:11:29 +010056 : "r" (__n_), "0" (__a), "r" (__b) \
57 : "memory"); \
Mikael Starvik51533b62005-07-27 11:44:44 -070058 if (__a >= 0) \
59 return (type) __a; \
60 errno = -__a; \
61 return (type) -1; \
62}
63
64#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
65type name(type1 arg1,type2 arg2,type3 arg3) \
66{ \
67 register long __a __asm__ ("r10") = (long) arg1; \
68 register long __b __asm__ ("r11") = (long) arg2; \
69 register long __c __asm__ ("r12") = (long) arg3; \
70 register long __n_ __asm__ ("r9") = (__NR_##name); \
71 __asm__ __volatile__ (".ifnc %0%1%3%4,$r10$r9$r11$r12\n\t" \
72 ".err\n\t" \
73 ".endif\n\t" \
74 "break 13" \
75 : "=r" (__a) \
Jesper Nilsson57e6f962008-01-28 18:11:29 +010076 : "r" (__n_), "0" (__a), "r" (__b), "r" (__c) \
77 : "memory"); \
Mikael Starvik51533b62005-07-27 11:44:44 -070078 if (__a >= 0) \
79 return (type) __a; \
80 errno = -__a; \
81 return (type) -1; \
82}
83
84#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
85type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
86{ \
87 register long __a __asm__ ("r10") = (long) arg1; \
88 register long __b __asm__ ("r11") = (long) arg2; \
89 register long __c __asm__ ("r12") = (long) arg3; \
90 register long __d __asm__ ("r13") = (long) arg4; \
91 register long __n_ __asm__ ("r9") = (__NR_##name); \
92 __asm__ __volatile__ (".ifnc %0%1%3%4%5,$r10$r9$r11$r12$r13\n\t" \
93 ".err\n\t" \
94 ".endif\n\t" \
95 "break 13" \
96 : "=r" (__a) \
97 : "r" (__n_), "0" (__a), "r" (__b), \
Jesper Nilsson57e6f962008-01-28 18:11:29 +010098 "r" (__c), "r" (__d)\
99 : "memory"); \
Mikael Starvik51533b62005-07-27 11:44:44 -0700100 if (__a >= 0) \
101 return (type) __a; \
102 errno = -__a; \
103 return (type) -1; \
104}
105
106#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
107 type5,arg5) \
108type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
109{ \
110 register long __a __asm__ ("r10") = (long) arg1; \
111 register long __b __asm__ ("r11") = (long) arg2; \
112 register long __c __asm__ ("r12") = (long) arg3; \
113 register long __d __asm__ ("r13") = (long) arg4; \
114 register long __e __asm__ ("mof") = (long) arg5; \
115 register long __n_ __asm__ ("r9") = (__NR_##name); \
116 __asm__ __volatile__ (".ifnc %0%1%3%4%5%6,$r10$r9$r11$r12$r13$mof\n\t" \
117 ".err\n\t" \
118 ".endif\n\t" \
119 "break 13" \
120 : "=r" (__a) \
121 : "r" (__n_), "0" (__a), "r" (__b), \
Jesper Nilsson57e6f962008-01-28 18:11:29 +0100122 "r" (__c), "r" (__d), "h" (__e) \
123 : "memory"); \
Mikael Starvik51533b62005-07-27 11:44:44 -0700124 if (__a >= 0) \
125 return (type) __a; \
126 errno = -__a; \
127 return (type) -1; \
128}
129
130#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
131 type5,arg5,type6,arg6) \
132type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
133{ \
134 register long __a __asm__ ("r10") = (long) arg1; \
135 register long __b __asm__ ("r11") = (long) arg2; \
136 register long __c __asm__ ("r12") = (long) arg3; \
137 register long __d __asm__ ("r13") = (long) arg4; \
138 register long __e __asm__ ("mof") = (long) arg5; \
139 register long __f __asm__ ("srp") = (long) arg6; \
140 register long __n_ __asm__ ("r9") = (__NR_##name); \
141 __asm__ __volatile__ (".ifnc %0%1%3%4%5%6%7,$r10$r9$r11$r12$r13$mof$srp\n\t" \
142 ".err\n\t" \
143 ".endif\n\t" \
144 "break 13" \
145 : "=r" (__a) \
146 : "r" (__n_), "0" (__a), "r" (__b), \
Jesper Nilsson57e6f962008-01-28 18:11:29 +0100147 "r" (__c), "r" (__d), "h" (__e), "x" (__f) \
148 : "memory"); \
Mikael Starvik51533b62005-07-27 11:44:44 -0700149 if (__a >= 0) \
150 return (type) __a; \
151 errno = -__a; \
152 return (type) -1; \
153}
154
155#endif