llvm.org GIT mirror llvm / 6d23522
Win32 support for Mutex class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22420 91177308-0d34-0410-b5e6-96231b3b80d8 Jeff Cohen 14 years ago
5 changed file(s) with 40 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
6565 /// @name Platform Dependent Data
6666 /// @{
6767 private:
68 void* data_; ///< We don't know what the data will be
68 void* data_; ///< We don't know what the data will be
6969
7070 /// @}
7171 /// @name Do Not Implement
7272 /// @{
7373 private:
74 Mutex(const Mutex & original);
75 void operator=(const Mutex &);
74 Mutex(const Mutex & original);
75 void operator=(const Mutex &);
7676 /// @}
7777 };
7878 }
1313 #include "llvm/System/Mutex.h"
1414 #include "llvm/Config/config.h"
1515
16 namespace llvm {
17 using namespace sys;
18
1916 //===----------------------------------------------------------------------===//
2017 //=== WARNING: Implementation here must contain only TRULY operating system
2118 //=== independent code.
2219 //===----------------------------------------------------------------------===//
2320
2421 #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_MUTEX_LOCK)
22
23 namespace llvm {
24 using namespace sys;
25
2526 #include
2627 #include
2728 #include
131132 }
132133
133134 }
135
134136 #elif defined(LLVM_ON_UNIX)
135137 #include "Unix/Mutex.inc"
136138 #elif defined( LLVM_ON_WIN32)
11 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Jeff Cohen and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
66 //
77 //===----------------------------------------------------------------------===//
1515 //=== is guaranteed to work on *all* Win32 variants.
1616 //===----------------------------------------------------------------------===//
1717
18 namespace llvm
19 {
18 #include "Win32.h"
19 #include "llvm/System/Mutex.h"
20
21 namespace llvm {
2022 using namespace sys;
2123
22 Mutex::Mutex( bool recursive)
24 Mutex::Mutex(bool /*recursive*/)
2325 {
26 data_ = new CRITICAL_SECTION;
27 InitializeCriticalSection((LPCRITICAL_SECTION)data_);
2428 }
2529
2630 Mutex::~Mutex()
2731 {
32 DeleteCriticalSection((LPCRITICAL_SECTION)data_);
33 data_ = 0;
2834 }
2935
3036 bool
3137 Mutex::acquire()
3238 {
39 EnterCriticalSection((LPCRITICAL_SECTION)data_);
40 return true;
3341 }
3442
3543 bool
3644 Mutex::release()
3745 {
46 LeaveCriticalSection((LPCRITICAL_SECTION)data_);
47 return true;
3848 }
3949
4050 bool
41 Mutex::tryacquire( void )
51 Mutex::tryacquire()
4252 {
53 return TryEnterCriticalSection((LPCRITICAL_SECTION)data_);
4354 }
4455
4556 }
11 //
22 // The LLVM Compiler Infrastructure
33 //
4 // This file was developed by Reid Spencer and is distributed under the
4 // This file was developed by Jeff Cohen and is distributed under the
55 // University of Illinois Open Source License. See LICENSE.TXT for details.
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This file defines things specific to Unix implementations.
9 // This file defines things specific to Win32 implementations.
1010 //
1111 //===----------------------------------------------------------------------===//
1212
1313 //===----------------------------------------------------------------------===//
14 //=== WARNING: Implementation here must contain only generic UNIX code that
15 //=== is guaranteed to work on all UNIX variants.
14 //=== WARNING: Implementation here must contain only generic Win32 code that
15 //=== is guaranteed to work on *all* Win32 variants.
1616 //===----------------------------------------------------------------------===//
17
18 // Require at least Windows 2000 API.
19 #define _WIN32_WINNT 0x0500
1720
1821 #include "llvm/Config/config.h" // Get autoconf configuration settings
1922 #include "windows.h"
116116 RelativePath="..\..\lib\System\Memory.cpp">
117117
118118
119 RelativePath="..\..\lib\System\Mutex.cpp">
120
121
119122 RelativePath="..\..\lib\System\Path.cpp">
120123
121124
145148 RelativePath="..\..\include\llvm\System\Memory.h">
146149
147150
151 RelativePath="..\..\include\llvm\System\Mutex.h">
152
153
148154 RelativePath="..\..\include\llvm\System\Path.h">
149155
150156
171177
172178
173179 RelativePath="..\..\lib\System\Win32\Memory.inc">
180
181
182 RelativePath="..\..\lib\System\Win32\Mutex.inc">
174183
175184
176185 RelativePath="..\..\lib\System\Win32\Path.inc">