<div>Maybe you can reference this:</div>
<div><a href="http://www.codeguru.com/cpp/w-p/system/misc/article.php/c5679">http://www.codeguru.com/cpp/w-p/system/misc/article.php/c5679</a></div>
<div> </div>
<div><br><br> </div>
<div class="gmail_quote">On Wed, Jun 17, 2009 at 5:11 PM, Owen Anderson <span dir="ltr"><<a href="mailto:resistor@mac.com">resistor@mac.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Author: resistor<br>Date: Wed Jun 17 04:10:42 2009<br>New Revision: 73607<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=73607&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=73607&view=rev</a><br>
Log:<br>Improve the Win32 reader-writer lock implementation by making it just a normal<br>lock.  This is obviously bad, but at least it's threadsafe!  If you know how<br>to improve this in a pre-Vista friendly well, patches welcome!<br>
<br>Patch by Max Burke.<br><br>Modified:<br>   llvm/trunk/lib/System/Win32/RWMutex.inc<br><br>Modified: llvm/trunk/lib/System/Win32/RWMutex.inc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73607&r1=73606&r2=73607&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73607&r1=73606&r2=73607&view=diff</a><br>
<br>==============================================================================<br>--- llvm/trunk/lib/System/Win32/RWMutex.inc (original)<br>+++ llvm/trunk/lib/System/Win32/RWMutex.inc Wed Jun 17 04:10:42 2009<br>@@ -18,31 +18,39 @@<br>
<br> #include "Win32.h"<br><br>-// FIXME: THIS IS NOT THREAD-SAFE!!<br>-// Windows does not have reader-writer locks pre-Vista.  If you want to have<br>-// thread-safe LLVM on Windows, for now at least, you need to use a pthreads<br>
-// replacement library.<br>+// FIXME: Windows does not have reader-writer locks pre-Vista.  If you want<br>+// real reader-writer locks, you a pthreads implementation for Windows.<br><br> namespace llvm {<br> using namespace sys;<br>
<br>-RWMutex::RWMutex() { }<br>+RWMutex::RWMutex() {<br>+  data_ = calloc(1, sizeof(CRITICAL_SECTION));<br>+  InitializeCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));<br>+}<br><br>-RWMutex::~RWMutex() { }<br>
+RWMutex::~RWMutex() {<br>+  DeleteCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));<br>+  free(data_);<br>+}<br><br> bool RWMutex::reader_acquire() {<br>+  EnterCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));<br>
  return true;<br> }<br><br> bool RWMutex::reader_release() {<br>+  LeaveCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));<br>  return true;<br> }<br><br> bool RWMutex::writer_acquire() {<br>+  EnterCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));<br>
  return true;<br> }<br><br> bool RWMutex::writer_release() {<br>+  LeaveCriticalSection(static_cast<LPCRITICAL_SECTION>(data_));<br>  return true;<br> }<br><br><br><br>_______________________________________________<br>
llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all">
<div></div><br>-- <br>-Howard<br>