15 #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*
>(
safe_malloc(
sizeof(pthread_mutex_t)));
52 pthread_mutexattr_t attr;
55 int errorcode = pthread_mutexattr_init(&attr);
56 assert(errorcode == 0); (void)errorcode;
60 int kind = ( recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL );
61 errorcode = pthread_mutexattr_settype(&attr, kind);
65 errorcode = pthread_mutex_init(mutex, &attr);
69 errorcode = pthread_mutexattr_destroy(&attr);
79 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
81 pthread_mutex_destroy(mutex);
88 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
91 int errorcode = pthread_mutex_lock(mutex);
92 return errorcode == 0;
98 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
101 int errorcode = pthread_mutex_unlock(mutex);
102 return errorcode == 0;
108 pthread_mutex_t* mutex =
static_cast<pthread_mutex_t*
>(data_);
111 int errorcode = pthread_mutex_trylock(mutex);
112 return errorcode == 0;
117 #elif defined(LLVM_ON_UNIX) 119 #elif defined( _WIN32) 122 #warning Neither LLVM_ON_UNIX nor _WIN32 was set in Support/Mutex.cpp bool acquire()
Attempts to unconditionally acquire the lock.
This class represents lattice values for constants.
bool release()
Attempts to release the lock.
MutexImpl(bool recursive=true)
Initializes the lock but doesn't acquire it.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
~MutexImpl()
Releases and removes the lock Destructor.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool tryacquire()
Attempts to acquire the lock without blocking.