Merge remote-tracking branch 'asoc/topic/component' into asoc-next
[sfrench/cifs-2.6.git] / arch / cris / include / arch-v10 / arch / unistd.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_CRIS_ARCH_UNISTD_H_
3 #define _ASM_CRIS_ARCH_UNISTD_H_
4
5 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
6 /*
7  * Don't remove the .ifnc tests; they are an insurance against
8  * any hard-to-spot gcc register allocation bugs.
9  */
10 #define _syscall0(type,name) \
11 type name(void) \
12 { \
13   register long __a __asm__ ("r10"); \
14   register long __n_ __asm__ ("r9") = (__NR_##name); \
15   __asm__ __volatile__ (".ifnc %0%1,$r10$r9\n\t" \
16                         ".err\n\t" \
17                         ".endif\n\t" \
18                         "break 13" \
19                         : "=r" (__a) \
20                         : "r" (__n_)); \
21   if (__a >= 0) \
22      return (type) __a; \
23   errno = -__a; \
24   return (type) -1; \
25 }
26
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   if (__a >= 0) \
39      return (type) __a; \
40   errno = -__a; \
41   return (type) -1; \
42 }
43
44 #define _syscall2(type,name,type1,arg1,type2,arg2) \
45 type name(type1 arg1,type2 arg2) \
46 { \
47   register long __a __asm__ ("r10") = (long) arg1; \
48   register long __b __asm__ ("r11") = (long) arg2; \
49   register long __n_ __asm__ ("r9") = (__NR_##name); \
50   __asm__ __volatile__ (".ifnc %0%1%3,$r10$r9$r11\n\t" \
51                         ".err\n\t" \
52                         ".endif\n\t" \
53                         "break 13" \
54                         : "=r" (__a) \
55                         : "r" (__n_), "0" (__a), "r" (__b)); \
56   if (__a >= 0) \
57      return (type) __a; \
58   errno = -__a; \
59   return (type) -1; \
60 }
61
62 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
63 type name(type1 arg1,type2 arg2,type3 arg3) \
64 { \
65   register long __a __asm__ ("r10") = (long) arg1; \
66   register long __b __asm__ ("r11") = (long) arg2; \
67   register long __c __asm__ ("r12") = (long) arg3; \
68   register long __n_ __asm__ ("r9") = (__NR_##name); \
69   __asm__ __volatile__ (".ifnc %0%1%3%4,$r10$r9$r11$r12\n\t" \
70                         ".err\n\t" \
71                         ".endif\n\t" \
72                         "break 13" \
73                         : "=r" (__a) \
74                         : "r" (__n_), "0" (__a), "r" (__b), "r" (__c)); \
75   if (__a >= 0) \
76      return (type) __a; \
77   errno = -__a; \
78   return (type) -1; \
79 }
80
81 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
82 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
83 { \
84   register long __a __asm__ ("r10") = (long) arg1; \
85   register long __b __asm__ ("r11") = (long) arg2; \
86   register long __c __asm__ ("r12") = (long) arg3; \
87   register long __d __asm__ ("r13") = (long) arg4; \
88   register long __n_ __asm__ ("r9") = (__NR_##name); \
89   __asm__ __volatile__ (".ifnc %0%1%3%4%5,$r10$r9$r11$r12$r13\n\t" \
90                         ".err\n\t" \
91                         ".endif\n\t" \
92                         "break 13" \
93                         : "=r" (__a) \
94                         : "r" (__n_), "0" (__a), "r" (__b), \
95                           "r" (__c), "r" (__d)); \
96   if (__a >= 0) \
97      return (type) __a; \
98   errno = -__a; \
99   return (type) -1; \
100
101
102 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
103           type5,arg5) \
104 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
105 { \
106   register long __a __asm__ ("r10") = (long) arg1; \
107   register long __b __asm__ ("r11") = (long) arg2; \
108   register long __c __asm__ ("r12") = (long) arg3; \
109   register long __d __asm__ ("r13") = (long) arg4; \
110   register long __n_ __asm__ ("r9") = (__NR_##name); \
111   __asm__ __volatile__ (".ifnc %0%1%3%4%5,$r10$r9$r11$r12$r13\n\t" \
112                         ".err\n\t" \
113                         ".endif\n\t" \
114                         "move %6,$mof\n\t" \
115                         "break 13" \
116                         : "=r" (__a) \
117                         : "r" (__n_), "0" (__a), "r" (__b), \
118                           "r" (__c), "r" (__d), "g" (arg5)); \
119   if (__a >= 0) \
120      return (type) __a; \
121   errno = -__a; \
122   return (type) -1; \
123 }
124
125 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
126           type5,arg5,type6,arg6) \
127 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
128 { \
129   register long __a __asm__ ("r10") = (long) arg1; \
130   register long __b __asm__ ("r11") = (long) arg2; \
131   register long __c __asm__ ("r12") = (long) arg3; \
132   register long __d __asm__ ("r13") = (long) arg4; \
133   register long __n_ __asm__ ("r9") = (__NR_##name); \
134   __asm__ __volatile__ (".ifnc %0%1%3%4%5,$r10$r9$r11$r12$r13\n\t" \
135                         ".err\n\t" \
136                         ".endif\n\t" \
137                         "move %6,$mof\n\tmove %7,$srp\n\t" \
138                         "break 13" \
139                         : "=r" (__a) \
140                         : "r" (__n_), "0" (__a), "r" (__b), \
141                           "r" (__c), "r" (__d), "g" (arg5), "g" (arg6)\
142                         : "srp"); \
143   if (__a >= 0) \
144      return (type) __a; \
145   errno = -__a; \
146   return (type) -1; \
147 }
148
149 #endif