#ifndef _MACHINE_H_
#define _MACHINE_H_

#include <exec/types.h>
#include <stddef.h>

#ifdef mc68000

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

/*
 * Define this to either 1 or 0. The advantage of this single define over
 * one define for each choice is that the compiler groks about a missing
 * define.
 */
#define STACK_GROWS_DOWNWARS 1

/* Define this to 0 for low endian and 1 for high endian (2 for others?) */
#define HIGH_ENDIAN 1

#ifdef __GNUC__

/* Try to avoid linking with special 32 bit code */
#define UDIVMOD10(v,q,r)        \
{ asm("movel %2,%0   ;"         \
      "clrw  %0      ;"         \
      "swap  %0      ;"         \
      "divu  #10:W,%0;"         \
      "movel %0,%1   ;"         \
      "movew %2,%1   ;"         \
      "swap  %0      ;"         \
      "divu  #10:W,%1;"         \
      "movew %1,%0   ;"         \
      "clrw  %1      ;"         \
      "swap  %1      ;"         \
      :"=&d"(q),"=&d"(r):"r"(v) \
    );				\
}

#endif
#endif

#ifdef i386
#define SP_OFFSET 0
#define STACK_GROWS_DOWNWARDS 1
#define BIG_ENDIAN 0
#define RDFCALL(hook,data,dptr) ((void(*)(UBYTE,APTR))(hook))(data,dptr);
#endif


#ifndef UDIVMOD10
#define UDIVMOD10(v,q,r) { ULONG a=v; q=a/10ul; r=a%10ul; }
#endif

#include <exec/libraries.h>
#undef LIBVECTSIZE
#define LIBVECTSIZE sizeof(struct JumpVec)

struct _longalign
{
    char dummy;
    LONG offset;
};

#define LONGALIGN	offsetof(struct _longalign,offset)

struct _wordalign
{
    char dummy;
    WORD offset;
};

#define WORDALIGN	offsetof(struct _wordalign,offset)

struct _ptralign
{
    char dummy;
    APTR offset;
};

#define PTRALIGN	offsetof(struct _ptralign,offset)

#define LIBALIGN	(DOUBLEALIGN>sizeof(long)?DOUBLEALIGN:sizeof(long))

#endif
