Workaround for an... interesting bug in Darwin's pthread_rwlock_init.
authorOwen Anderson <resistor@mac.com>
Sat, 20 Jun 2009 00:32:27 +0000 (00:32 +0000)
committerOwen Anderson <resistor@mac.com>
Sat, 20 Jun 2009 00:32:27 +0000 (00:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73806 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/RWMutex.cpp

index cf1aea03ddf3e51e879dfe92b11b87eedc376a10..15d98cb8f418be49987637f298c0a13541d20bf7 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "llvm/Config/config.h"
 #include "llvm/System/RWMutex.h"
+#include <cstring>
 
 //===----------------------------------------------------------------------===//
 //=== WARNING: Implementation here must contain only TRULY operating system
@@ -64,6 +65,12 @@ RWMutexImpl::RWMutexImpl()
     // Declare the pthread_rwlock data structures
     pthread_rwlock_t* rwlock =
       static_cast<pthread_rwlock_t*>(malloc(sizeof(pthread_rwlock_t)));
+
+#ifdef __APPLE__
+    // Workaround a bug/mis-feature in Darwin's pthread_rwlock_init.
+    bzero(rwlock, sizeof(pthread_rwlock_t));
+#endif
+
     pthread_rwlockattr_t attr;
 
     // Initialize the rwlock attributes