#ifndef AROS_MACHINE_H
#define AROS_MACHINE_H

/*
    Copyright © 1995-2001, The AROS Development Team. All rights reserved.
    $Id$

    NOTE: This file must compile *without* any other header !

    Desc: machine.h include file for Linux/m68k (and others?)
    Lang: english
*/

/* We want register args, and LVOs */
#define UseRegisterArgs 1
#define EnableSetFunction 1
/*   
     We want full AmigaOS compatibility. When calling obtainsemaphore,
     obtainsemaphoreshared, releasesemaphore, getcc, permit, forbid, 
     enable, disable and getcc *all* Registers need to be preserved.
     But due to the gnu c-compiler we only have to preserve d0,d1,a0,a1.
     UseExecstubs has to be defined when UseRegisterArgs is used!
*/
#if UseRegisterArgs
#undef UseExecstubs
#define UseExecstubs 1
#endif

/* Linux/m68k gcc has no register args capabilities */
#define AROS_COMPILER_NO_REGARGS

/* Information generated by machine.c */
#define AROS_STACK_GROWS_DOWNWARDS 1 /* Stack direction */
#define AROS_BIG_ENDIAN            1 /* Big or little endian */
#define AROS_SIZEOFULONG           4 /* Size of an ULONG */
#define AROS_WORDALIGN             2 /* Alignment for WORD */
#define AROS_LONGALIGN             2 /* Alignment for LONG */
#define AROS_PTRALIGN              2 /* Alignment for PTR */
#define AROS_IPTRALIGN             2 /* Alignment for IPTR */
#define AROS_DOUBLEALIGN           2 /* Alignment for double */
#define AROS_WORSTALIGN            8 /* Worst case alignment */

#define AROS_GET_SYSBASE	extern struct ExecBase * SysBase;
#define AROS_GET_DOSBASE        extern struct DosLibrary * DOSBase;
#define AROS_GET_SYSBASE_OK	extern struct ExecBase * SysBase;

/* do we need a function attribute to get parameters on the stack? */
#define __stackparm

register unsigned char * AROS_GET_SP asm("%sp");

/*
    How much do I have to add to sp to get the address of the first
    byte on the stack?
*/
#define SP_OFFSET 0

/*
    Retain binary compatibility with AmigaOS.
    Comment this out if you want APTRs.
*/
#define AROS_BSTR_TYPE	long
#define AROS_BPTR_TYPE	long
#define MKBADDR(a)	(((LONG)(a)) >> 2)
#define BADDR(a)	((APTR)((ULONG)(a) << 2))

/* For debugging only: Pass errnos from the emulated OS. dos/Fault() will
   recognise them */
#undef PassThroughErrnos
#define PassThroughErrnos 0x40000000

/* Linux/m68k seems to set bit 31 in all memory allocations, so
   default AllocEntry() checking goes wrong. */
#if 0
#define AROS_ALLOCENTRY_FAILED(memType) \
	((struct MemList *)NULL)
#define AROS_CHECK_ALLOCENTRY(memList) \
	((APTR)(memList) != NULL)
