From 96c51a8de18ee0675f48a98649fe25175c6b36f8 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Sat, 20 Jun 2009 00:32:27 +0000 Subject: [PATCH] Workaround for an... interesting bug in Darwin's pthread_rwlock_init. llvm-svn: 73806 --- llvm/lib/System/RWMutex.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/llvm/lib/System/RWMutex.cpp b/llvm/lib/System/RWMutex.cpp index cf1aea03ddf3..15d98cb8f418 100644 --- a/llvm/lib/System/RWMutex.cpp +++ b/llvm/lib/System/RWMutex.cpp @@ -13,6 +13,7 @@ #include "llvm/Config/config.h" #include "llvm/System/RWMutex.h" +#include //===----------------------------------------------------------------------===// //=== 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(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