/*

$VER: initializers.h 41.2 (26.7.2001)
Copyright (C) 2000,2001 Neil Cafferkey

This file is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this file; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.

*/

#ifndef EXEC_INITIALIZERS_H
#define EXEC_INITIALIZERS_H

#include <exec/types.h>


/* Use the OFFSET macro as the offset parameter of one of the other
   macros */
/*
#ifdef OFFSET
#undef OFFSET
#endif
*/
#define OFFSET(struct_name,struct_field) \
   ((ULONG)(&(((struct struct_name *)0)->struct_field)))

/* Use the following macros in the structure definition */

#define INITBYTEDEF(name) \
   ULONG name ## _c_o; UBYTE name ## _v; UBYTE name ## _p
#define INITWORDDEF(name) ULONG name ## _c_o; UWORD name ## _v
#define INITLONGDEF(name) ULONG name ## _c_o; ULONG name ## _v
#define INITPINTDEF(name) ULONG name ## _c_o; UPINT name ## _v

#define SMALLINITBYTEDEF(name) \
   UWORD name ## _c_o; UBYTE name ## _v; UBYTE name ## _p
#define SMALLINITWORDDEF(name) UWORD name ## _c_o; UWORD name ## _v
#define SMALLINITLONGDEF(name) UWORD name ## _c_o; ULONG name ## _v
#define SMALLINITPINTDEF(name) UWORD name ## _c_o; UPINT name ## _v

#define INITENDDEF UBYTE the_end

/* Use the following macros to fill in a structure */

#define NEWINITBYTE(offset,value) \
   (0xe0000000|(offset)),(UBYTE)(value),0
#define NEWINITWORD(offset,value) \
   (0xd0000000|(offset)),(UWORD)(value)
#define NEWINITLONG(offset,value) \
   (0xc0000000|(offset)),(ULONG)(value)
#define INITPINT(offset,value) \
   (0xc0000000|(offset)),(UPINT)(value)

#define SMALLINITBYTE(offset,value) \
   0xa000|(offset),(UBYTE)(value),0
#define SMALLINITWORD(offset,value) \
   0x9000|(offset),(UWORD)(value)
#define SMALLINITLONG(offset,value) \
   0x8000|(offset),(ULONG)(value)
#define SMALLINITPINT(offset,value) \
   0x8000|(offset),(UPINT)(value)

#define INITEND 0

/* Obsolete definitions */

#define INITBYTE(offset,value) \
   (0xe000|((UWORD)(offset)>>16)),(UWORD)(offset),(UWORD)((value)<<8)
#define INITWORD(offset,value) \
   (0xd000|((UWORD)(offset)>>16)),(UWORD)(offset),(UWORD)(value)
#define INITLONG(offset,value) \
   (0xc000|((UWORD)(offset)>>16)),(UWORD)(offset),(UWORD)((value)>>16), \
   (UWORD)(value)
#define INITAPTR(offset,value) \
   (0xc000|((UWORD)(offset)>>16)),(UWORD)(offset), \
   (UWORD)((ULONG)(value)>>16),(UWORD)(value)

#if 0
#define SMALLINITBYTE(offset,value) \
   0xa000|(offset),(UWORD)((value)<<8)
#define SMALLINITWORD(offset,value) \
   0x9000|(offset),(UWORD)(value)
#define SMALLINITLONG(offset,value) \
   0x8000|(offset),(UWORD)((value)>>16),(UWORD)(value)
#define SMALLINITAPTR(offset,value) \
   0x8000|(offset),(UWORD)((value)>>16),(UWORD)(value)
#endif

#endif
