Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / include / asm-cris / arch-v32 / unistd.h
blob0051114c63c7004f404b3f6d46f47bf3593c2971
1 #ifndef _ASM_CRIS_ARCH_UNISTD_H_
2 #define _ASM_CRIS_ARCH_UNISTD_H_
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) \
10 type 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) \
19 : "r" (__n_) \
20 : "memory"); \
21 if (__a >= 0) \
22 return (type) __a; \
23 errno = -__a; \
24 return (type) -1; \
27 #define _syscall1(type,name,type1,arg1) \
28 type 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) \
37 : "r" (__n_), "0" (__a) \
38 : "memory"); \
39 if (__a >= 0) \
40 return (type) __a; \
41 errno = -__a; \
42 return (type) -1; \
45 #define _syscall2(type,name,type1,arg1,type2,arg2) \
46 type 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) \
56 : "r" (__n_), "0" (__a), "r" (__b) \
57 : "memory"); \
58 if (__a >= 0) \
59 return (type) __a; \
60 errno = -__a; \
61 return (type) -1; \
64 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
65 type 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) \
76 : "r" (__n_), "0" (__a), "r" (__b), "r" (__c) \
77 : "memory"); \
78 if (__a >= 0) \
79 return (type) __a; \
80 errno = -__a; \
81 return (type) -1; \
84 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
85 type 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), \
98 "r" (__c), "r" (__d)\
99 : "memory"); \
100 if (__a >= 0) \
101 return (type) __a; \
102 errno = -__a; \
103 return (type) -1; \
106 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
107 type5,arg5) \
108 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
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), \
122 "r" (__c), "r" (__d), "h" (__e) \
123 : "memory"); \
124 if (__a >= 0) \
125 return (type) __a; \
126 errno = -__a; \
127 return (type) -1; \
130 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
131 type5,arg5,type6,arg6) \
132 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
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), \
147 "r" (__c), "r" (__d), "h" (__e), "x" (__f) \
148 : "memory"); \
149 if (__a >= 0) \
150 return (type) __a; \
151 errno = -__a; \
152 return (type) -1; \
155 #endif