2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 * This program generates the libcall.h macroset for gcc
12 #define GENCALL_MAX (13 + 1) /* Max number of arguments */
14 void aros_lc(int id
, const char *suffix
)
18 printf("#define AROS_LC%d%s(t,n,", id
, suffix
);
19 for (i
= 0; i
< id
; i
++)
20 printf("a%d,", i
+ 1);
21 printf("bt,bn,o,s) \\\n"
23 " bt __bn = (bt)bn; \\\n"
24 " ((__attribute__((regparm(1))) t (*)(bt"
26 for (i
= 0; i
< id
; i
++)
28 printf(", __AROS_LDA(a%d)", i
+1);
30 printf("))__AROS_GETVECADDR(__bn,o))(__bn");
31 for (i
= 0; i
< id
; i
++)
33 printf(", __AROS_LCA(a%d)", i
+1);
40 void aros_call(int id
, const char *suffix
)
44 printf("#define AROS_CALL%d%s(t,n,", id
, suffix
);
45 for (i
= 0; i
< id
; i
++)
46 printf("a%d,", i
+ 1);
49 " bt __bn = (bt)bn; \\\n"
50 /* Need to first assign to variable otherwise gcc may miscompile */
51 " APTR __func = (APTR)n; \\\n"
52 " ((__attribute__((regparm(1))) t (*)(bt"
54 for (i
= 0; i
< id
; i
++)
56 printf(", __AROS_LDA(a%d)", i
+1);
58 printf("))(APTR)__func)(__bn");
59 for (i
= 0; i
< id
; i
++)
61 printf(", __AROS_LCA(a%d)", i
+1);
68 void aros_lh(int id
, int is_ignored
)
72 printf("#define AROS_LH%d%s(t,n,", id
, is_ignored
? "I" : "");
73 for (i
= 0; i
< id
; i
++)
74 printf("a%d,", i
+ 1);
75 printf("bt,bn,o,s) \\\n");
79 printf(" __attribute__((regparm(1))) t AROS_SLIB_ENTRY(n,s,o) (bt bn");
80 for (i
= 0; i
< id
; i
++)
82 printf(", __AROS_LHA(a%d)", i
+ 1);
90 printf(" t AROS_SLIB_ENTRY(n,s,o) (");
93 for (i
= 0; i
< id
; i
++)
97 printf("__AROS_LHA(a%d)", i
+ 1);
105 static void aros_ld(int id
, int is_ignored
)
109 printf("#define AROS_LD%d%s(t,n,", id
, is_ignored
? "I" : "");
110 for (i
= 0; i
< id
; i
++)
111 printf("a%d,", i
+ 1);
112 printf("bt,bn,o,s) \\\n");
115 printf(" __attribute__((regparm(1))) t AROS_SLIB_ENTRY(n,s,o) (bt bn");
116 for (i
= 0; i
< id
; i
++)
118 printf(", __AROS_LDA(a%d)", i
+ 1);
123 printf(" t AROS_SLIB_ENTRY(n,s,o) (");
126 for (i
= 0; i
< id
; i
++)
130 printf("__AROS_LDA(a%d)", i
+ 1);
136 const static char extra
[] =
138 "#define __AROS_QUADt(type,name,reg1,reg2) type\n"
139 "#define __AROS_QUADn(type,name,reg1,reg2) name\n"
140 "#define __AROS_QUADr(type,name,reg1,reg2) reg1##reg2\n"
142 "#define AROS_LHQUAD1(t,n,a1,bt,bn,o,s) \\\n"
143 " AROS_LH1(t,n, \\\n"
144 " AROS_LHA(__AROS_QUADt(a1), __AROS_QUADn(a1), __AROS_QUADr(a1)), \\\n"
147 "#define AROS_LHQUAD2(t,n,a1,a2,bt,bn,o,s) \\\n"
148 " AROS_LH2(t,n, \\\n"
149 " AROS_LHA(__AROS_QUADt(a1), __AROS_QUADn(a1), __AROS_QUADr(a1)), \\\n"
150 " AROS_LHA(__AROS_QUADt(a2), __AROS_QUADn(a2), __AROS_QUADr(a2)), \\\n"
153 "#define AROS_LH1QUAD1(t,n,a1,a2,bt,bn,o,s) \\\n"
154 " AROS_LH2(t,n, \\\n"
155 " AROS_LHA(a1), \\\n"
156 " AROS_LHA(__AROS_QUADt(a2), __AROS_QUADn(a2), __AROS_QUADr(a2)), \\\n"
159 "#define AROS_LH2QUAD1(t,n,a1,a2,a3,bt,bn,o,s) \\\n"
160 " AROS_LH3(t,n, \\\n"
161 " AROS_LHA(a1), \\\n"
162 " AROS_LHA(a2), \\\n"
163 " AROS_LHA(__AROS_QUADt(a3), __AROS_QUADn(a3), __AROS_QUADr(a3)), \\\n"
166 "#define AROS_LH3QUAD1(t,n,a1,a2,a3,a4,bt,bn,o,s) \\\n"
167 " AROS_LH4(t,n, \\\n"
168 " AROS_LHA(a1), \\\n"
169 " AROS_LHA(a2), \\\n"
170 " AROS_LHA(a3), \\\n"
171 " AROS_LHA(__AROS_QUADt(a4), __AROS_QUADn(a4), __AROS_QUADr(a4)), \\\n"
176 "#define AROS_LCQUAD1(t,n,a1,bt,bn,o,s) \\\n"
177 " AROS_LC1(t,n, \\\n"
178 " AROS_LCA(__AROS_QUADt(a1), __AROS_QUADn(a1), __AROS_QUADr(a1)), \\\n"
181 "#define AROS_LCQUAD2(t,n,a1,a2,bt,bn,o,s) \\\n"
182 " AROS_LC2(t,n, \\\n"
183 " AROS_LCA(__AROS_QUADt(a1), __AROS_QUADn(a1), __AROS_QUADr(a1)), \\\n"
184 " AROS_LCA(__AROS_QUADt(a2), __AROS_QUADn(a2), __AROS_QUADr(a2)), \\\n"
187 "#define AROS_LC1QUAD1(t,n,a1,a2,bt,bn,o,s) \\\n"
188 " AROS_LC2(t,n, \\\n"
189 " AROS_LCA(a1), \\\n"
190 " AROS_LCA(__AROS_QUADt(a2), __AROS_QUADn(a2), __AROS_QUADr(a2)), \\\n"
193 "#define AROS_LC2QUAD1(t,n,a1,a2,a3,bt,bn,o,s) \\\n"
194 " AROS_LC3(t,n, \\\n"
195 " AROS_LCA(a1), \\\n"
196 " AROS_LCA(a2), \\\n"
197 " AROS_LCA(__AROS_QUADt(a3), __AROS_QUADn(a3), __AROS_QUADr(a3)), \\\n"
200 "#define AROS_LC3QUAD1(t,n,a1,a2,a3,a4,bt,bn,o,s) \\\n"
201 " AROS_LC4(t,n, \\\n"
202 " AROS_LCA(a1), \\\n"
203 " AROS_LCA(a2), \\\n"
204 " AROS_LCA(a3), \\\n"
205 " AROS_LCA(__AROS_QUADt(a4), __AROS_QUADn(a4), __AROS_QUADr(a4)), \\\n"
209 "#define AROS_LDQUAD1(t,n,a1,bt,bn,o,s) \\\n"
210 " AROS_LD1(t,n, \\\n"
211 " AROS_LDA(__AROS_QUADt(a1), __AROS_QUADn(a1), __AROS_QUADr(a1)), \\\n"
214 "#define AROS_LDQUAD2(t,n,a1,a2,bt,bn,o,s) \\\n"
215 " AROS_LD2(t,n, \\\n"
216 " AROS_LDA(__AROS_QUADt(a1), __AROS_QUADn(a1), __AROS_QUADr(a1)), \\\n"
217 " AROS_LDA(__AROS_QUADt(a2), __AROS_QUADn(a2), __AROS_QUADr(a2)), \\\n"
220 "#define AROS_LD1QUAD1(t,n,a1,a2,bt,bn,o,s) \\\n"
221 " AROS_LD2(t,n, \\\n"
222 " AROS_LDA(a1), \\\n"
223 " AROS_LDA(__AROS_QUADt(a2), __AROS_QUADn(a2), __AROS_QUADr(a2)), \\\n"
226 "#define AROS_LD2QUAD1(t,n,a1,a2,a3,bt,bn,o,s) \\\n"
227 " AROS_LD3(t,n, \\\n"
228 " AROS_LDA(a1), \\\n"
229 " AROS_LDA(a2), \\\n"
230 " AROS_LDA(__AROS_QUADt(a3), __AROS_QUADn(a3), __AROS_QUADr(a3)), \\\n"
233 "#define AROS_LD3QUAD1(t,n,a1,a2,a3,a4,bt,bn,o,s) \\\n"
234 " AROS_LD4(t,n, \\\n"
235 " AROS_LDA(a1), \\\n"
236 " AROS_LDA(a2), \\\n"
237 " AROS_LDA(a3), \\\n"
238 " AROS_LDA(__AROS_QUADt(a4), __AROS_QUADn(a4), __AROS_QUADr(a4)), \\\n"
243 int main(int argc
, char **argv
)
247 printf("/* AUTOGENERATED by arch/i386-all/include/gencall.c */\n");
249 printf("#ifndef AROS_I386_LIBCALL_H\n");
250 printf("#define AROS_I386_LIBCALL_H\n");
253 printf("#define __AROS_CPU_SPECIFIC_LH\n\n");
255 for (i
= 0; i
< GENCALL_MAX
; i
++)
258 for (i
= 0; i
< GENCALL_MAX
; i
++)
262 printf("#define __AROS_CPU_SPECIFIC_LC\n\n");
264 for (i
= 0; i
< GENCALL_MAX
; i
++)
267 for (i
= 0; i
< GENCALL_MAX
; i
++)
270 for (i
= 0; i
< GENCALL_MAX
; i
++)
273 for (i
= 0; i
< GENCALL_MAX
; i
++)
277 printf("#define __AROS_CPU_SPECIFIC_LD\n\n");
279 for (i
= 0; i
< GENCALL_MAX
; i
++)
282 for (i
= 0; i
< GENCALL_MAX
; i
++)
285 printf("%s\n", extra
);
287 printf("#endif /* AROS_I386_LIBCALL_H */\n");