2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
15 Some macros to build and call functions with registerized parameters on
16 the different compilers around. Usage:
18 AROS_UFH<n><f>(type, name, [AROS_UFHA(type1, name1, reg1),] ...)
25 <n> - Number of arguments of the function.
27 <f> - 'S' means: define function as static.
29 type - Returntype of the function.
31 name - Name of the function. A underscore '_' is prepended so that
32 following functions jump over the base vector and don't call
33 the function directly.
35 type<i>, name<i>, reg<i> - Type, name and register for the
36 arguments. Register names are written uppercase because they
37 are preprocessor symbols.
39 Example: Define a function which can be used for a callback hook.
41 AROS_UFH3(ULONG, myfunction,
42 AROS_UFHA(struct Hook *, h, A0),
43 AROS_UFHA(Object *, object, A2),
44 AROS_UFHA(APTR, msg, A1))
53 ******************************************************************************/
55 /* System-Specific things */
57 # include <aros/system.h>
60 #ifndef __typedef_VOID_FUNC
61 #define __typedef_VOID_FUNC
62 typedef void (*VOID_FUNC
)();
64 #ifndef __typedef_LONG_FUNC
65 #define __typedef_LONG_FUNC
66 typedef int (*LONG_FUNC
)();
68 #ifndef __typedef_ULONG_FUNC
69 #define __typedef_ULONG_FUNC
70 typedef unsigned int (*ULONG_FUNC
)();
73 #ifndef __AROS_CPU_SPECIFIC_ASMCALLS
75 #if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) /* Function headers for user functions */
76 #define AROS_UFH0(t,n) \
77 __AROS_UFH_PREFIX t n (void) {
78 #define AROS_UFH1(t,n,a1) \
79 __AROS_UFH_PREFIX t n (\
82 #define AROS_UFH2S(t,n,a1,a2) \
83 __AROS_UFH_PREFIX static t n (\
87 #define AROS_UFH2(t,n,a1,a2) \
88 __AROS_UFH_PREFIX t n (\
92 #define AROS_UFH3(t,n,a1,a2,a3) \
93 __AROS_UFH_PREFIX t n (\
98 #define AROS_UFH3S(t,n,a1,a2,a3) \
99 __AROS_UFH_PREFIX static t n (\
104 #define AROS_UFH4(t,n,a1,a2,a3,a4) \
105 __AROS_UFH_PREFIX t n (\
111 #define AROS_UFH5(t,n,a1,a2,a3,a4,a5) \
112 __AROS_UFH_PREFIX t n (\
119 #define AROS_UFH5S(t,n,a1,a2,a3,a4,a5) \
120 __AROS_UFH_PREFIX static t n (\
127 #define AROS_UFH6(t,n,a1,a2,a3,a4,a5,a6) \
128 __AROS_UFH_PREFIX t n (\
136 #define AROS_UFH7(t,n,a1,a2,a3,a4,a5,a6,a7) \
137 __AROS_UFH_PREFIX t n (\
146 #define AROS_UFH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
147 __AROS_UFH_PREFIX t n (\
157 #define AROS_UFH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
158 __AROS_UFH_PREFIX t n (\
169 #define AROS_UFH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
170 __AROS_UFH_PREFIX t n (\
182 #define AROS_UFH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
183 __AROS_UFH_PREFIX t n (\
196 #define AROS_UFH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
197 __AROS_UFH_PREFIX t n (\
211 #define AROS_UFH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
212 __AROS_UFH_PREFIX t n (\
227 #define AROS_UFH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
228 __AROS_UFH_PREFIX t n (\
244 #define AROS_UFH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
245 __AROS_UFH_PREFIX t n (\
263 /* Call a user function */
264 #define AROS_UFC0(t,n) \
265 (((__AROS_UFC_PREFIX t(*)(void))n)())
266 #define AROS_UFC1(t,n,a1) \
267 (((__AROS_UFC_PREFIX t(*)(\
272 #define AROS_UFC2(t,n,a1,a2) \
273 (((__AROS_UFC_PREFIX t(*)(\
280 #define AROS_UFC3(t,n,a1,a2,a3) \
281 (((__AROS_UFC_PREFIX t(*)(\
290 #define AROS_UFC4(t,n,a1,a2,a3,a4) \
291 (((__AROS_UFC_PREFIX t(*)(\
302 #define AROS_UFC5(t,n,a1,a2,a3,a4,a5) \
303 (((__AROS_UFC_PREFIX t(*)(\
316 #define AROS_UFC6(t,n,a1,a2,a3,a4,a5,a6) \
317 (((__AROS_UFC_PREFIX t(*)(\
332 #define AROS_UFC7(t,n,a1,a2,a3,a4,a5,a6,a7) \
333 (((__AROS_UFC_PREFIX t(*)(\
350 #define AROS_UFC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
351 (((__AROS_UFC_PREFIX t(*)(\
370 #define AROS_UFC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
371 (((__AROS_UFC_PREFIX t(*)(\
392 #define AROS_UFC10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
393 (((__AROS_UFC_PREFIX t(*)(\
416 #define AROS_UFC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
417 (((__AROS_UFC_PREFIX t(*)(\
442 #define AROS_UFC12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
443 (((__AROS_UFC_PREFIX t(*)(\
470 #define AROS_UFC13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
471 (((__AROS_UFC_PREFIX t(*)(\
500 #define AROS_UFC14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
501 (((__AROS_UFC_PREFIX t(*)(\
532 #define AROS_UFC15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
533 (((__AROS_UFC_PREFIX t(*)(\
566 #endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
568 /* Prototypes for user functions */
569 # define AROS_UFP0(t,n) \
570 __AROS_UFP_PREFIX t n (void)
571 # define AROS_UFP1(t,n,a1) \
572 __AROS_UFP_PREFIX t n (\
574 # define AROS_UFP2(t,n,a1,a2) \
575 __AROS_UFP_PREFIX t n (\
578 # define AROS_UFP3(t,n,a1,a2,a3) \
579 __AROS_UFP_PREFIX t n (\
583 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
584 # define AROS_UFP3S(t,n,a1,a2,a3) \
585 __AROS_UFP_PREFIX static t n (\
590 # define AROS_UFP3S(t,n,a1,a2,a3) \
591 __AROS_UFP_PREFIX t n (\
595 # endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
596 # define AROS_UFP4(t,n,a1,a2,a3,a4) \
597 __AROS_UFP_PREFIX t n (\
602 # define AROS_UFP5(t,n,a1,a2,a3,a4,a5) \
603 __AROS_UFP_PREFIX t n (\
609 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
610 # define AROS_UFP5S(t,n,a1,a2,a3,a4,a5) \
611 __AROS_UFP_PREFIX static t n (\
618 # define AROS_UFP5S(t,n,a1,a2,a3,a4,a5) \
619 __AROS_UFP_PREFIX t n (\
625 # endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
626 # define AROS_UFP6(t,n,a1,a2,a3,a4,a5,a6) \
627 __AROS_UFP_PREFIX t n (\
634 # define AROS_UFP7(t,n,a1,a2,a3,a4,a5,a6,a7) \
635 __AROS_UFP_PREFIX t n (\
643 # define AROS_UFP8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
644 __AROS_UFP_PREFIX t n (\
653 # define AROS_UFP9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
654 __AROS_UFP_PREFIX t n (\
664 # define AROS_UFP10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
665 __AROS_UFP_PREFIX t n (\
676 # define AROS_UFP11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
677 __AROS_UFP_PREFIX t n (\
689 # define AROS_UFP12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
690 __AROS_UFP_PREFIX t n (\
703 # define AROS_UFP13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
704 __AROS_UFP_PREFIX t n (\
718 # define AROS_UFP14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
719 __AROS_UFP_PREFIX t n (\
734 # define AROS_UFP15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
735 __AROS_UFP_PREFIX t n (\
752 #endif /* !__AROS_CPU_SPECIFIC_ASMCALLS */
753 #define AROS_UFHA(type,name,reg) type,name,reg
754 #define AROS_UFPA(type,name,reg) type,name,reg
755 #define AROS_UFCA(type,name,reg) type,name,reg
757 #ifndef AROS_USERFUNC_INIT
758 # define AROS_USERFUNC_INIT {
760 #ifndef AROS_USERFUNC_EXIT
761 # define AROS_USERFUNC_EXIT }}
764 /******************************************************************************
765 ***** ENDE aros/asmcall.h
766 ******************************************************************************/
768 #endif /* AROS_ASMCALL_H */