#else
/* It works now because of a nice trick :) */
#define AROS_ALLOCENTRY_FAILED(memType) \
	((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
#define AROS_CHECK_ALLOCENTRY(memList) \
	(!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
#endif

/*
    One entry in a libraries' jumptable. For assembler compatibility, the
    field jmp should contain the code for an absolute jmp to a 32bit
    address. There are also a couple of macros which you should use to
    access the vector table from C.
*/
struct JumpVec
{
    unsigned short jmp;
    unsigned char vec[4];
};

/* Internal macros */
#define __AROS_ASMJMP			0x4EF9
#define __AROS_SET_VEC(v,a)             (*(ULONG*)(v)->vec=(ULONG)(a))

#define __AROS_GET_VEC(v)               ((APTR)(*(ULONG*)(v)->vec))

/* Use these to acces a vector table */
#define LIB_VECTSIZE			(sizeof (struct JumpVec))
#define __AROS_GETJUMPVEC(lib,n)        ((struct JumpVec *)(((UBYTE *)lib)-(n*LIB_VECTSIZE)))
#define __AROS_GETVECADDR(lib,n)        (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
#define __AROS_SETVECADDR(lib,n,addr)   (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
#define __AROS_INITVEC(lib,n)           __AROS_GETJUMPVEC(lib,n)->jmp = __AROS_ASMJMP, \
					__AROS_SETVECADDR(lib,n,_aros_not_implemented)

/*
    Find the next valid alignment for a structure if the next x bytes must
    be skipped.
*/
#define AROS_ALIGN(x)        (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)

/* Prototypes */
extern void _aros_not_implemented (char *X);

/* How much stack do we need ? Lots :-) */
#define AROS_STACKSIZE	20000

/* How to map function arguments to CPU registers */

/* The registers */
#define D0 "%d0"
#define D1 "%d1"
#define D2 "%d2"
#define D3 "%d3"
#define D4 "%d4"
#define D5 "%d5"
#define D6 "%d6"
#define D7 "%d7"
#define A0 "%a0"
#define A1 "%a1"
#define A2 "%a2"
#define A3 "%a3"
#define A4 "%a4"
#define A5 "%a5"
#define A6 "%a6"

/* What to do with the library base in header, prototype and call */
#define __AROS_LH_BASE(basetype,basename)   basetype basename
#define __AROS_LP_BASE(basetype,basename)   basetype
#define __AROS_LC_BASE(basetype,basename)   basename
#define __AROS_LD_BASE(basetype,basename)   basetype

/* How to transform an argument in header, prototype and call */
#define __AROS_LHA(type,name,reg)     type name
#define __AROS_LPA(type,name,reg)     type
#define __AROS_LCA(type,name,reg)     name
#define __AROS_LDA(type,name,reg)     type
#define __AROS_UFHA(type,name,reg)    type name
#define __AROS_UFPA(type,name,reg)    type
#define __AROS_UFCA(type,name,reg)    name
#define __AROS_UFDA(type,name,reg)    type
#define __AROS_LHA2(type,name,reg1,reg2)	type name
#define __AROS_LPA2(type,name,reg1,reg2)	type
#define __AROS_LCA2(type,name,reg1,reg2)	name

/* Prefix for library function in header, prototype and call */
#define __AROS_LH_PREFIX    /* eps */
#define __AROS_LP_PREFIX    /* eps */
#define __AROS_LC_PREFIX    /* eps */
#define __AROS_LD_PREFIX    /* eps */
#define __AROS_UFH_PREFIX   /* eps */
#define __AROS_UFP_PREFIX   /* eps */
#define __AROS_UFC_PREFIX   /* eps */
#define __AROS_UFD_PREFIX   /* eps */

/* if this is defined, all AROS_LP*-macros will expand to nothing. */
#define __AROS_USE_MACROS_FOR_LIBCALL

#if UseRegisterArgs
/* We need to redefine all the macros for use with Linux/m68k gcc */

#define AROS_SLIB_ENTRY_S(n,s) #s "_" #n

#define AROS_SLIB_ENTRY_U(n,s) _ ## s ## _ ## n

#define __ASM_PREFIX(name,system) \
    __asm__(".text\n\t.align 2\n\t"\
	".globl "## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
	".type\t"## AROS_SLIB_ENTRY_S(name,system) ##",@function\n"\
	AROS_SLIB_ENTRY_S(name,system) ##":\n\t"\
	"move.l %a6,-(%sp)\n\t"


#define __ASM_PREFIXI(name,system) \
    __asm__(".text\n\t.align 2\n\t"\
	".globl "## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
	".type\t"## AROS_SLIB_ENTRY_S(name,system) ##",@function\n"\
	AROS_SLIB_ENTRY_S(name,system) ##":\n\t"


#define __ASM_ARG(type, name, reg) \
	"move.l "## reg ##",-(%sp)\n\t"

#define __ASM_ARGQUAD1(type, name, reg1, reg2) \
	"move.l "## reg2 ##",-(%sp)\n\t"
#define __ASM_ARGQUAD2(type, name, reg1, reg2) \
	"move.l "## reg1 ##",-(%sp)\n\t"

#ifdef __PIC__
#define __ASM_POSTFIX(type,name,system,argc) \
	"bsr.l _"## AROS_SLIB_ENTRY_S(name,system) ##"@PLTPC\n\t"\
	"add.w #4*" #argc "+4,%sp\n\t"\
	"rts\n\t"\
	".size "## AROS_SLIB_ENTRY_S(name,system) ##",.-"\
	## AROS_SLIB_ENTRY_S(name,system) );\
    __AROS_LH_PREFIX static type AROS_SLIB_ENTRY(name,_##system)(
#else
#define __ASM_POSTFIX(type,name,system,argc) \
	"jbsr _"## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
	"add.w #4*" #argc "+4,%sp\n\t"\
	"rts\n\t"\
	".size "## AROS_SLIB_ENTRY_S(name,system) ##",.-"\
	## AROS_SLIB_ENTRY_S(name,system) );\
    __AROS_LH_PREFIX static type AROS_SLIB_ENTRY(name,_##system)(
#endif

#ifdef __PIC__
#define __ASM_POSTFIXI(type,name,system,argc) \
	"bsr.l _"## AROS_SLIB_ENTRY_S(name,system) ##"@PLTPC\n\t"\
	"add.w #4*" #argc ",%sp\n\t"\
	"rts\n\t"\
	".size "## AROS_SLIB_ENTRY_S(name,system) ##",.-"\
	## AROS_SLIB_ENTRY_S(name,system) );\
    __AROS_LH_PREFIX static type AROS_SLIB_ENTRY(name,_##system)(
#else
#define __ASM_POSTFIXI(type,name,system,argc) \
	"jbsr _"## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
	"add.w #4*" #argc ",%sp\n\t"\
	"rts\n\t"\
	".size "## AROS_SLIB_ENTRY_S(name,system) ##",.-"\
	## AROS_SLIB_ENTRY_S(name,system) );\
    __AROS_LH_PREFIX static type AROS_SLIB_ENTRY(name,_##system)(
#endif

#define AROS_LHDOUBLE1(t,n,a1,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA2(a1),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARGQUAD1(a1)\
    __ASM_ARGQUAD2(a1)\
    __ASM_POSTFIX(t,n,s,2)\
    __AROS_LHA2(a1),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LHDOUBLE2(t,n,a1,a2,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA2(a1),\
    __AROS_LPA2(a2),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARGQUAD1(a2)\
    __ASM_ARGQUAD2(a2)\
    __ASM_ARGQUAD1(a1)\
    __ASM_ARGQUAD2(a1)\
    __ASM_POSTFIX(t,n,s,4)\
    __AROS_LHA2(a1),\
    __AROS_LHA2(a2),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH0(t,n,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_POSTFIX(t,n,s,0)\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH1(t,n,a1,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,1)\
    __AROS_LHA(a1),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH2(t,n,a1,a2,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,2)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH3(t,n,a1,a2,a3,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,3)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH4(t,n,a1,a2,a3,a4,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,4)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,5)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,6)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH7(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,7)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,8)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,9)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,10)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,11)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,12)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12),\
    __AROS_LPA(a13),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,13)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12),\
    __AROS_LHA(a13),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12),\
    __AROS_LPA(a13),\
    __AROS_LPA(a14),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ASM_ARG(a14)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,14)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12),\
    __AROS_LHA(a13),\
    __AROS_LHA(a14),\
    __AROS_LH_BASE(bt,bn))

#define AROS_LH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12),\
    __AROS_LPA(a13),\
    __AROS_LPA(a14),\
    __AROS_LPA(a15),\
    __AROS_LP_BASE(bt,bn)) __attribute__((unused));\
    __ASM_PREFIX(n,s)\
    __ARM_ARG(a15)\
    __ASM_ARG(a14)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX(t,n,s,15)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12),\
    __AROS_LHA(a13),\
    __AROS_LHA(a14),\
    __AROS_LHA(a15),\
    __AROS_LH_BASE(bt,bn))

