/*
    Copyright (C) 1995-2016, The AROS Development Team. All rights reserved.

    Desc: Macros to make calling ARexx library querying functions portable
*/

#ifndef REXX_REXXCALL_H
#define REXX_REXXCALL_H

#include <exec/types.h>

#ifdef __mc68000

#include <rexx/rexxcall-m68k.h>

#else

/* Some macros to make ARexx portable to non-m68k platforms */
#define RexxCallQueryLibFunc(rexxmsg, libbase, offset, retargstringptr) \
  ({ \
    int _offset=abs(offset)/6; \
    AROS_LVO_CALL2(ULONG, \
	       AROS_LCA(struct RexxMsg *, rexxmsg, A0), \
	       AROS_LCA(STRPTR *, retargstringptr, A1), \
	       struct Library *, libbase, _offset, rexxcall); \
  })

#define AROS_AREXXLIBQUERYFUNC(f,m,lt,l,o,p) \
  AROS_LH2(ULONG, f, \
	     AROS_LHA(struct RexxMsg *, m, A0), \
	     AROS_LHA(STRPTR *, _retargstringptr, A1), \
	     lt, l, o, p) { AROS_LIBFUNC_INIT
#define AROS_AREXXLIBQUERYFUNC_END \
    AROS_LIBFUNC_EXIT }

#define ReturnRexxQuery(rc,arg) \
  ({ *_retargstringptr = arg; \
     return rc; \
  })

#endif
#endif
