#ifndef AROS_LVO_H
#define AROS_LVO_H
/* (C) 1995 AROS - The Amiga Replacement OS */

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

    MODUL
	$Id: lvo.h 1.1 1995/11/05 22:30:57 digulla Exp digulla $

    DESCRIPTION
	Here we declare a couple of macros and types to work with LVOs
	when your C compiler doesn't support them directly.

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

/**************************************
		Includes
**************************************/
#ifndef EXEC_TYPES_H
#   include <exec/types.h>
#endif


/**************************************
		Defines
**************************************/
#define M68k_JMP	0x4EB9L   /* The opcode for the 68k JMP instruction */

/* This structure definies an LVO */
typedef struct {
    UWORD lve_Jmp;	    /* always M68k_JMP */
    APTR  lve_FuncPtr;	    /* This is the pointer to the function
				that is to be called */
} LVEntry;

/* This macro calculates the address of an LVO in the table before the
    library base */
#define __AROS_LVO_GET(lib,offset) \
    (((LVEntry *)(lib))-(offset))

/* This macro returns the address of a function at the given offset */
#define __AROS_LVO_GET_FUNC(lib,offset) \
    (__AROS_LVO_GET(lib,offset)->lve_FuncPtr)

/* This macro is the first part of a sequence to call a function with
    an LVO. Use it like this:


	#define AddHead(l,n)    __AROS_LVO_CALL(ExecBase,40,\
		    (void (* __asm)(struct ExecBase *, struct List *,
			struct Node *))) \
		    (SysBase,l,n)

    This way, the C compiler does type checking and conversion if
    neccessary and it still uses the LVO to call the function.
*/
#define __AROS_LVO_CALL(lib,offset,type) \
    ((type)__AROS_LVO_GET_FUNC((struct Library *)lib,offset))


/******************************************************************************
*****  END aros/lvo.h
******************************************************************************/

#endif /* AROS_LVO_H */