/* Library functions which don't need the libbase */
#define AROS_LH0I(t,n,bt,bn,o,s) \
    __AROS_LH_PREFIX t AROS_SLIB_ENTRY(n,s)(void)

#define AROS_LH1I(t,n,a1,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,1)\
    __AROS_LHA(a1))

#define AROS_LH2I(t,n,a1,a2,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,2)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2))

#define AROS_LH3I(t,n,a1,a2,a3,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,3)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3))

#define AROS_LH4I(t,n,a1,a2,a3,a4,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,4)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4))

#define AROS_LH5I(t,n,a1,a2,a3,a4,a5,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,5)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5))

#define AROS_LH6I(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,6)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6))

#define AROS_LH7I(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,7)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7))

#define AROS_LH8I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,8)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8))

#define AROS_LH9I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,9)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9))

#define AROS_LH10I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,10)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10))

#define AROS_LH11I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,11)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11))

#define AROS_LH12I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,12)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12))

#define AROS_LH13I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12),\
    __AROS_LPA(a13)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,13)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12),\
    __AROS_LHA(a13))

#define AROS_LH14I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12),\
    __AROS_LPA(a13),\
    __AROS_LPA(a14)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a14)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,14)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12),\
    __AROS_LHA(a13),\
    __AROS_LHA(a14))

#define AROS_LH15I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,bt,bn,o,s) \
    __AROS_LP_PREFIX static t AROS_SLIB_ENTRY_U(n,s)(\
    __AROS_LPA(a1),\
    __AROS_LPA(a2),\
    __AROS_LPA(a3),\
    __AROS_LPA(a4),\
    __AROS_LPA(a5),\
    __AROS_LPA(a6),\
    __AROS_LPA(a7),\
    __AROS_LPA(a8),\
    __AROS_LPA(a9),\
    __AROS_LPA(a10),\
    __AROS_LPA(a11),\
    __AROS_LPA(a12),\
    __AROS_LPA(a13),\
    __AROS_LPA(a14),\
    __AROS_LPA(a15)) __attribute__((unused));\
    __ASM_PREFIXI(n,s)\
    __ASM_ARG(a15)\
    __ASM_ARG(a14)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIXI(t,n,s,15)\
    __AROS_LHA(a1),\
    __AROS_LHA(a2),\
    __AROS_LHA(a3),\
    __AROS_LHA(a4),\
    __AROS_LHA(a5),\
    __AROS_LHA(a6),\
    __AROS_LHA(a7),\
    __AROS_LHA(a8),\
    __AROS_LHA(a9),\
    __AROS_LHA(a10),\
    __AROS_LHA(a11),\
    __AROS_LHA(a12),\
    __AROS_LHA(a13),\
    __AROS_LHA(a14),\
    __AROS_LHA(a15))

/*

    Taken from an old version of AROS:
    This is one way to call a function with registerized parameters and gcc:
    I build a define that defines normal function calls into one of those
    LC0()-Makros for expansion directly into the source code.

    They work as follows:
    First I copy the arguments of the function into normal variables.
    Second I copy those variables into the appropriate registers.
    (I cannot write them directly into those registers because this locks
     the register and one of the arguments may be a function call that needs it.)
    Third I call the assembler function with registers as arguments.
    Fourth I return the result. (The casting of the long is necessary to make
    void work).

    Prototype stylish Macros are also possible (using __inline functions instead
    of defines) but they need more system ressources to compile, more complicated
    Makefiles (gcc cannot inline without optimization) and cannot use local
    library bases.
*/

/****************************************************/
#define __LC0(type,name,basetype,basename,offset,system)  \
({                                                  \
   {						    \
	long _##name##_re;                          \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#offset":W)\n\t"	    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##name##_re)                     \
	    :"g"(basename)			    \
	    :D0,D1,A0,A1,"memory","cc");            \
	(type)_##name##_re;			    \
    }						    \
})

#define __LC1(t,n,t1,n1,r1,bt,bn,o,s)               \
({                                                  \
    t1 _##n##_n1 = (n1);                            \
    {						    \
	long _##n##_re;                             \
	register t1 _n1 __asm(r1) = _##n##_n1;      \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##n##_re)                        \
	    :"g"(bn), "r"(_n1)			    \
	    :A0,A1,D0,D1,"memory","cc");            \
	(t)_##n##_re;				    \
    }						    \
})

#define __LC2(t,name,t1,n1,r1,t2,n2,r2,bt,bn,o,s)   \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    {						    \
	long _##name##_re;                          \
	register t1 _n1 __asm(r1) = _##name##_n1;   \
	register t2 _n2 __asm(r2) = _##name##_n2;   \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##name##_re)                     \
	    :"g"(bn), "r"(_n1), "r"(_n2)	    \
	    :D0,D1,A0,A1,"memory","cc");            \
        (t)_##name##_re;                            \
    }						    \
})

#define __LC3(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,bt,bn,o,s) \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    t3 _##name##_n3 = (n3);                         \
    {						    \
	long _##name##_re;                          \
	register t1 _n1 __asm(r1) = _##name##_n1;   \
	register t2 _n2 __asm(r2) = _##name##_n2;   \
	register t3 _n3 __asm(r3) = _##name##_n3;   \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##name##_re)                     \
	    :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3)  \
	    :A0,A1,D0,D1,"memory","cc");            \
	(t)_##name##_re;			    \
    }						    \
})

#define __LC4(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,bt,bn,o,s) \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    t3 _##name##_n3 = (n3);                         \
    t4 _##name##_n4 = (n4);                         \
    {						    \
	long _##name##_re;                          \
	register t1 _n1 __asm(r1) = _##name##_n1;   \
	register t2 _n2 __asm(r2) = _##name##_n2;   \
	register t3 _n3 __asm(r3) = _##name##_n3;   \
	register t4 _n4 __asm(r4) = _##name##_n4;   \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##name##_re)                     \
	    :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4)				    \
	    :A0,A1,D0,D1,"memory","cc");            \
	(t)_##name##_re;			    \
    }						    \
})

