Win32 support for Mutex class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22420 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jeff Cohen 2005-07-13 02:15:18 +00:00
parent c087a43510
commit 6d2352249a
5 changed files with 40 additions and 15 deletions

View File

@ -66,14 +66,14 @@ namespace llvm
/// @name Platform Dependent Data /// @name Platform Dependent Data
/// @{ /// @{
private: 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 /// @name Do Not Implement
/// @{ /// @{
private: private:
Mutex(const Mutex & original); Mutex(const Mutex & original);
void operator=(const Mutex &); void operator=(const Mutex &);
/// @} /// @}
}; };
} }

View File

@ -14,15 +14,16 @@
#include "llvm/System/Mutex.h" #include "llvm/System/Mutex.h"
#include "llvm/Config/config.h" #include "llvm/Config/config.h"
namespace llvm {
using namespace sys;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only TRULY operating system //=== WARNING: Implementation here must contain only TRULY operating system
//=== independent code. //=== independent code.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK) #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
namespace llvm {
using namespace sys;
#include <cassert> #include <cassert>
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
@ -132,6 +133,7 @@ Mutex::tryacquire()
} }
} }
#elif defined(LLVM_ON_UNIX) #elif defined(LLVM_ON_UNIX)
#include "Unix/Mutex.inc" #include "Unix/Mutex.inc"
#elif defined( LLVM_ON_WIN32) #elif defined( LLVM_ON_WIN32)

View File

@ -2,7 +2,7 @@
// //
// The LLVM Compiler Infrastructure // 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. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -16,31 +16,42 @@
//=== is guaranteed to work on *all* Win32 variants. //=== is guaranteed to work on *all* Win32 variants.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
namespace llvm #include "Win32.h"
{ #include "llvm/System/Mutex.h"
namespace llvm {
using namespace sys; using namespace sys;
Mutex::Mutex( bool recursive) Mutex::Mutex(bool /*recursive*/)
{ {
data_ = new CRITICAL_SECTION;
InitializeCriticalSection((LPCRITICAL_SECTION)data_);
} }
Mutex::~Mutex() Mutex::~Mutex()
{ {
DeleteCriticalSection((LPCRITICAL_SECTION)data_);
data_ = 0;
} }
bool bool
Mutex::acquire() Mutex::acquire()
{ {
EnterCriticalSection((LPCRITICAL_SECTION)data_);
return true;
} }
bool bool
Mutex::release() Mutex::release()
{ {
LeaveCriticalSection((LPCRITICAL_SECTION)data_);
return true;
} }
bool bool
Mutex::tryacquire( void ) Mutex::tryacquire()
{ {
return TryEnterCriticalSection((LPCRITICAL_SECTION)data_);
} }
} }

View File

@ -2,20 +2,23 @@
// //
// The LLVM Compiler Infrastructure // 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. // 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 //=== WARNING: Implementation here must contain only generic Win32 code that
//=== is guaranteed to work on all UNIX variants. //=== 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 "llvm/Config/config.h" // Get autoconf configuration settings
#include "windows.h" #include "windows.h"
#include <cassert> #include <cassert>

View File

@ -116,6 +116,9 @@
<File <File
RelativePath="..\..\lib\System\Memory.cpp"> RelativePath="..\..\lib\System\Memory.cpp">
</File> </File>
<File
RelativePath="..\..\lib\System\Mutex.cpp">
</File>
<File <File
RelativePath="..\..\lib\System\Path.cpp"> RelativePath="..\..\lib\System\Path.cpp">
</File> </File>
@ -145,6 +148,9 @@
<File <File
RelativePath="..\..\include\llvm\System\Memory.h"> RelativePath="..\..\include\llvm\System\Memory.h">
</File> </File>
<File
RelativePath="..\..\include\llvm\System\Mutex.h">
</File>
<File <File
RelativePath="..\..\include\llvm\System\Path.h"> RelativePath="..\..\include\llvm\System\Path.h">
</File> </File>
@ -173,6 +179,9 @@
<File <File
RelativePath="..\..\lib\System\Win32\Memory.inc"> RelativePath="..\..\lib\System\Win32\Memory.inc">
</File> </File>
<File
RelativePath="..\..\lib\System\Win32\Mutex.inc">
</File>
<File <File
RelativePath="..\..\lib\System\Win32\Path.inc"> RelativePath="..\..\lib\System\Win32\Path.inc">
</File> </File>