[llvm-commits] [Patch Proposal] PR6297 simplify RWMutex

NAKAMURA Takumi geek4civic at gmail.com
Mon Aug 9 09:51:13 PDT 2010


Hello everyone,

We don't need to set the default value "PTHREAD_PROCESS_PRIVATE" for
pthread_rwlock_init(3T).

It also resolves PR6297.
RWMutex.cpp and pthread on mingw
http://llvm.org/bugs/show_bug.cgi?id=6297

I have checked on mingw(msysgit), fedora12-ppc, and centos5(x86-64)
w/o regression.


...Takumi
-------------- next part --------------
diff --git a/lib/System/RWMutex.cpp b/lib/System/RWMutex.cpp
index 5faf220..5a33364 100644
--- a/lib/System/RWMutex.cpp
+++ b/lib/System/RWMutex.cpp
@@ -71,23 +71,8 @@ RWMutexImpl::RWMutexImpl()
     bzero(rwlock, sizeof(pthread_rwlock_t));
 #endif
 
-    pthread_rwlockattr_t attr;
-
-    // Initialize the rwlock attributes
-    int errorcode = pthread_rwlockattr_init(&attr);
-    assert(errorcode == 0);
-
-#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
-    // Make it a process local rwlock
-    errorcode = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE);
-#endif
-
     // Initialize the rwlock
-    errorcode = pthread_rwlock_init(rwlock, &attr);
-    assert(errorcode == 0);
-
-    // Destroy the attributes
-    errorcode = pthread_rwlockattr_destroy(&attr);
+    int errorcode = pthread_rwlock_init(rwlock, NULL);
     assert(errorcode == 0);
 
     // Assign the data member


More information about the llvm-commits mailing list