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 #ifdef __AROS_ASMCALL_H_FILE
61 #include __AROS_ASMCALL_H_FILE
64 #ifndef __typedef_VOID_FUNC
65 #define __typedef_VOID_FUNC
66 typedef void (*VOID_FUNC
)();
68 #ifndef __typedef_LONG_FUNC
69 #define __typedef_LONG_FUNC
70 typedef int (*LONG_FUNC
)();
72 #ifndef __typedef_ULONG_FUNC
73 #define __typedef_ULONG_FUNC
74 typedef unsigned int (*ULONG_FUNC
)();
78 #define __AROS_UFHA(type,name,reg) type name
81 #define __AROS_UFPA(type,name,reg) type
84 #define __AROS_UFCA(type,name,reg) (name)
87 #define __AROS_UFDA(type,name,reg) type
90 #ifndef __AROS_UFH_PREFIX
91 #define __AROS_UFH_PREFIX /* eps */
93 #ifndef __AROS_UFP_PREFIX
94 #define __AROS_UFP_PREFIX /* eps */
96 #ifndef __AROS_UFC_PREFIX
97 #define __AROS_UFC_PREFIX /* eps */
99 #ifndef __AROS_UFD_PREFIX
100 #define __AROS_UFD_PREFIX /* eps */
103 #ifndef __AROS_CPU_SPECIFIC_ASMCALLS
105 #if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) /* Function headers for user functions */
106 #define AROS_UFH0(t,n) \
107 __AROS_UFH_PREFIX t n (void) {
108 #define AROS_UFH1S(t,n,a1) \
109 __AROS_UFH_PREFIX static t n (\
112 #define AROS_UFH1(t,n,a1) \
113 __AROS_UFH_PREFIX t n (\
116 #define AROS_UFH2S(t,n,a1,a2) \
117 __AROS_UFH_PREFIX static t n (\
121 #define AROS_UFH2(t,n,a1,a2) \
122 __AROS_UFH_PREFIX t n (\
126 #define AROS_UFH3(t,n,a1,a2,a3) \
127 __AROS_UFH_PREFIX t n (\
132 #define AROS_UFH3S(t,n,a1,a2,a3) \
133 __AROS_UFH_PREFIX static t n (\
138 #define AROS_UFH4(t,n,a1,a2,a3,a4) \
139 __AROS_UFH_PREFIX t n (\
145 #define AROS_UFH5(t,n,a1,a2,a3,a4,a5) \
146 __AROS_UFH_PREFIX t n (\
153 #define AROS_UFH5S(t,n,a1,a2,a3,a4,a5) \
154 __AROS_UFH_PREFIX static t n (\
161 #define AROS_UFH6(t,n,a1,a2,a3,a4,a5,a6) \
162 __AROS_UFH_PREFIX t n (\
170 #define AROS_UFH7(t,n,a1,a2,a3,a4,a5,a6,a7) \
171 __AROS_UFH_PREFIX t n (\
180 #define AROS_UFH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
181 __AROS_UFH_PREFIX t n (\
191 #define AROS_UFH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
192 __AROS_UFH_PREFIX t n (\
203 #define AROS_UFH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
204 __AROS_UFH_PREFIX t n (\
216 #define AROS_UFH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
217 __AROS_UFH_PREFIX t n (\
230 #define AROS_UFH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
231 __AROS_UFH_PREFIX t n (\
245 #define AROS_UFH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
246 __AROS_UFH_PREFIX t n (\
261 #define AROS_UFH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
262 __AROS_UFH_PREFIX t n (\
278 #define AROS_UFH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
279 __AROS_UFH_PREFIX t n (\
297 /* Call a user function */
298 #define AROS_UFC0(t,n) \
299 (((__AROS_UFC_PREFIX t(*)(void))n)())
300 #define AROS_UFC1(t,n,a1) \
301 (((__AROS_UFC_PREFIX t(*)(\
306 #define AROS_UFC2(t,n,a1,a2) \
307 (((__AROS_UFC_PREFIX t(*)(\
314 #define AROS_UFC3(t,n,a1,a2,a3) \
315 (((__AROS_UFC_PREFIX t(*)(\
324 #define AROS_UFC4(t,n,a1,a2,a3,a4) \
325 (((__AROS_UFC_PREFIX t(*)(\
336 #define AROS_UFC5(t,n,a1,a2,a3,a4,a5) \
337 (((__AROS_UFC_PREFIX t(*)(\
350 #define AROS_UFC6(t,n,a1,a2,a3,a4,a5,a6) \
351 (((__AROS_UFC_PREFIX t(*)(\
366 #define AROS_UFC7(t,n,a1,a2,a3,a4,a5,a6,a7) \
367 (((__AROS_UFC_PREFIX t(*)(\
384 #define AROS_UFC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
385 (((__AROS_UFC_PREFIX t(*)(\
404 #define AROS_UFC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
405 (((__AROS_UFC_PREFIX t(*)(\
426 #define AROS_UFC10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
427 (((__AROS_UFC_PREFIX t(*)(\
450 #define AROS_UFC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
451 (((__AROS_UFC_PREFIX t(*)(\
476 #define AROS_UFC12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
477 (((__AROS_UFC_PREFIX t(*)(\
504 #define AROS_UFC13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
505 (((__AROS_UFC_PREFIX t(*)(\
534 #define AROS_UFC14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
535 (((__AROS_UFC_PREFIX t(*)(\
566 #define AROS_UFC15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
567 (((__AROS_UFC_PREFIX t(*)(\
600 #define AROS_UFC0NR AROS_UFC0
601 #define AROS_UFC1NR AROS_UFC1
602 #define AROS_UFC2NR AROS_UFC2
603 #define AROS_UFC3NR AROS_UFC3
604 #define AROS_UFC4NR AROS_UFC4
605 #define AROS_UFC5NR AROS_UFC5
606 #define AROS_UFC6NR AROS_UFC6
607 #define AROS_UFC7NR AROS_UFC7
608 #define AROS_UFC8NR AROS_UFC8
609 #define AROS_UFC9NR AROS_UFC9
610 #define AROS_UFC10NR AROS_UFC10
611 #define AROS_UFC11NR AROS_UFC11
612 #define AROS_UFC12NR AROS_UFC12
613 #define AROS_UFC13NR AROS_UFC13
614 #define AROS_UFC14NR AROS_UFC14
615 #define AROS_UFC15NR AROS_UFC15
616 #endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
618 /* Prototypes for user functions */
619 # define AROS_UFP0(t,n) \
620 __AROS_UFP_PREFIX t n (void)
621 # define AROS_UFP1(t,n,a1) \
622 __AROS_UFP_PREFIX t n (\
624 # define AROS_UFP2(t,n,a1,a2) \
625 __AROS_UFP_PREFIX t n (\
628 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
629 # define AROS_UFP2S(t,n,a1,a2) \
630 __AROS_UFP_PREFIX static t n (\
634 # define AROS_UFP2S(t,n,a1,a2) \
635 __AROS_UFP_PREFIX t n (\
639 # define AROS_UFP3(t,n,a1,a2,a3) \
640 __AROS_UFP_PREFIX t n (\
644 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
645 # define AROS_UFP3S(t,n,a1,a2,a3) \
646 __AROS_UFP_PREFIX static t n (\
651 # define AROS_UFP3S(t,n,a1,a2,a3) \
652 __AROS_UFP_PREFIX t n (\
656 # endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
657 # define AROS_UFP4(t,n,a1,a2,a3,a4) \
658 __AROS_UFP_PREFIX t n (\
663 # define AROS_UFP5(t,n,a1,a2,a3,a4,a5) \
664 __AROS_UFP_PREFIX t n (\
670 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
671 # define AROS_UFP5S(t,n,a1,a2,a3,a4,a5) \
672 __AROS_UFP_PREFIX static t n (\
679 # define AROS_UFP5S(t,n,a1,a2,a3,a4,a5) \
680 __AROS_UFP_PREFIX t n (\
686 # endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
687 # define AROS_UFP6(t,n,a1,a2,a3,a4,a5,a6) \
688 __AROS_UFP_PREFIX t n (\
695 # define AROS_UFP7(t,n,a1,a2,a3,a4,a5,a6,a7) \
696 __AROS_UFP_PREFIX t n (\
704 # define AROS_UFP8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
705 __AROS_UFP_PREFIX t n (\
714 # define AROS_UFP9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
715 __AROS_UFP_PREFIX t n (\
725 # define AROS_UFP10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
726 __AROS_UFP_PREFIX t n (\
737 # define AROS_UFP11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
738 __AROS_UFP_PREFIX t n (\
750 # define AROS_UFP12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
751 __AROS_UFP_PREFIX t n (\
764 # define AROS_UFP13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
765 __AROS_UFP_PREFIX t n (\
779 # define AROS_UFP14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
780 __AROS_UFP_PREFIX t n (\
795 # define AROS_UFP15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
796 __AROS_UFP_PREFIX t n (\
813 #endif /* !__AROS_CPU_SPECIFIC_ASMCALLS */
814 #define AROS_UFHA(type,name,reg) type,name,reg
815 #define AROS_UFPA(type,name,reg) type,name,reg
816 #define AROS_UFCA(type,name,reg) type,name,reg
818 #ifndef AROS_USERFUNC_INIT
819 # define AROS_USERFUNC_INIT {
821 #ifndef AROS_USERFUNC_EXIT
822 # define AROS_USERFUNC_EXIT }}
825 /* DOS/CreateProc() entry point definition
830 #define AROS_PROCH(n, _argptr, _argsize, _SysBase) \
831 AROS_UFH3(SIPTR, n, \
832 AROS_UFHA(STRPTR, _argptr, A0), \
833 AROS_UFHA(ULONG, _argsize, D0), \
834 AROS_UFHA(struct ExecBase *, _SysBase, A6))
837 #define AROS_PROCP(n) \
838 AROS_UFP3(SIPTR, n, \
839 AROS_UFPA(STRPTR, _argptr, A0), \
840 AROS_UFPA(ULONG, _argsize, D0), \
841 AROS_UFPA(struct ExecBase *, _SysBase, A6))
844 #define AROS_PROCC(n) \
845 AROS_UFC3(SIPTR, n, \
846 AROS_UFCA(STRPTR, _argptr, A0), \
847 AROS_UFCA(ULONG, _argsize, D0), \
848 AROS_UFCA(struct ExecBase *, _SysBase, A6))
851 #define AROS_PROCFUNC_INIT AROS_USERFUNC_INIT
852 #define AROS_PROCFUNC_EXIT AROS_USERFUNC_EXIT
854 /******************************************************************************
855 ***** ENDE aros/asmcall.h
856 ******************************************************************************/
858 #endif /* AROS_ASMCALL_H */