2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
10 /******************************************************************************
16 Some macros to build and call functions with registerized parameters on
17 the different compilers around. Usage:
19 AROS_UFH<n><f>(type, name, type1, name1, reg1, ...)
21 \* Function starts here. *\
24 <n> - Number of arguments of the function (not including the
27 <f> - 'I' means: Function ignores library base.
28 This is useful to get rid of warnings about unused arguments.
30 type - Returntype of the function.
32 name - Name of the function. A underscore '_' is prepended so that
33 following functions jump over the base vector and don't call
34 the function directly.
36 type<i>, name<i>, reg<i> - Type, name and register for the
37 arguments. Register names are written uppercase because they
38 are preprocessor symbols.
40 Example: Define a Exec compatible RemHead function.
42 AROS_UFH1(struct Node *, RemHead,
43 AROS_UFHA(struct List *, list, A0)
49 if(node->ln_Succ==NULL)
55 ******************************************************************************/
59 /* System-Specific things */
61 # include <aros/system.h>
64 #ifndef __typedef_VOID_FUNC
65 #define __typedef_VOID_FUNC
66 typedef void (*VOID_FUNC
)(void);
68 #ifndef __typedef_LONG_FUNC
69 #define __typedef_LONG_FUNC
70 typedef long (*LONG_FUNC
)(void);
72 #ifndef __typedef_ULONG_FUNC
73 #define __typedef_ULONG_FUNC
74 typedef unsigned long (*ULONG_FUNC
)(void);
77 #ifndef AROS_ASMSYMNAME
78 # define AROS_ASMSYMNAME(n) ((APTR)&Xj(n,_Gate))
97 #if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
98 /* Function headers for user functions */
99 #define AROS_UFH0(t,n) \
100 __AROS_UFH_PREFIX t n##_Func (void); \
101 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
102 __AROS_UFH_PREFIX t n##_Func(void) \
105 #define AROS_UFH1(t,n,a1) \
106 __AROS_UFH_PREFIX t n##_Func (void); \
107 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
108 __AROS_UFH_PREFIX t n##_Func(void) \
112 #define AROS_UFH2(t,n,a1,a2) \
113 __AROS_UFH_PREFIX t n##_Func (void); \
114 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
115 __AROS_UFH_PREFIX t n##_Func(void) \
120 #define AROS_UFH3(t,n,a1,a2,a3) \
121 __AROS_UFH_PREFIX t n##_Func (void); \
122 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
123 __AROS_UFH_PREFIX t n##_Func(void) \
129 #define AROS_UFH3S(t,n,a1,a2,a3) \
130 static __AROS_UFH_PREFIX t n##_Func (void); \
131 static const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
132 static __AROS_UFH_PREFIX t n##_Func(void) \
138 #define AROS_UFH4(t,n,a1,a2,a3,a4) \
139 __AROS_UFH_PREFIX t n##_Func (void); \
140 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
141 __AROS_UFH_PREFIX t n##_Func(void) \
148 #define AROS_UFH5(t,n,a1,a2,a3,a4,a5) \
149 __AROS_UFH_PREFIX t n##_Func (void); \
150 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
151 __AROS_UFH_PREFIX t n##_Func(void) \
159 #define AROS_UFH5S(t,n,a1,a2,a3,a4,a5) \
160 __AROS_UFH_PREFIX static t n##_Func (void); \
161 static const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
162 __AROS_UFH_PREFIX static t n##_Func(void) \
170 #define AROS_UFH6(t,n,a1,a2,a3,a4,a5,a6) \
171 __AROS_UFH_PREFIX t n##_Func (void); \
172 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
173 __AROS_UFH_PREFIX t n##_Func(void) \
182 #define AROS_UFH7(t,n,a1,a2,a3,a4,a5,a6,a7) \
183 __AROS_UFH_PREFIX t n##_Func (void); \
184 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
185 __AROS_UFH_PREFIX t n##_Func(void) \
195 #define AROS_UFH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
196 __AROS_UFH_PREFIX t n##_Func (void); \
197 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
198 __AROS_UFH_PREFIX t n##_Func(void) \
209 #define AROS_UFH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
210 __AROS_UFH_PREFIX t n##_Func (void); \
211 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
212 __AROS_UFH_PREFIX t n##_Func(void) \
224 #define AROS_UFH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
225 __AROS_UFH_PREFIX t n##_Func (void); \
226 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
227 __AROS_UFH_PREFIX t n##_Func(void) \
240 #define AROS_UFH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
241 __AROS_UFH_PREFIX t n##_Func (void); \
242 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
243 __AROS_UFH_PREFIX t n##_Func(void) \
257 #define AROS_UFH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
258 __AROS_UFH_PREFIX t n##_Func (void); \
259 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
260 __AROS_UFH_PREFIX t n##_Func(void) \
275 #define AROS_UFH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
276 __AROS_UFH_PREFIX t n##_Func (void); \
277 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
278 __AROS_UFH_PREFIX t n##_Func(void) \
294 #define AROS_UFH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
295 __AROS_UFH_PREFIX t n##_Func (void); \
296 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
297 __AROS_UFH_PREFIX t n##_Func(void) \
314 #define AROS_UFH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
315 __AROS_UFH_PREFIX t n##_Func (void); \
316 const struct EmulLibEntry n##_Gate = { TRAP_LIB, 0, (void(*))n##_Func }; \
317 __AROS_UFH_PREFIX t n##_Func(void) \
335 /* Call a user function */
336 #define AROS_UFC0(t,n) \
337 ((t)MyEmulHandle->EmulCallDirect68k((APTR)(n)))
339 #define AROS_UFC1(t,n,a1) \
343 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
346 #define AROS_UFC2(t,n,a1,a2) \
352 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
355 #define AROS_UFC3(t,n,a1,a2,a3) \
363 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
366 #define AROS_UFC4(t,n,a1,a2,a3,a4) \
376 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
379 #define AROS_UFC5(t,n,a1,a2,a3,a4,a5) \
391 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
394 #define AROS_UFC6(t,n,a1,a2,a3,a4,a5,a6) \
408 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
411 #define AROS_UFC7(t,n,a1,a2,a3,a4,a5,a6,a7) \
427 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
430 #define AROS_UFC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
448 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
451 #define AROS_UFC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
471 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
474 #define AROS_UFC10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
496 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
499 #define AROS_UFC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
523 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
526 #define AROS_UFC12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
552 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
555 #define AROS_UFC13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
583 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
586 #define AROS_UFC14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
616 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
619 #define AROS_UFC15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
651 (t)MyEmulHandle->EmulCallDirect68k((APTR)(n)); \
654 #endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
656 /* Prototypes for user functions */
657 # define AROS_UFP0(t,n) \
658 extern const struct EmulLibEntry n##_Gate;
660 # define AROS_UFP1(t,n,a1) \
661 extern const struct EmulLibEntry n##_Gate;
663 # define AROS_UFP2(t,n,a1,a2) \
664 extern const struct EmulLibEntry n##_Gate;
666 # define AROS_UFP3(t,n,a1,a2,a3) \
667 extern const struct EmulLibEntry n##_Gate;
669 # define AROS_UFP3S(t,n,a1,a2,a3) \
670 extern const struct EmulLibEntry n##_Gate;
672 # define AROS_UFP4(t,n,a1,a2,a3,a4) \
673 const struct EmulLibEntry Xj(n,_Gate);
675 # define AROS_UFP5(t,n,a1,a2,a3,a4,a5) \
676 extern const struct EmulLibEntry n##_Gate;
678 # define AROS_UFP5S(t,n,a1,a2,a3,a4,a5) \
679 extern const struct EmulLibEntry n##_Gate;
680 # define AROS_UFP6(t,n,a1,a2,a3,a4,a5,a6) \
681 extern const struct EmulLibEntry n##_Gate;
683 # define AROS_UFP7(t,n,a1,a2,a3,a4,a5,a6,a7) \
684 extern const struct EmulLibEntry n##_Gate;
686 # define AROS_UFP8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
687 extern const struct EmulLibEntry n##_Gate;
689 # define AROS_UFP9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
690 extern const struct EmulLibEntry n##_Gate;
692 # define AROS_UFP10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
693 extern const struct EmulLibEntry n##_Gate;
695 # define AROS_UFP11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
696 extern const struct EmulLibEntry n##_Gate;
698 # define AROS_UFP12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
699 extern const struct EmulLibEntry n##_Gate;
701 # define AROS_UFP13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
702 extern const struct EmulLibEntry n##_Gate;
704 # define AROS_UFP14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
705 extern const struct EmulLibEntry n##_Gate;
707 # define AROS_UFP15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
708 extern const struct EmulLibEntry n##_Gate;
710 #define AROS_UFHA(type,name,reg) type,name,reg
711 #define AROS_UFPA(type,name,reg) type,name,reg
712 #define AROS_UFCA(type,name,reg) type,name,reg
714 #ifndef AROS_USERFUNC_INIT
715 # define AROS_USERFUNC_INIT {
717 #ifndef AROS_USERFUNC_EXIT
718 # define AROS_USERFUNC_EXIT }}
721 /******************************************************************************
722 ***** ENDE aros/asmcall.h
723 ******************************************************************************/
725 #endif /* AROS_ASMCALL_H */