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

#ifndef _MUTEX_H_
#define _MUTEX_H_

/* This data structure is used to implement mutual exclusion among (up
   to four) independent processors, based on the generalized Decker's
   algorithm. */

typedef struct {			/* mutual exclusion flag */
	union {
	  unsigned long l;
	  unsigned char p[4]; } need;
	long check;
} MUTEX;

/* The magic number has been put in so that we can verify the structure
   is a real mutex and avoid infinite loops.
*/

#define MUTEX_MAGIC	0x87654321

#define MUTEX_CLEAR(m)	((m)->need.l = 0, (m)->check = MUTEX_MAGIC)
#define MUTEX_VALID(m)	((m)->check == MUTEX_MAGIC)

#endif
