[llvm-commits] CVS: llvm/lib/System/Win32/Mutex.inc Win32.h

Jeff Cohen jeffc at jolt-lang.org
Tue Jul 12 19:15:30 PDT 2005



Changes in directory llvm/lib/System/Win32:

Mutex.inc updated: 1.1 -> 1.2
Win32.h updated: 1.3 -> 1.4
---
Log message:

Win32 support for Mutex class.

---
Diffs of the changes:  (+23 -9)

 Mutex.inc |   21 ++++++++++++++++-----
 Win32.h   |   11 +++++++----
 2 files changed, 23 insertions(+), 9 deletions(-)


Index: llvm/lib/System/Win32/Mutex.inc
diff -u llvm/lib/System/Win32/Mutex.inc:1.1 llvm/lib/System/Win32/Mutex.inc:1.2
--- llvm/lib/System/Win32/Mutex.inc:1.1	Tue Jul 12 10:37:43 2005
+++ llvm/lib/System/Win32/Mutex.inc	Tue Jul 12 21:15:17 2005
@@ -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.
 // 
 //===----------------------------------------------------------------------===//
@@ -16,31 +16,42 @@
 //===          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: llvm/lib/System/Win32/Win32.h
diff -u llvm/lib/System/Win32/Win32.h:1.3 llvm/lib/System/Win32/Win32.h:1.4
--- llvm/lib/System/Win32/Win32.h:1.3	Thu Apr 21 17:48:40 2005
+++ llvm/lib/System/Win32/Win32.h	Tue Jul 12 21:15:17 2005
@@ -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>






More information about the llvm-commits mailing list