summaryrefslogtreecommitdiff
path: root/lib/System
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2005-07-13 02:15:18 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2005-07-13 02:15:18 +0000
commit6d2352249af8853c8307a7cf679017b32d27958c (patch)
treee3fcf758ddf54cbe8d1106dac4fefc811a57d006 /lib/System
parentc087a435109cdc943da094a21371f7d66d5b0e54 (diff)
downloadllvm-6d2352249af8853c8307a7cf679017b32d27958c.tar.gz
llvm-6d2352249af8853c8307a7cf679017b32d27958c.tar.bz2
llvm-6d2352249af8853c8307a7cf679017b32d27958c.tar.xz
Win32 support for Mutex class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22420 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/Mutex.cpp8
-rw-r--r--lib/System/Win32/Mutex.inc21
-rw-r--r--lib/System/Win32/Win32.h11
3 files changed, 28 insertions, 12 deletions
diff --git a/lib/System/Mutex.cpp b/lib/System/Mutex.cpp
index 2a15197691..4ec5af302f 100644
--- a/lib/System/Mutex.cpp
+++ b/lib/System/Mutex.cpp
@@ -14,15 +14,16 @@
#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)
diff --git a/lib/System/Win32/Mutex.inc b/lib/System/Win32/Mutex.inc
index d6acb2352b..439ce1a401 100644
--- a/lib/System/Win32/Mutex.inc
+++ b/lib/System/Win32/Mutex.inc
@@ -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_);
}
}
diff --git a/lib/System/Win32/Win32.h b/lib/System/Win32/Win32.h
index 6cda8c675f..7ed10471de 100644
--- a/lib/System/Win32/Win32.h
+++ b/lib/System/Win32/Win32.h
@@ -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>