16 #include "llvm/Config/config.h"
23 #if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
35 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
49 pthread_mutex_t* mutex =
50 static_cast<pthread_mutex_t*
>(malloc(
sizeof(pthread_mutex_t)));
55 pthread_mutexattr_t attr;
58 int errorcode = pthread_mutexattr_init(&attr);
59 assert(errorcode == 0); (void)errorcode;
63 int kind = ( recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL );
64 errorcode = pthread_mutexattr_settype(&attr, kind);
68 errorcode = pthread_mutex_init(mutex, &attr);
72 errorcode = pthread_mutexattr_destroy(&attr);
82 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
84 pthread_mutex_destroy(mutex);
91 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
94 int errorcode = pthread_mutex_lock(mutex);
95 return errorcode == 0;
101 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
104 int errorcode = pthread_mutex_unlock(mutex);
105 return errorcode == 0;
111 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
114 int errorcode = pthread_mutex_trylock(mutex);
115 return errorcode == 0;
120 #elif defined(LLVM_ON_UNIX)
122 #elif defined( LLVM_ON_WIN32)
125 #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.
void report_bad_alloc_error(const char *Reason, bool GenCrashDiag=true)
Reports a bad alloc error, calling any user defined bad alloc error handler.
~MutexImpl()
Releases and removes the lock.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool tryacquire()
Attempts to acquire the lock without blocking.