]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // srw_lock.hpp --------------------------------------------------------------// |
2 | ||
3 | // Copyright 2010 Vicente J. Botet Escriba | |
4 | // Copyright 2015 Andrey Semashev | |
5 | ||
6 | // Distributed under the Boost Software License, Version 1.0. | |
7 | // See http://www.boost.org/LICENSE_1_0.txt | |
8 | ||
9 | ||
10 | #ifndef BOOST_DETAIL_WINAPI_SRW_LOCK_HPP | |
11 | #define BOOST_DETAIL_WINAPI_SRW_LOCK_HPP | |
12 | ||
13 | #include <boost/detail/winapi/config.hpp> | |
14 | ||
15 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
16 | #pragma once | |
17 | #endif | |
18 | ||
19 | #if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WIN6 \ | |
20 | || (defined(_MSC_VER) && _MSC_VER < 1600) | |
21 | // Windows SDK 6.0A, which is used by MSVC 9, does not have TryAcquireSRWLock* neither in headers nor in .lib files, | |
22 | // although the functions are present in later SDKs since Windows API version 6. | |
23 | #define BOOST_WINAPI_NO_TRY_ACQUIRE_SRWLOCK | |
24 | #endif | |
25 | ||
26 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 | |
27 | ||
28 | #include <boost/detail/winapi/basic_types.hpp> | |
29 | ||
30 | #if !defined( BOOST_USE_WINDOWS_H ) | |
31 | extern "C" { | |
32 | struct _RTL_SRWLOCK; | |
33 | ||
34 | BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI | |
35 | InitializeSRWLock(::_RTL_SRWLOCK* SRWLock); | |
36 | ||
37 | BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI | |
38 | ReleaseSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); | |
39 | ||
40 | BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI | |
41 | ReleaseSRWLockShared(::_RTL_SRWLOCK* SRWLock); | |
42 | ||
43 | BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI | |
44 | AcquireSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); | |
45 | ||
46 | BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI | |
47 | AcquireSRWLockShared(::_RTL_SRWLOCK* SRWLock); | |
48 | ||
49 | #if !defined( BOOST_WINAPI_NO_TRY_ACQUIRE_SRWLOCK ) | |
50 | BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOLEAN_ WINAPI | |
51 | TryAcquireSRWLockExclusive(::_RTL_SRWLOCK* SRWLock); | |
52 | ||
53 | BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOLEAN_ WINAPI | |
54 | TryAcquireSRWLockShared(::_RTL_SRWLOCK* SRWLock); | |
55 | #endif | |
56 | } | |
57 | #endif | |
58 | ||
59 | namespace boost { | |
60 | namespace detail { | |
61 | namespace winapi { | |
62 | ||
63 | typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _RTL_SRWLOCK { | |
64 | PVOID_ Ptr; | |
65 | } SRWLOCK_, *PSRWLOCK_; | |
66 | ||
67 | #if defined( BOOST_USE_WINDOWS_H ) | |
68 | #define BOOST_DETAIL_WINAPI_SRWLOCK_INIT SRWLOCK_INIT | |
69 | #else | |
70 | #define BOOST_DETAIL_WINAPI_SRWLOCK_INIT {0} | |
71 | #endif | |
72 | ||
73 | BOOST_FORCEINLINE VOID_ InitializeSRWLock(PSRWLOCK_ SRWLock) | |
74 | { | |
75 | ::InitializeSRWLock(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); | |
76 | } | |
77 | ||
78 | BOOST_FORCEINLINE VOID_ ReleaseSRWLockExclusive(PSRWLOCK_ SRWLock) | |
79 | { | |
80 | ::ReleaseSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); | |
81 | } | |
82 | ||
83 | BOOST_FORCEINLINE VOID_ ReleaseSRWLockShared(PSRWLOCK_ SRWLock) | |
84 | { | |
85 | ::ReleaseSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); | |
86 | } | |
87 | ||
88 | BOOST_FORCEINLINE VOID_ AcquireSRWLockExclusive(PSRWLOCK_ SRWLock) | |
89 | { | |
90 | ::AcquireSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); | |
91 | } | |
92 | ||
93 | BOOST_FORCEINLINE VOID_ AcquireSRWLockShared(PSRWLOCK_ SRWLock) | |
94 | { | |
95 | ::AcquireSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); | |
96 | } | |
97 | ||
98 | #if !defined( BOOST_WINAPI_NO_TRY_ACQUIRE_SRWLOCK ) | |
99 | BOOST_FORCEINLINE BOOLEAN_ TryAcquireSRWLockExclusive(PSRWLOCK_ SRWLock) | |
100 | { | |
101 | return ::TryAcquireSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); | |
102 | } | |
103 | ||
104 | BOOST_FORCEINLINE BOOLEAN_ TryAcquireSRWLockShared(PSRWLOCK_ SRWLock) | |
105 | { | |
106 | return ::TryAcquireSRWLockShared(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock)); | |
107 | } | |
108 | #endif | |
109 | ||
110 | } | |
111 | } | |
112 | } | |
113 | ||
114 | #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 | |
115 | ||
116 | #endif // BOOST_DETAIL_WINAPI_SRW_LOCK_HPP |