sync.h 1.78 KB

/*************************************************************************
 *
 *  File: sync.h
 *
 *  Header file for the synchronization module.
 *
 *  $Header: /root/leakn64/depot/rf/sw/bbplayer/iosim/src/sync.h,v 1.2 2002/05/30 05:52:53 whs Exp $
 *
 */


#ifndef _SYNC_H_
#define _SYNC_H_

#ifdef __sgi__
#include <ulocks.h>


/**********************************************************************
 * Common definitions
 */
/*
 * IDs for different locks
 */
#define	MAX_LOCK		8
#define SYS_LOCK_ID		0
#define LOG_LOCK_ID		(SYS_LOCK_ID+1)
#define PI_LOCK_ID		(LOG_LOCK_ID+1)
#define SI_LOCK_ID		(PI_LOCK_ID+1)
#define AI_LOCK_ID		(SI_LOCK_ID+1)
#define VI_LOCK_ID		(AI_LOCK_ID+1)
#define SP_LOCK_ID		(VI_LOCK_ID+1)
#define DPC_LOCK_ID		(SP_LOCK_ID+1)

#define SYS_LOCK		SyncLock[SYS_LOCK_ID]
#define LOG_LOCK		SyncLock[LOG_LOCK_ID]
#define PI_LOCK			SyncLock[PI_LOCK_ID]
#define SI_LOCK			SyncLock[SI_LOCK_ID]
#define AI_LOCK			SyncLock[AI_LOCK_ID]
#define VI_LOCK			SyncLock[VI_LOCK_ID]
#define SP_LOCK			SyncLock[SP_LOCK_ID]
#define DPC_LOCK		SyncLock[DPC_LOCK_ID]


/* Redefine fprintf to use the locking LogPrintf so that it would work in
 * both multi-threaded and single-threaded environment
 */
#define	fprintf	LogPrintf


/**********************************************************************
 * Macro definitions
 */


/***********************************************************************
 * External definitions
 */
extern usptr_t *SyncArena;
extern ulock_t SyncLock[];


/***********************************************************************
 * External declartions
 */
extern	int	LockSet(ulock_t);
extern	int	LockReset(ulock_t);
extern	void	SysLockSet(void);
extern	void	SysLockReset(void);
extern	void	SyncInit(void);

#endif
extern	int	LogPrintf(FILE *, const char *, ... );


#endif  /* _SYNC_H_ */