#define __LC5(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,bt,bn,o,s) \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    t3 _##name##_n3 = (n3);                         \
    t4 _##name##_n4 = (n4);                         \
    t5 _##name##_n5 = (n5);                         \
    {						    \
	long _##name##_re;                          \
	register t1 _n1 __asm(r1) = _##name##_n1;   \
	register t2 _n2 __asm(r2) = _##name##_n2;   \
	register t3 _n3 __asm(r3) = _##name##_n3;   \
	register t4 _n4 __asm(r4) = _##name##_n4;   \
	register t5 _n5 __asm(r5) = _##name##_n5;   \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##name##_re)                     \
	    :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4), "r"(_n5)			    \
	    :A0,A1,D0,D1,"memory","cc");            \
	(t)_##name##_re;			    \
    }						    \
})

#define __LC6(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,bt,bn,o,s) \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    t3 _##name##_n3 = (n3);                         \
    t4 _##name##_n4 = (n4);                         \
    t5 _##name##_n5 = (n5);                         \
    t6 _##name##_n6 = (n6);			    \
    {                                               \
        long _##name##_re;                          \
        register t1 _n1 __asm(r1) = _##name##_n1;   \
        register t2 _n2 __asm(r2) = _##name##_n2;   \
        register t3 _n3 __asm(r3) = _##name##_n3;   \
        register t4 _n4 __asm(r4) = _##name##_n4;   \
        register t5 _n5 __asm(r5) = _##name##_n5;   \
        register t6 _n6 __asm(r6) = _##name##_n6;   \
        __asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
            :"=g"(_##name##_re)                     \
            :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4), "r"(_n5), "r"(_n6)	    \
            :A0,A1,D0,D1,"memory","cc");            \
        (t)_##name##_re;                            \
    }                                               \
})

#define __LC7(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,t7,n7,r7,bt,bn,o,s) \
({						    \
    t1 _##name##_n1 = (n1);			    \
    t2 _##name##_n2 = (n2);			    \
    t3 _##name##_n3 = (n3);			    \
    t4 _##name##_n4 = (n4);			    \
    t5 _##name##_n5 = (n5);			    \
    t6 _##name##_n6 = (n6);			    \
    t7 _##name##_n7 = (n7);			    \
    {						    \
	long _##name##_re;	                    \
	register t1 _n1 __asm(r1) = _##name##_n1;   \
	register t2 _n2 __asm(r2) = _##name##_n2;   \
	register t3 _n3 __asm(r3) = _##name##_n3;   \
	register t4 _n4 __asm(r4) = _##name##_n4;   \
	register t5 _n5 __asm(r5) = _##name##_n5;   \
	register t6 _n6 __asm(r6) = _##name##_n6;   \
	register t7 _n7 __asm(r7) = _##name##_n7;   \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##name##_re)			    \
	    :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4), "r"(_n5), "r"(_n6), "r"(_n7) \
	    :A0,A1,D0,D1,"memory","cc");	    \
	(t)_##name##_re;			    \
    }						    \
})

#define __LC8(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,t7,n7,r7,t8,n8,r8,bt,bn,o,s) \
({						    \
    t1 _##name##_n1 = (n1);			    \
    t2 _##name##_n2 = (n2);			    \
    t3 _##name##_n3 = (n3);			    \
    t4 _##name##_n4 = (n4);			    \
    t5 _##name##_n5 = (n5);			    \
    t6 _##name##_n6 = (n6);			    \
    t7 _##name##_n7 = (n7);			    \
    t8 _##name##_n8 = (n8);			    \
    {						    \
	long _##name##_re;			    \
	register t1 _n1 __asm(r1) = _##name##_n1;   \
	register t2 _n2 __asm(r2) = _##name##_n2;   \
	register t3 _n3 __asm(r3) = _##name##_n3;   \
	register t4 _n4 __asm(r4) = _##name##_n4;   \
	register t5 _n5 __asm(r5) = _##name##_n5;   \
	register t6 _n6 __asm(r6) = _##name##_n6;   \
	register t7 _n7 __asm(r7) = _##name##_n7;   \
	register t8 _n8 __asm(r8) = _##name##_n8;   \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "move.l %%d0,%0"			    \
	    :"=g"(_##name##_re)			    \
	    :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4), "r"(_n5), "r"(_n6), "r"(_n7),\
	     "r"(_n8)				    \
	    :A0,A1,D0,D1,"memory","cc");	    \
	(t)_##name##_re;			    \
    }						    \
})

