2 Copyright © 1995-2015, 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_UFH0S(t,n) \
109 __AROS_UFH_PREFIX static t n (void) {
110 #define AROS_UFH1(t,n,a1) \
111 __AROS_UFH_PREFIX t n (\
114 #define AROS_UFH1S(t,n,a1) \
115 __AROS_UFH_PREFIX static t n (\
118 #define AROS_UFH2(t,n,a1,a2) \
119 __AROS_UFH_PREFIX t n (\
123 #define AROS_UFH2S(t,n,a1,a2) \
124 __AROS_UFH_PREFIX static t n (\
128 #define AROS_UFH3(t,n,a1,a2,a3) \
129 __AROS_UFH_PREFIX t n (\
134 #define AROS_UFH3S(t,n,a1,a2,a3) \
135 __AROS_UFH_PREFIX static t n (\
140 #define AROS_UFH4(t,n,a1,a2,a3,a4) \
141 __AROS_UFH_PREFIX t n (\
147 #define AROS_UFH4S(t,n,a1,a2,a3,a4) \
148 __AROS_UFH_PREFIX static t n (\
154 #define AROS_UFH5(t,n,a1,a2,a3,a4,a5) \
155 __AROS_UFH_PREFIX t n (\
162 #define AROS_UFH5S(t,n,a1,a2,a3,a4,a5) \
163 __AROS_UFH_PREFIX static t n (\
170 #define AROS_UFH6(t,n,a1,a2,a3,a4,a5,a6) \
171 __AROS_UFH_PREFIX t n (\
179 #define AROS_UFH7(t,n,a1,a2,a3,a4,a5,a6,a7) \
180 __AROS_UFH_PREFIX t n (\
189 #define AROS_UFH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
190 __AROS_UFH_PREFIX t n (\
200 #define AROS_UFH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
201 __AROS_UFH_PREFIX t n (\
212 #define AROS_UFH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
213 __AROS_UFH_PREFIX t n (\
225 #define AROS_UFH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
226 __AROS_UFH_PREFIX t n (\
239 #define AROS_UFH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
240 __AROS_UFH_PREFIX t n (\
254 #define AROS_UFH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
255 __AROS_UFH_PREFIX t n (\
270 #define AROS_UFH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
271 __AROS_UFH_PREFIX t n (\
287 #define AROS_UFH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
288 __AROS_UFH_PREFIX t n (\
306 /* Call a user function */
307 #define AROS_UFC0(t,n) \
308 (((__AROS_UFC_PREFIX t(*)(void))n)())
309 #define AROS_UFC1(t,n,a1) \
310 (((__AROS_UFC_PREFIX t(*)(\
315 #define AROS_UFC2(t,n,a1,a2) \
316 (((__AROS_UFC_PREFIX t(*)(\
323 #define AROS_UFC3(t,n,a1,a2,a3) \
324 (((__AROS_UFC_PREFIX t(*)(\
333 #define AROS_UFC4(t,n,a1,a2,a3,a4) \
334 (((__AROS_UFC_PREFIX t(*)(\
345 #define AROS_UFC5(t,n,a1,a2,a3,a4,a5) \
346 (((__AROS_UFC_PREFIX t(*)(\
359 #define AROS_UFC6(t,n,a1,a2,a3,a4,a5,a6) \
360 (((__AROS_UFC_PREFIX t(*)(\
375 #define AROS_UFC7(t,n,a1,a2,a3,a4,a5,a6,a7) \
376 (((__AROS_UFC_PREFIX t(*)(\
393 #define AROS_UFC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
394 (((__AROS_UFC_PREFIX t(*)(\
413 #define AROS_UFC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
414 (((__AROS_UFC_PREFIX t(*)(\
435 #define AROS_UFC10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
436 (((__AROS_UFC_PREFIX t(*)(\
459 #define AROS_UFC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
460 (((__AROS_UFC_PREFIX t(*)(\
485 #define AROS_UFC12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
486 (((__AROS_UFC_PREFIX t(*)(\
513 #define AROS_UFC13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
514 (((__AROS_UFC_PREFIX t(*)(\
543 #define AROS_UFC14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
544 (((__AROS_UFC_PREFIX t(*)(\
575 #define AROS_UFC15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
576 (((__AROS_UFC_PREFIX t(*)(\
609 #define AROS_UFC0NR AROS_UFC0
610 #define AROS_UFC1NR AROS_UFC1
611 #define AROS_UFC2NR AROS_UFC2
612 #define AROS_UFC3NR AROS_UFC3
613 #define AROS_UFC4NR AROS_UFC4
614 #define AROS_UFC5NR AROS_UFC5
615 #define AROS_UFC6NR AROS_UFC6
616 #define AROS_UFC7NR AROS_UFC7
617 #define AROS_UFC8NR AROS_UFC8
618 #define AROS_UFC9NR AROS_UFC9
619 #define AROS_UFC10NR AROS_UFC10
620 #define AROS_UFC11NR AROS_UFC11
621 #define AROS_UFC12NR AROS_UFC12
622 #define AROS_UFC13NR AROS_UFC13
623 #define AROS_UFC14NR AROS_UFC14
624 #define AROS_UFC15NR AROS_UFC15
625 #endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
627 /* Prototypes for user functions */
628 # define AROS_UFP0(t,n) \
629 __AROS_UFP_PREFIX t n (void)
630 # define AROS_UFP1(t,n,a1) \
631 __AROS_UFP_PREFIX t n (\
633 # define AROS_UFP2(t,n,a1,a2) \
634 __AROS_UFP_PREFIX t n (\
637 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
638 # define AROS_UFP2S(t,n,a1,a2) \
639 __AROS_UFP_PREFIX static t n (\
643 # define AROS_UFP2S(t,n,a1,a2) \
644 __AROS_UFP_PREFIX t n (\
648 # define AROS_UFP3(t,n,a1,a2,a3) \
649 __AROS_UFP_PREFIX t n (\
653 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
654 # define AROS_UFP3S(t,n,a1,a2,a3) \
655 __AROS_UFP_PREFIX static t n (\
660 # define AROS_UFP3S(t,n,a1,a2,a3) \
661 __AROS_UFP_PREFIX t n (\
665 # endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
666 # define AROS_UFP4(t,n,a1,a2,a3,a4) \
667 __AROS_UFP_PREFIX t n (\
672 # define AROS_UFP5(t,n,a1,a2,a3,a4,a5) \
673 __AROS_UFP_PREFIX t n (\
679 # if !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS))
680 # define AROS_UFP5S(t,n,a1,a2,a3,a4,a5) \
681 __AROS_UFP_PREFIX static t n (\
688 # define AROS_UFP5S(t,n,a1,a2,a3,a4,a5) \
689 __AROS_UFP_PREFIX t n (\
695 # endif /* !(UseRegisterArgs && defined(AROS_COMPILER_NO_REGARGS)) */
696 # define AROS_UFP6(t,n,a1,a2,a3,a4,a5,a6) \
697 __AROS_UFP_PREFIX t n (\
704 # define AROS_UFP7(t,n,a1,a2,a3,a4,a5,a6,a7) \
705 __AROS_UFP_PREFIX t n (\
713 # define AROS_UFP8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
714 __AROS_UFP_PREFIX t n (\
723 # define AROS_UFP9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
724 __AROS_UFP_PREFIX t n (\
734 # define AROS_UFP10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
735 __AROS_UFP_PREFIX t n (\
746 # define AROS_UFP11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
747 __AROS_UFP_PREFIX t n (\
759 # define AROS_UFP12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
760 __AROS_UFP_PREFIX t n (\
773 # define AROS_UFP13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
774 __AROS_UFP_PREFIX t n (\
788 # define AROS_UFP14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
789 __AROS_UFP_PREFIX t n (\
804 # define AROS_UFP15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
805 __AROS_UFP_PREFIX t n (\
822 #endif /* !__AROS_CPU_SPECIFIC_ASMCALLS */
823 #define AROS_UFHA(type,name,reg) type,name,reg
824 #define AROS_UFPA(type,name,reg) type,name,reg
825 #define AROS_UFCA(type,name,reg) type,name,reg
827 #ifndef AROS_USERFUNC_INIT
828 # define AROS_USERFUNC_INIT {
830 #ifndef AROS_USERFUNC_EXIT
831 # define AROS_USERFUNC_EXIT }}
834 /* DOS/CreateProc() entry point definition
839 #define AROS_PROCH(n, _argptr, _argsize, _SysBase) \
840 AROS_UFH3(SIPTR, n, \
841 AROS_UFHA(STRPTR, _argptr, A0), \
842 AROS_UFHA(ULONG, _argsize, D0), \
843 AROS_UFHA(struct ExecBase *, _SysBase, A6))
846 #define AROS_PROCP(n) \
847 AROS_UFP3(SIPTR, n, \
848 AROS_UFPA(STRPTR, _argptr, A0), \
849 AROS_UFPA(ULONG, _argsize, D0), \
850 AROS_UFPA(struct ExecBase *, _SysBase, A6))
853 #define AROS_PROCC(n) \
854 AROS_UFC3(SIPTR, n, \
855 AROS_UFCA(STRPTR, _argptr, A0), \
856 AROS_UFCA(ULONG, _argsize, D0), \
857 AROS_UFCA(struct ExecBase *, _SysBase, A6))
860 #define AROS_PROCFUNC_INIT AROS_USERFUNC_INIT
861 #define AROS_PROCFUNC_EXIT AROS_USERFUNC_EXIT
863 /******************************************************************************
864 ***** ENDE aros/asmcall.h
865 ******************************************************************************/
867 #endif /* AROS_ASMCALL_H */