#ifndef _ALLOCMEM_H_
#define _ALLOCMEM_H_

/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1991 by John E. Lloyd.				    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

/*---------------------------------------------------------------------------
 *
 * DESCRIPTION:	Definitons for the RCI allocMem() package.
 * 
 * AUTHOR/DATE:	John Lloyd, Fall 1988
 *
 * MODIFICATION HISTORY:
 *
 *--------------------------------------------------------------------------*/

#include "../h/cdefs.h"
#include "../h/mutex.h"

#define MEM_POOL_SIZE	0x10000		/* size of memory allocation pool */

#define ALLOC_MEM(n,type,pool)  ((type*)allocMem(n,sizeof(type),pool))

typedef struct _MEM_HEADER {
	/* Header information attached to every mem object (but
	   hidden from view). Used internally by the system. */

	  char *name;
	  MUTEX mutex;
	  int size;	  
	  int cpu;
} MEM_HEADER;

/* Compatibility definitions for the old 'object' package */

#define allocObject(n,s,p)	allocMem(n,s,p)
#define freeObject(o)		freeMem(o)
#define findObject(a)		getMemByAddr(a)
#define getObject(n)		getMemByName(n)
#define readObject(o,b)		readMem(o,b)
#define writeObject(o,b)	writeMem(o,b)
#define accessObject(o,f,t,s)	accessMem(o,f,t,s)
#define getObjectName(o)	getMemName(o)
#define ALLOC_OBJECT(n,t,p)	ALLOC_MEM(n,t,p)

#ifndef PROTO
#ifndef NO_PROTOTYPES
#define PROTO(x) x
#else
#define PROTO(x) ()
#endif
#endif

extern void *allocMem PROTO((const char*, int, int));
extern freeMem PROTO((void*));
extern void *getMemByName PROTO((const char*));
extern void *getMemByAddr PROTO((void*));
extern readMem PROTO((void*, void*));
extern writeMem PROTO((void*, void*));
extern accessMem PROTO((void*, void*, void*, int));
extern char *getMemName PROTO((void*));
extern lockMem PROTO((void*));
extern unlockMem PROTO((void*));

#endif