#define __LC9(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,t7,n7,r7,t8,n8,r8,t9,n9,r9,bt,bn,o,s) \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    t3 _##name##_n3 = (n3);                         \
    t4 _##name##_n4 = (n4);                         \
    t5 _##name##_n5 = (n5);                         \
    t6 _##name##_n6 = (n6);                         \
    t7 _##name##_n7 = (n7);                         \
    t8 _##name##_n8 = (n8);                         \
    t9 _##name##_n9 = (n9);                         \
    {                                               \
	long _##name##_re;			    \
        register t1 _n1 __asm(r1) = _##name##_n1;   \
        register t2 _n2 __asm(r2) = _##name##_n2;   \
        register t3 _n3 __asm(r3) = _##name##_n3;   \
        register t4 _n4 __asm(r4) = _##name##_n4;   \
        register t5 _n5 __asm(r5) = _##name##_n5;   \
        register t6 _n6 __asm(r6) = _##name##_n6;   \
        register t7 _n7 __asm(r7) = _##name##_n7;   \
        register t8 _n8 __asm(r8) = _##name##_n8;   \
        register t9 _n9 __asm(r9) = _##name##_n9;   \
        __asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6"		    \
            :"=g"(_##name##_re)			    \
            :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4), "r"(_n5), "r"(_n6), "r"(_n7),\
	     "r"(_n8), "r"(_n9)			    \
            :A0,A1,D0,D1,"memory","cc");            \
	(t)_##name##_re;			    \
    }                                               \
})

#define __LC10(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,t7,n7,r7,t8,n8,r8,t9,n9,r9,t10,n10,r10,bt,bn,o,s) \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    t3 _##name##_n3 = (n3);                         \
    t4 _##name##_n4 = (n4);                         \
    t5 _##name##_n5 = (n5);                         \
    t6 _##name##_n6 = (n6);                         \
    t7 _##name##_n7 = (n7);                         \
    t8 _##name##_n8 = (n8);                         \
    t9 _##name##_n9 = (n9);                         \
    t10 _##name##_n10 = (n10);                      \
    {                                               \
	long _##name##_re;			    \
        register t1 _n1 __asm(r1) = _##name##_n1;   \
        register t2 _n2 __asm(r2) = _##name##_n2;   \
        register t3 _n3 __asm(r3) = _##name##_n3;   \
        register t4 _n4 __asm(r4) = _##name##_n4;   \
        register t5 _n5 __asm(r5) = _##name##_n5;   \
        register t6 _n6 __asm(r6) = _##name##_n6;   \
        register t7 _n7 __asm(r7) = _##name##_n7;   \
        register t8 _n8 __asm(r8) = _##name##_n8;   \
        register t9 _n9 __asm(r9) = _##name##_n9;   \
        register t10 _n10 __asm(r10) = _##name##_n10; \
        __asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6"		    \
            :"=g"(_##name##_re)			    \
            :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4), "r"(_n5), "r"(_n6), "r"(_n7),\
	     "r"(_n8), "r"(_n9), "r"(_n10)	    \
            :A0,A1,D0,D1,"memory","cc");            \
	(t)_##name##_re;			    \
    }                                               \
})

#define __LC11(t,name,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,t7,n7,r7,t8,n8,r8,t9,n9,r9,t10,n10,r10,t11,n11,r11,bt,bn,o,s) \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    t3 _##name##_n3 = (n3);                         \
    t4 _##name##_n4 = (n4);                         \
    t5 _##name##_n5 = (n5);                         \
    t6 _##name##_n6 = (n6);                         \
    t7 _##name##_n7 = (n7);                         \
    t8 _##name##_n8 = (n8);                         \
    t9 _##name##_n9 = (n9);                         \
    t10 _##name##_n10 = (n10);                      \
    t11 _##name##_n11 = (n11);                      \
    {                                               \
	long _##name##_re;			    \
        register t1 _n1 __asm(r1) = _##name##_n1;   \
        register t2 _n2 __asm(r2) = _##name##_n2;   \
        register t3 _n3 __asm(r3) = _##name##_n3;   \
        register t4 _n4 __asm(r4) = _##name##_n4;   \
        register t5 _n5 __asm(r5) = _##name##_n5;   \
        register t6 _n6 __asm(r6) = _##name##_n6;   \
        register t7 _n7 __asm(r7) = _##name##_n7;   \
        register t8 _n8 __asm(r8) = _##name##_n8;   \
        register t9 _n9 __asm(r9) = _##name##_n9;   \
        register t10 _n10 __asm(r10) = _##name##_n10; \
        register t11 _n11 __asm(r11) = _##name##_n11; \
        __asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %1,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6"		    \
            :"=g"(_##name##_re)			    \
            :"g"(bn), "r"(_n1), "r"(_n2), "r"(_n3), \
	     "r"(_n4), "r"(_n5), "r"(_n6), "r"(_n7),\
	     "r"(_n8), "r"(_n9), "r"(_n10),	    \
	     "r"(_n11)				    \
            :A0,A1,D0,D1,"memory","cc");            \
	(t)_##name##_re;			    \
    }                                               \
})

/****************************************************/

#define __LCDOUBLE1(t,n,t1,n1,r11,r12,bt,bn,o,s)      \
({                                                  \
    t1 _##n##_n1 = (n1);                            \
    {						    \
	t _##n##_re;                                \
	register t1 _n1 __asm(r11) = _##n##_n1;     \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %2,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "movem.l %%d0-%%d1,%0\n\t"		    \
	    :"=m"(_##n##_re)                        \
	    :"r"(_n1),"g"(bn)			    \
	    :A0,A1,D0,D1,"memory","cc");            \
	(t)_##n##_re;				    \
    }						    \
})

#define __LCDOUBLE2(t,name,t1,n1,r11,r12,t2,n2,r21,r22,bt,bn,o,s)   \
({                                                  \
    t1 _##name##_n1 = (n1);                         \
    t2 _##name##_n2 = (n2);                         \
    {						    \
	t _##name##_re;                             \
	register t1 _n1 __asm(r11) = _##name##_n1;  \
	register t2 _n2 __asm(r21) = _##name##_n2;  \
	__asm __volatile("move.l %%a6,-(%%sp)\n\t"  \
	    "move.l %3,%%a6\n\t"		    \
	    "jsr %%a6@(-6*"#o":W)\n\t"		    \
	    "move.l (%%sp)+,%%a6\n\t"		    \
	    "movem.l %%d0-%%d1,%0\n\t"		    \
	    :"=m"(_##name##_re)                     \
	    :"r"(_n1),"r"(_n2),"g"(bn)		    \
	    :D0,D1,A0,A1,"memory","cc");            \
        (t)_##name##_re;                            \
    }						    \
})

/****************************************************/
#define AROS_LCDOUBLE1(t,n,a1,bt,bn,o,s)          __LCDOUBLE1(t,n,a1,bt,bn,o,s)
#define AROS_LCDOUBLE2(t,n,a1,a2,bt,bn,o,s)       __LCDOUBLE2(t,n,a1,a2,bt,bn,o,s)

#define AROS_LC0(t,n,bt,bn,o,s)                 __LC0(t,n,bt,bn,o,s)
#define AROS_LC0I(t,n,bt,bn,o,s)                __LC0(t,n,bt,bn,o,s)
#define AROS_LC1(t,n,a1,bt,bn,o,s)              __LC1(t,n,a1,bt,bn,o,s)
#define AROS_LC1I(t,n,a1,bt,bn,o,s)             __LC1(t,n,a1,bt,bn,o,s)
#define AROS_LC2(t,n,a1,a2,bt,bn,o,s)           __LC2(t,n,a1,a2,bt,bn,o,s)
#define AROS_LC2I(t,n,a1,a2,bt,bn,o,s)          __LC2(t,n,a1,a2,bt,bn,o,s)
#define AROS_LC3(t,n,a1,a2,a3,bt,bn,o,s)        __LC3(t,n,a1,a2,a3,bt,bn,o,s)
#define AROS_LC3I(t,n,a1,a2,a3,bt,bn,o,s)       __LC3(t,n,a1,a2,a3,bt,bn,o,s)
#define AROS_LC4(t,n,a1,a2,a3,a4,bt,bn,o,s)     __LC4(t,n,a1,a2,a3,a4,bt,bn,o,s)
#define AROS_LC4I(t,n,a1,a2,a3,a4,bt,bn,o,s)    __LC4(t,n,a1,a2,a3,a4,bt,bn,o,s)
#define AROS_LC5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s)  __LC5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s)
#define AROS_LC5I(t,n,a1,a2,a3,a4,a5,bt,bn,o,s) __LC5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s)
#define AROS_LC6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
	__LC6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s)
#define AROS_LC6I(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
	__LC6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s)
#define AROS_LC7(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s) \
	__LC7(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s)
#define AROS_LC7I(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s) \
	__LC7(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s)
#define AROS_LC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
	__LC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s)
#define AROS_LC8I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
	__LC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s)
