27 #ifndef SC_HOST_MUTEX_H_INCLUDED_
28 #define SC_HOST_MUTEX_H_INCLUDED_
30 #ifndef SC_INCLUDE_WINDOWS_H
31 # define SC_INCLUDE_WINDOWS_H // include Windows.h, if needed
36 #if defined(WIN32) || defined(_WIN32)
38 #define SC_MTX_TYPE_ CRITICAL_SECTION
40 #define SC_MTX_INIT_( Mutex ) \
41 InitializeCriticalSection( &(Mutex) )
42 #define SC_MTX_LOCK_( Mutex ) \
43 EnterCriticalSection( &(Mutex) )
44 #define SC_MTX_UNLOCK_( Mutex ) \
45 LeaveCriticalSection( &(Mutex) )
46 #define SC_MTX_TRYLOCK_( Mutex ) \
47 ( TryEnterCriticalSection( &(Mutex) ) != 0 )
48 #define SC_MTX_DESTROY_( Mutex ) \
49 DeleteCriticalSection( &(Mutex) )
51 #else // use pthread mutex
54 #define SC_MTX_TYPE_ pthread_mutex_t
57 # define SC_PTHREAD_NULL_ cma_c_null
58 #else // !defined(__hpux)
59 # define SC_PTHREAD_NULL_ NULL
62 #define SC_MTX_INIT_( Mutex ) \
63 pthread_mutex_init( &(Mutex), SC_PTHREAD_NULL_ )
64 #define SC_MTX_LOCK_( Mutex ) \
65 pthread_mutex_lock( &(Mutex) )
66 #define SC_MTX_UNLOCK_( Mutex ) \
67 pthread_mutex_unlock( &(Mutex) )
70 # define SC_MTX_TRYLOCK_( Mutex ) \
71 ( pthread_mutex_trylock( &(Mutex) ) == 0 )
72 #else // no try_lock available
73 # define SC_MTX_TRYLOCK_( Mutex ) \
77 #define SC_MTX_DESTROY_( Mutex ) \
78 pthread_mutex_destroy( &(Mutex) )
129 underlying_type m_mtx;
136 #undef SC_MTX_DESTROY_
138 #undef SC_MTX_TRYLOCK_
139 #undef SC_MTX_UNLOCK_
140 #undef SC_PTHREAD_NULL_
#define SC_MTX_TRYLOCK_(Mutex)
#define SC_MTX_INIT_(Mutex)
#define SC_MTX_LOCK_(Mutex)
#define SC_MTX_UNLOCK_(Mutex)
The sc_mutex_if interface class.
virtual int lock(int)
A new parameter segment ID is added for the out-of-order simulation.
The sc_host_mutex class, wrapping an OS mutex on the simulation host.
#define SC_MTX_DESTROY_(Mutex)