14 #include "llvm/Config/config.h"
22 #if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
34 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
48 pthread_mutex_t* mutex =
49 static_cast<pthread_mutex_t*
>(malloc(
sizeof(pthread_mutex_t)));
50 pthread_mutexattr_t attr;
53 int errorcode = pthread_mutexattr_init(&attr);
54 assert(errorcode == 0); (void)errorcode;
58 int kind = ( recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL );
59 errorcode = pthread_mutexattr_settype(&attr, kind);
63 errorcode = pthread_mutex_init(mutex, &attr);
67 errorcode = pthread_mutexattr_destroy(&attr);
77 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
79 pthread_mutex_destroy(mutex);
86 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
89 int errorcode = pthread_mutex_lock(mutex);
90 return errorcode == 0;
96 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
99 int errorcode = pthread_mutex_unlock(mutex);
100 return errorcode == 0;
106 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
109 int errorcode = pthread_mutex_trylock(mutex);
110 return errorcode == 0;
115 #elif defined(LLVM_ON_UNIX)
117 #elif defined( LLVM_ON_WIN32)
120 #warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in Support/Mutex.cpp
bool acquire()
Attempts to unconditionally acquire the lock.
bool release()
Attempts to release the lock.
MutexImpl(bool recursive=true)
Initializes the lock but doesn't acquire it.
~MutexImpl()
Releases and removes the lock.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool tryacquire()
Attempts to acquire the lock without blocking.