#if 0
#define AROS_LC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
	__LC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s)
#define AROS_LC9I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
	__LC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s)
#define AROS_LC10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s) \
	__LC10(t,n,a1,a2,a3,a4,a5,a7,a7,a8,a9,a10,bt,bn,o,s)
#define AROS_LC10I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s) \
	__LC10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s)
#define AROS_LC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s) \
	__LC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s)
#define AROS_LC11I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s) \
	__LC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s)
#endif

#if 1
/* AROS_LC9 and higher just don't work with gcc. gcc complains
   about too many registers being used. So we have to fall back
   to stubs for this kind of calls.
 */
#define AROS_LC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
    n(\
    __AROS_LCA(a1),\
    __AROS_LCA(a2),\
    __AROS_LCA(a3),\
    __AROS_LCA(a4),\
    __AROS_LCA(a5),\
    __AROS_LCA(a6),\
    __AROS_LCA(a7),\
    __AROS_LCA(a8),\
    __AROS_LCA(a9),\
    __AROS_LC_BASE(bt,bn))

#define AROS_LC10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s) \
    n(\
    __AROS_LCA(a1),\
    __AROS_LCA(a2),\
    __AROS_LCA(a3),\
    __AROS_LCA(a4),\
    __AROS_LCA(a5),\
    __AROS_LCA(a6),\
    __AROS_LCA(a7),\
    __AROS_LCA(a8),\
    __AROS_LCA(a9),\
    __AROS_LCA(a10),\
    __AROS_LC_BASE(bt,bn))

#define AROS_LC11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s) \
    n(\
    __AROS_LCA(a1),\
    __AROS_LCA(a2),\
    __AROS_LCA(a3),\
    __AROS_LCA(a4),\
    __AROS_LCA(a5),\
    __AROS_LCA(a6),\
    __AROS_LCA(a7),\
    __AROS_LCA(a8),\
    __AROS_LCA(a9),\
    __AROS_LCA(a10),\
    __AROS_LCA(a11),\
    __AROS_LC_BASE(bt,bn))
#endif

#define AROS_LVO_CALL0(returntype,basetype,basename,offset,system) \
__LC0(returntype,,basetype,basename,offset,system)

#define AROS_LVO_CALL1(t,a1,bt,bn,o,s) \
__LC1(t,,a1,bt,bn,o,s)

#define AROS_LVO_CALL1NR(a1,bt,bn,o,s) \
__LC1(void,,a1,bt,bn,o,s)

#define AROS_LVO_CALL2(t,a1,a2,bt,bn,o,s) \
__LC2(t,,a1,a2,bt,bn,o,s)

#define AROS_LVO_CALL3(t,a1,a2,a3,bt,bn,o,s) \
__LC3(t,,a1,a2,a3,bt,bn,o,s)

#define AROS_LVO_CALL3NR(a1,a2,a3,bt,bn,o,s) \
__LC3(void,,a1,a2,a3,bt,bn,o,s)

#define AROS_LVO_CALL4(t,a1,a2,a3,a4,bt,bn,o,s) \
__LC4(t,,a1,a2,a3,a4,bt,bn,o,s)

/*****************************************************************/

/* Macros for user functions */

#define AROS_UF_ENTRY_U(n) _ ## n

#define __ASM_PREFIX_U(name) \
    __asm__(".text\n\t.align 2\n"\
	".globl " #name "\n\t"\
	".type\t" #name ",@function\n"\
	#name ":\n\t"\

#define __ASM_PREFIX_US(name) \
    __asm__(".text\n\t.align 2\n\t"\
	".type\t" #name ",@function\n"\
	#name ":\n\t"\

#ifdef __PIC__
#define __ASM_POSTFIX_U(type,name,argc) \
	"bsr.l _" #name "@PLTPC\n\t"\
	"add.w #4*" #argc ",%sp\n\t"\
	"rts\n\t"\
	".size " #name ",.-" #name);\
    __AROS_UFH_PREFIX static type _##name (
#else
#define __ASM_POSTFIX_U(type,name,argc) \
	"jbsr _" #name "\n\t"\
	"add.w #4*" #argc ",%sp\n\t"\
	"rts\n\t"\
	".size " #name ",.-" #name);\
    __AROS_UFH_PREFIX static type _##name (
#endif

/* Function headers for user functions */

#define AROS_UFH0(t,n) \
    t n (void)

#define AROS_UFH1(t,n,a1) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,1)\
    __AROS_UFHA(a1))

#define AROS_UFH2(t,n,a1,a2) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,2)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2))

#define AROS_UFH3(t,n,a1,a2,a3) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,3)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3))

#define AROS_UFH3S(t,n,a1,a2,a3) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3)) __attribute__((unused));\
    __ASM_PREFIX_US(n)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,3)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3))

