Win32 support for Mutex class.
authorJeff Cohen <jeffc@jolt-lang.org>
Wed, 13 Jul 2005 02:15:18 +0000 (02:15 +0000)
committerJeff Cohen <jeffc@jolt-lang.org>
Wed, 13 Jul 2005 02:15:18 +0000 (02:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22420 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Mutex.h
lib/System/Mutex.cpp
lib/System/Win32/Mutex.inc
lib/System/Win32/Win32.h
win32/System/System.vcproj

index 16e898c2dedff32a611638361adc9ebb6a267268..8b5078d16d6cc5f4f4ae1d49d7e42d6a4292d226 100644 (file)
@@ -66,14 +66,14 @@ namespace llvm
     /// @name Platform Dependent Data
     /// @{
     private:
-        void* data_; ///< We don't know what the data will be
+      void* data_; ///< We don't know what the data will be
 
     /// @}
     /// @name Do Not Implement
     /// @{
     private: 
-       Mutex(const Mutex & original);
-       void operator=(const Mutex &);
+           Mutex(const Mutex & original);
+           void operator=(const Mutex &);
     /// @}
     };
   }
index 2a1519769134a4039d7aecec1148569f31113954..4ec5af302f935fd47c09b8235e640f1e83416d3d 100644 (file)
 #include "llvm/System/Mutex.h"
 #include "llvm/Config/config.h"
 
-namespace llvm {
-using namespace sys;
-
 //===----------------------------------------------------------------------===//
 //=== WARNING: Implementation here must contain only TRULY operating system
 //===          independent code.
 //===----------------------------------------------------------------------===//
 
 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
+
+namespace llvm {
+using namespace sys;
+
 #include <cassert>
 #include <pthread.h>
 #include <stdlib.h>
@@ -132,6 +133,7 @@ Mutex::tryacquire()
 }
 
 }
+
 #elif defined(LLVM_ON_UNIX)
 #include "Unix/Mutex.inc"
 #elif defined( LLVM_ON_WIN32)
index d6acb2352bed73251e725f0379cbcd70de0736e0..439ce1a401a8fe30c1cc77a34293af3ed8286840 100644 (file)
@@ -2,7 +2,7 @@
 // 
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer and is distributed under the 
+// This file was developed by Jeff Cohen and is distributed under the 
 // University of Illinois Open Source License. See LICENSE.TXT for details.
 // 
 //===----------------------------------------------------------------------===//
 //===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
-namespace llvm
-{
+#include "Win32.h"
+#include "llvm/System/Mutex.h"
+
+namespace llvm {
 using namespace sys;
 
-Mutex::Mutex( bool recursive)
+Mutex::Mutex(bool /*recursive*/)
 {
+  data_ = new CRITICAL_SECTION;
+  InitializeCriticalSection((LPCRITICAL_SECTION)data_);
 }
 
 Mutex::~Mutex()
 {
+  DeleteCriticalSection((LPCRITICAL_SECTION)data_);
+  data_ = 0;
 }
 
 bool 
 Mutex::acquire()
 {
+  EnterCriticalSection((LPCRITICAL_SECTION)data_);
+  return true;
 }
 
 bool 
 Mutex::release()
 {
+  LeaveCriticalSection((LPCRITICAL_SECTION)data_);
+  return true;
 }
 
 bool 
-Mutex::tryacquire( void )
+Mutex::tryacquire()
 {
+  return TryEnterCriticalSection((LPCRITICAL_SECTION)data_);
 }
 
 }
index 6cda8c675fe44031a45fcd1b449a6418f7a8307e..7ed10471de15fe7bea08fb7079025ebb157634e5 100644 (file)
@@ -2,20 +2,23 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer and is distributed under the
+// This file was developed by Jeff Cohen and is distributed under the
 // University of Illinois Open Source License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
-// This file defines things specific to Unix implementations.
+// This file defines things specific to Win32 implementations.
 //
 //===----------------------------------------------------------------------===//
 
 //===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only generic UNIX code that
-//===          is guaranteed to work on all UNIX variants.
+//=== WARNING: Implementation here must contain only generic Win32 code that
+//===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
+// Require at least Windows 2000 API.
+#define _WIN32_WINNT 0x0500
+
 #include "llvm/Config/config.h"     // Get autoconf configuration settings
 #include "windows.h"
 #include <cassert>
index 2f03809667f0727095971dbe178046ca9013796a..c14f7cf937db9861de5dedb41c96b4c46916903e 100644 (file)
                        <File
                                RelativePath="..\..\lib\System\Memory.cpp">
                        </File>
+                       <File
+                               RelativePath="..\..\lib\System\Mutex.cpp">
+                       </File>
                        <File
                                RelativePath="..\..\lib\System\Path.cpp">
                        </File>
                        <File
                                RelativePath="..\..\include\llvm\System\Memory.h">
                        </File>
+                       <File
+                               RelativePath="..\..\include\llvm\System\Mutex.h">
+                       </File>
                        <File
                                RelativePath="..\..\include\llvm\System\Path.h">
                        </File>
                        <File
                                RelativePath="..\..\lib\System\Win32\Memory.inc">
                        </File>
+                       <File
+                               RelativePath="..\..\lib\System\Win32\Mutex.inc">
+                       </File>
                        <File
                                RelativePath="..\..\lib\System\Win32\Path.inc">
                        </File>