aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-02-27 19:07:36 +0000
committerChris Lattner <sabre@nondot.org>2005-02-27 19:07:36 +0000
commita97cf2138335150ce6484c3398c39cd4c3ac558c (patch)
tree5229a47ef1496be7b8800c4cce526df24e91d100 /include/llvm/Support
parent3e27952a8b3987b8dddef85dd00db07447575982 (diff)
downloadexternal_llvm-a97cf2138335150ce6484c3398c39cd4c3ac558c.zip
external_llvm-a97cf2138335150ce6484c3398c39cd4c3ac558c.tar.gz
external_llvm-a97cf2138335150ce6484c3398c39cd4c3ac558c.tar.bz2
Fix this to create a recursive mutex. Patch by Evan Jones!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20355 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/ThreadSupport-PThreads.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/include/llvm/Support/ThreadSupport-PThreads.h b/include/llvm/Support/ThreadSupport-PThreads.h
index 1bd3f32..34b9090 100644
--- a/include/llvm/Support/ThreadSupport-PThreads.h
+++ b/include/llvm/Support/ThreadSupport-PThreads.h
@@ -32,11 +32,34 @@ namespace llvm {
void operator=(const Mutex &); // DO NOT IMPLEMENT
public:
Mutex() {
+ // Initialize the mutex as a recursive mutex
pthread_mutexattr_t Attr;
- pthread_mutex_init(&mutex, &Attr);
+ int errorcode = pthread_mutexattr_init(&Attr);
+ assert(errorcode == 0);
+
+ errorcode = pthread_mutexattr_settype(&Attr, PTHREAD_MUTEX_RECURSIVE);
+ assert(errorcode == 0);
+
+ errorcode = pthread_mutex_init(&mutex, &Attr);
+ assert(errorcode == 0);
+
+ errorcode = pthread_mutexattr_destroy(&Attr);
+ assert(errorcode == 0);
+ }
+
+ ~Mutex() {
+ int errorcode = pthread_mutex_destroy(&mutex);
+ assert(errorcode == 0);
+ }
+
+ void acquire () {
+ int errorcode = pthread_mutex_lock(&mutex);
+ assert(errorcode == 0);
+ }
+
+ void release () {
+ int errorcode = pthread_mutex_unlock(&mutex);
+ assert(errorcode == 0);
}
- ~Mutex() { pthread_mutex_destroy(&mutex); }
- void acquire () { pthread_mutex_lock (&mutex); }
- void release () { pthread_mutex_unlock (&mutex); }
};
} // end namespace llvm