#define AROS_UFH4(t,n,a1,a2,a3,a4) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,4)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4))

#define AROS_UFH5(t,n,a1,a2,a3,a4,a5) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,5)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5))

#define AROS_UFH5S(t,n,a1,a2,a3,a4,a5) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5)) __attribute__((unused));\
    __ASM_PREFIX_US(n)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,5)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5))

#define AROS_UFH6(t,n,a1,a2,a3,a4,a5,a6) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,6)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6))

#define AROS_UFH7(t,n,a1,a2,a3,a4,a5,a6,a7) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,7)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7))

#define AROS_UFH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,8)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8))

#define AROS_UFH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8),\
    __AROS_UFPA(a9)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,9)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8),\
    __AROS_UFHA(a9))

#define AROS_UFH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8),\
    __AROS_UFPA(a9),\
    __AROS_UFPA(a10)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,10)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8),\
    __AROS_UFHA(a9),\
    __AROS_UFHA(a10))

#define AROS_UFH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8),\
    __AROS_UFPA(a9),\
    __AROS_UFPA(a10),\
    __AROS_UFPA(a11)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,11)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8),\
    __AROS_UFHA(a9),\
    __AROS_UFHA(a10),\
    __AROS_UFHA(a11))

#define AROS_UFH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8),\
    __AROS_UFPA(a9),\
    __AROS_UFPA(a10),\
    __AROS_UFPA(a11),\
    __AROS_UFPA(a12)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,12)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8),\
    __AROS_UFHA(a9),\
    __AROS_UFHA(a10),\
    __AROS_UFHA(a11),\
    __AROS_UFHA(a12))

#define AROS_UFH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8),\
    __AROS_UFPA(a9),\
    __AROS_UFPA(a10),\
    __AROS_UFPA(a11),\
    __AROS_UFPA(a12),\
    __AROS_UFPA(a13)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,13)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8),\
    __AROS_UFHA(a9),\
    __AROS_UFHA(a10),\
    __AROS_UFHA(a11),\
    __AROS_UFHA(a12),\
    __AROS_UFHA(a13))

#define AROS_UFH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8),\
    __AROS_UFPA(a9),\
    __AROS_UFPA(a10),\
    __AROS_UFPA(a11),\
    __AROS_UFPA(a12),\
    __AROS_UFPA(a13),\
    __AROS_UFPA(a14)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a14)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,14)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8),\
    __AROS_UFHA(a9),\
    __AROS_UFHA(a10),\
    __AROS_UFHA(a11),\
    __AROS_UFHA(a12),\
    __AROS_UFHA(a13),\
    __AROS_UFHA(a14))

#define AROS_UFH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
    t n ();\
    __AROS_UFP_PREFIX static t AROS_UF_ENTRY_U(n)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3),\
    __AROS_UFPA(a4),\
    __AROS_UFPA(a5),\
    __AROS_UFPA(a6),\
    __AROS_UFPA(a7),\
    __AROS_UFPA(a8),\
    __AROS_UFPA(a9),\
    __AROS_UFPA(a10),\
    __AROS_UFPA(a11),\
    __AROS_UFPA(a12),\
    __AROS_UFPA(a13),\
    __AROS_UFPA(a14),\
    __AROS_UFPA(a15)) __attribute__((unused));\
    __ASM_PREFIX_U(n)\
    __ASM_ARG(a15)\
    __ASM_ARG(a14)\
    __ASM_ARG(a13)\
    __ASM_ARG(a12)\
    __ASM_ARG(a11)\
    __ASM_ARG(a10)\
    __ASM_ARG(a9)\
    __ASM_ARG(a8)\
    __ASM_ARG(a7)\
    __ASM_ARG(a6)\
    __ASM_ARG(a5)\
    __ASM_ARG(a4)\
    __ASM_ARG(a3)\
    __ASM_ARG(a2)\
    __ASM_ARG(a1)\
    __ASM_POSTFIX_U(t,n,15)\
    __AROS_UFHA(a1),\
    __AROS_UFHA(a2),\
    __AROS_UFHA(a3),\
    __AROS_UFHA(a4),\
    __AROS_UFHA(a5),\
    __AROS_UFHA(a6),\
    __AROS_UFHA(a7),\
    __AROS_UFHA(a8),\
    __AROS_UFHA(a9),\
    __AROS_UFHA(a10),\
    __AROS_UFHA(a11),\
    __AROS_UFHA(a12),\
    __AROS_UFHA(a13),\
    __AROS_UFHA(a14),\
    __AROS_UFHA(a15))

/* Call a user function */

#define AROS_UFC0(t,n) \
    (((__AROS_UFC_PREFIX t(*)(void))n)())
