#ifndef MPLIB1_BPO_LOCK #define MPLIB1_BPO_LOCK /* ******************************************************************************* * Copyright (c) 1996 Martin Poole * ******************************************************************************* ** ** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! ** ** Any changes to be made to this file should first be checked with ** mplib1 source control for library integrity. ** ** mplib1 source control can be reached at mplib1@quatermass.co.uk ** * * $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/mplib1/bpo_lock.h,v $ * $Author: mpoole $ * $Date: 2002/10/07 09:37:44 $ * $Revision: 1.2 $ * ******************************************************************************* * * Change History * * $Log: bpo_lock.h,v $ * Revision 1.2 2002/10/07 09:37:44 mpoole * Initial checkin of mplib1-3.1.0 * * Revision 1.1 2002/10/07 09:36:59 mpoole * Initial checkin of mplib1-3.1.0 * * ******************************************************************************* */ #ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/mplib1/bpo_lock.h,v 1.2 2002/10/07 09:37:44 mpoole Exp $" /* #ifdef CXREF */ #include /* #endif */ #ifndef MPLIB1_CONFIG #include #endif /* ------------------------------------------------------------------ defines ------------------------------------------------------------------ */ enum bpo_lock_mode { BPO_L_READ, BPO_L_WRITE }; #ifndef BIT #define BIT(n) (1<<(n)) #endif #define BPO_PID_F_DEBUG BIT(0) /* ------------------------------------------------------------------ structures ------------------------------------------------------------------ */ /* Only one of the following ifdef blocks should be enabled */ #ifdef HAVE_LWP_MUTEX #define BPO_LOCK_MECH_DEFINED #include typedef lwp_mutex_t b_lock_t; #ifndef STRICT typedef lwp_mutex_t b_lock; #endif #endif #ifdef HAVE_PTHREADS #define BPO_LOCK_MECH_DEFINED #include struct bpo_thread_lock { pthread_mutex_t mp; pthread_mutexattr_t mattr; }; typedef struct bpo_thread_lock b_lock_t; #ifndef STRICT typedef struct bpo_thread_lock b_lock; #endif #endif #ifdef HAVE_MSEM #define BPO_LOCK_MECH_DEFINED #include typedef msemaphore b_lock_t; #ifndef STRICT typedef msemaphore b_lock; #endif #endif #ifdef HAVE_MUTEX #define BPO_LOCK_MECH_DEFINED #include typedef abilock_t b_lock_t; #ifndef STRICT typedef abilock_t b_lock; #endif #endif #if defined(HAVE_GCC_I386) || \ defined(HAVE_SVR4_I386) || \ defined(HAVE_LINUX_BITOPS) || \ defined(HAVE_SYS_ATOMIC) || \ defined(HAVE_SVR4_I386B) #define BPO_LOCK_MECH_DEFINED typedef volatile void * b_lock_t; #ifndef STRICT typedef volatile void * b_lock; #endif #endif #ifndef BPO_LOCK_MECH_DEFINED #error "BPO_LOCK_MECH not defined" #endif struct use_count_lock { b_lock_t ucl_b_lock; int ucl_count; }; struct bpo_fl_lock { b_lock_t bpo_fl_lock; int r_cnt; int w_cnt; }; struct bpo_pid_lock { b_lock_t bpo_pid_lock; pid_t lock_pid; int pid_cnt; b_lock_t bpo_unlock; pid_t unlock_pid; int flags; struct timeval lock_time; struct timeval lock_duration; }; /* ------------------------------------------------------------------ function definitions ------------------------------------------------------------------ */ extern int bpo_nap_a_while( long secs, long usecs ); extern int bpo_take_a_nap( void ); extern long b_Lockval( b_lock_t *lockp ); extern void b_Init( b_lock_t *lockp ); extern int b_TryLock( b_lock_t *lockp ); extern void b_Lock( b_lock_t *lockp ); extern void b_Unlock( b_lock_t *lockp ); /* The following seven functions are now deprecated and may be removed in a later release of library */ extern void bpo_RLock( struct bpo_fl_lock *bflp ); extern void bpo_WLock( struct bpo_fl_lock *bflp); extern void bpo_RUnlock( struct bpo_fl_lock *bflp ); extern void bpo_WUnlock( struct bpo_fl_lock *bflp ); extern int bpo_RWLock( struct bpo_fl_lock *bflp ); extern void bpo_WRLock( struct bpo_fl_lock *bflp ); extern void bpo_Init_RWLock( struct bpo_fl_lock *bflp ); extern struct bpo_pid_lock * bpo_Init_pid_lock( struct bpo_pid_lock *bplp, struct timeval *udtp ); extern void bpo_pid_Lock( struct bpo_pid_lock *bplp ); extern void bpo_pid_Unlock( struct bpo_pid_lock *bplp ); extern int bpo_pid_set_flags( struct bpo_pid_lock *bplp, int set_bits ); extern int bpo_pid_clr_flags( struct bpo_pid_lock *bplp, int clr_bits ); extern int bpo_pid_get_flags( struct bpo_pid_lock *bplp ); #endif /* -- End of File -- */