/* 
 * $RCSfile: platform.h,v $
 *
 * x-kernel v3.3
 *
 * Copyright (c) 1993,1991,1990,1996  Arizona Board of Regents
 *
 * HISTORY
 * $Log: platform.h,v $
 * Revision 1.5  1996/06/14 23:59:34  slm
 * Merged in brakmo's changes.
 *
 * Revision 1.4  1996/06/03  22:46:11  slm
 * Changed msg_s.h to msg_p.h.
 *
 * Revision 1.3  1996/02/01  15:22:05  slm
 * Updated copyright and version.
 *
 * Revision 1.2  1995/08/28  16:15:25  acb
 * Initial revision for x3.3
 *
 * Revision 1.2  1994/11/22  21:22:22  hkaram
 * Added FORCE_LASTCALL; and xRealloc decl
 *
 * Revision 1.1  1994/10/26  20:45:44  hkaram
 * Initial revision
 */

/*
 * "Solaris" (simulator) version of platform.h
 */

#ifndef platform_h
#define platform_h

#include "pthread.h"

#include "xk_arch.h"
#include "xk_debug.h"

#if defined(__GNUC__) && ! defined(XK_DEBUG)
#  define XK_USE_INLINE
#endif

/* #include <sys/types.h> */
/* #include "signal.h" */
#include <netinet/in.h>
#include <malloc.h>
#include <alloca.h>
#include <limits.h>
#include "process.h"
#include "msg_p.h"
#include "xtype.h"
#include "x_libc.h"

#ifdef __STDC__

u_short ocsum( u_short *buf, int count );
u_short ocsum_simple( u_short *buf, int count );
u_short inCkSum( Msg *m, u_short *buf, int len );
char *	inet_ntoa( struct in_addr );

extern	char *	xMalloc( unsigned );
extern	void	xFree( char * );
extern	void	xMallocInit( void );
extern	char *	xRealloc( char *, unsigned );

#else

extern	char *	xMalloc( );
extern	void	xFree();
extern	void	xMallocInit();
extern	char *	xRealloc( );

#endif


typedef long *Unspec;
typedef unsigned long ProcessId;
typedef unsigned long ContextId;

#ifndef NULL
#define NULL	0
#endif
#define MAXUNSIGNED	((unsigned) (-1)

#define splx(x)
#define spl7() 1
#define splnet spl7
#define splclk spl7

#define INIT_STACK_SIZE 1024

#define BYTES_PER_WORD	4

#ifndef ENDIAN
/*
 * Definitions for byte order,
 * according to byte significance from low address to high.
 */
#define	LITTLE	1234		/* least-significant byte first (vax) */
#define	BIG	4321		/* most-significant byte first */
#define	PDP	3412		/* LSB first in word, MSW first in long (pdp) */
#if defined(vax) || defined(pmax) || defined(mips)
#define	ENDIAN	LITTLE
#else
#define	ENDIAN	BIG		/* byte order on mc68000, tahoe, most others */
#endif
#endif /* ENDIAN */

#define CLICKS_PER_SEC 100	/* Clock interrupts per second */

#if !defined(ROUND4)
#define ROUND4(len)  ((len + 3) & ~3)
#endif
#define BETWEEN(A,B,C) ((A) <= (B) && (B) < (C))

typedef	char	*mapKeyPtr_t;
typedef	int	mapVal_t;

typedef char	*statePtr_t;

#ifndef	TRUE
#define	TRUE	1
#define FALSE	0
#endif

#ifdef __PREDICTIONS__
# define PREDICT_FALSE  @0
# define PREDICT_TRUE   @1
#else
# define PREDICT_FALSE
# define PREDICT_TRUE
#endif

#ifdef __LASTCALL__
# define FORCE_LASTCALL	!
#else
# define FORCE_LASTCALL
#endif

#define	SUCCESS_RET_VAL		0
#define	FAILURE_RET_VAL		(-1)

#define	LO_BYTE_OF_2(word)	 ((u_char) (0xff & (unsigned) word))
#define HI_BYTE_OF_2(word)	 ((u_char) (((unsigned) word) >> 8 ))
#define CAT_BYTES(hiByte,loByte) ((((unsigned)hiByte)<<8) + (unsigned)loByte)

/* 
 * LONG_ALIGNMENT_REQUIRED indicates that int's must be 32-bit aligned
 * on this architecture.
 */
#define LONG_ALIGNMENT_REQUIRED
#define LONG_ALIGNED( address )  (! ((int)(address) & 0x3))
#define SHORT_ALIGNED( address ) ( ! ((int)(address) & 0x1))

#define XK_ALIGNED(a,t)	(((unsigned long)(a) & (sizeof(t) - 1)) == 0)
#define XK_ROUNDUP(v,t)	(((v) + sizeof(t) - 1) & ~(sizeof(t) - 1))

#define ROM_MAX_LINES 	100 	/* Up to 100 table entries */
#define ROM_MAX_FIELDS 	20

extern	char *rom[ROM_MAX_LINES + 1][ROM_MAX_FIELDS + 1];  

# ifdef __STDC__
    typedef void    *PTR;
# else
    typedef char    *PTR;  
# endif


#endif