#define __UFC1(t,n,t1,n1,r1) \
({\
    long _n1 = (long)(n1);\
    long _re;\
    __asm__ __volatile__(\
	"move.l	%%a5,-(%%sp)\n\t"\
	"move.l %%a6,-(%%sp)\n\t"\
	"move.l	%2,%"##r1##"\n\t"\
	"jsr	(%1)\n\t"\
	"move.l (%%sp)+,%%a6\n\t"\
	"move.l (%%sp)+,%%a5\n\t"\
	"move.l	%%d0,%0"\
	:"=g"(_re)\
	:"ad"(n),"g"(_n1)\
	:A0,A1,D0,D1,r1,"cc","memory");\
    (t)_re;\
})
#define AROS_UFC1(t,n,a1)       __UFC1(t,n,a1)
#define __UFC2(t,n,t1,n1,r1,t2,n2,r2) \
({\
    long _n1 = (long)(n1);\
    long _n2 = (long)(n2);\
    long _re;\
    __asm__ __volatile__(\
	"move.l %%a5,-(%%sp)\n\t"\
	"move.l	%%a6,-(%%sp)\n\t"\
        "move.l %2,%"##r1##"\n\t"\
	"move.l %3,%"##r2##"\n\t"\
        "jsr    (%1)\n\t"\
	"move.l (%%sp)+,%%a6\n\t"\
        "move.l (%%sp)+,%%a5\n\t"\
	"move.l %%d0,%0"\
        :"=g"(_re)\
	:"ad"(n),"g"(_n1),"g"(_n2)\
        :A0,A1,D0,D1,r1,r2,"cc","memory");\
    (t)_re;\
})
#define AROS_UFC2(t,n,a1,a2)    __UFC2(t,n,a1,a2)
#define __UFC3(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3) \
({\
    long _n1 = (long)(n1);\
    long _n2 = (long)(n2);\
    long _n3 = (long)(n3);\
    long _re;\
    __asm__ __volatile__(\
        "move.l %%a5,-(%%sp)\n\t"\
	"move.l %%a6,-(%%sp)\n\t"\
        "move.l %2,%"##r1##"\n\t"\
        "move.l %3,%"##r2##"\n\t"\
	"move.l %4,%"##r3##"\n\t"\
        "jsr    (%1)\n\t"\
        "move.l (%%sp)+,%%a6\n\t"\
	"move.l (%%sp)+,%%a5\n\t"\
	"move.l %%d0,%0"\
        :"=g"(_re)\
        :"ad"(n),"g"(_n1),"g"(_n2),"g"(_n3)\
        :A0,A1,D0,D1,r1,r2,r3,"cc","memory");\
    (t)_re;\
})
#define AROS_UFC3(t,n,a1,a2,a3) __UFC3(t,n,a1,a2,a3)
#define __UFC3R(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,p,ss) \
({\
    long _n1 = (long)(n1);\
    long _n2 = (long)(n2);\
    long _n3 = (long)(n3);\
    long _re;\
    __asm__ __volatile__(\
	"movem.l %%d2-%%d7/%%a2-%%a6,-(%%sp)\n\t"\
        "move.l %3,%"##r1##"\n\t"\
        "move.l %4,%"##r2##"\n\t"\
        "move.l %5,%"##r3##"\n\t"\
	"move.l %%sp,-(%%sp)\n\t"\
	"move.l %6,-(%%sp)\n\t"\
	"move.l %%sp,%1\n\t"\
        "jsr    (%2)\n\t"\
	"movea.l 4(%%sp),%%sp\n\t"\
	"movem.l (%%sp)+,%%d2-%%d7/%%a2-%%a6\n\t"\
        "move.l %%d0,%0"\
        :"=g"(_re),"=m"(*(APTR *)p)\
        :"ad"(n),"g"(_n1),"g"(_n2),"g"(_n3),"g"(ss)\
        :A0,A1,D0,D1,r1,r2,r3,"cc","memory");\
    (t)_re;\
})
#define AROS_UFC3R(t,n,a1,a2,a3,p,ss) __UFC3R(t,n,a1,a2,a3,p,ss)
#define __UFC4(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4) \
({\
    long _n1 = (long)(n1);\
    long _n2 = (long)(n2);\
    long _n3 = (long)(n3);\
    long _n4 = (long)(n4);\
    long _re;\
    __asm__ __volatile__(\
        "move.l %%a5,-(%%sp)\n\t"\
	"move.l %%a6,-(%%sp)\n\t"\
        "move.l %2,%"##r1##"\n\t"\
        "move.l %3,%"##r2##"\n\t"\
        "move.l %4,%"##r3##"\n\t"\
	"move.l %5,%"##r4##"\n\t"\
        "jsr    (%1)\n\t"\
        "move.l (%%sp)+,%%a6\n\t"\
	"move.l (%%sp)+,%%a5\n\t"\
	"move.l %%d0,%0"\
        :"=g"(_re)\
        :"ad"(n),"g"(_n1),"g"(_n2),"g"(_n3),\
	 "g"(_n4)\
        :A0,A1,D0,D1,r1,r2,r3,r4,"cc","memory");\
    (t)_re;\
})
#define AROS_UFC4(t,n,a1,a2,a3,a4) __UFC4(t,n,a1,a2,a3,a4)
#define __UFC5(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5) \
({\
    long _n1 = (long)(n1);\
    long _n2 = (long)(n2);\
    long _n3 = (long)(n3);\
    long _n4 = (long)(n4);\
    long _n5 = (long)(n5);\
    long _re;\
    __asm__ __volatile__(\
        "move.l %%a5,-(%%sp)\n\t"\
	"move.l %%a6,-(%%sp)\n\t"\
        "move.l %2,%"##r1##"\n\t"\
        "move.l %3,%"##r2##"\n\t"\
        "move.l %4,%"##r3##"\n\t"\
        "move.l %5,%"##r4##"\n\t"\
	"move.l %6,%"##r5##"\n\t"\
        "jsr    (%1)\n\t"\
        "move.l (%%sp)+,%%a6\n\t"\
	"move.l (%%sp)+,%%a5\n\t"\
	"move.l %%d0,%0"\
        :"=g"(_re)\
        :"ad"(n),"g"(_n1),"g"(_n2),"g"(_n3),\
         "g"(_n4),"g"(_n5)\
        :A0,A1,D0,D1,r1,r2,r3,r4,r5,"cc","memory");\
    (t)_re;\
})
#define AROS_UFC5(t,n,a1,a2,a3,a4,a5) __UFC5(t,n,a1,a2,a3,a4,a5)

#else /* UseRegisterArgs */

#define AROS_UFC3R(t,n,a1,a2,a3,p,ss) \
    (((__AROS_UFC_PREFIX t(*)(\
    __AROS_UFPA(a1),\
    __AROS_UFPA(a2),\
    __AROS_UFPA(a3)\
    ))n)(\
    __AROS_UFCA(a1),\
    __AROS_UFCA(a2),\
    __AROS_UFCA(a3)\
    ))

#endif /* UseRegisterArgs */

#endif /* AROS_MACHINE_H */
