]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/winapi/mutex.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / winapi / mutex.hpp
1 /*
2 * Copyright 2010 Vicente J. Botet Escriba
3 * Copyright 2015, 2017 Andrey Semashev
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * See http://www.boost.org/LICENSE_1_0.txt
7 */
8
9 #ifndef BOOST_WINAPI_MUTEX_HPP_INCLUDED_
10 #define BOOST_WINAPI_MUTEX_HPP_INCLUDED_
11
12 #include <boost/winapi/basic_types.hpp>
13
14 #ifdef BOOST_HAS_PRAGMA_ONCE
15 #pragma once
16 #endif
17
18 #if !defined( BOOST_USE_WINDOWS_H ) && BOOST_WINAPI_PARTITION_APP_SYSTEM
19 extern "C" {
20 #if !defined( BOOST_NO_ANSI_APIS )
21 BOOST_SYMBOL_IMPORT boost::winapi::HANDLE_ WINAPI
22 CreateMutexA(
23 ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
24 boost::winapi::BOOL_ bInitialOwner,
25 boost::winapi::LPCSTR_ lpName);
26 #endif
27
28 BOOST_SYMBOL_IMPORT boost::winapi::HANDLE_ WINAPI
29 CreateMutexW(
30 ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
31 boost::winapi::BOOL_ bInitialOwner,
32 boost::winapi::LPCWSTR_ lpName);
33 } // extern "C"
34 #endif // !defined( BOOST_USE_WINDOWS_H ) && BOOST_WINAPI_PARTITION_APP_SYSTEM
35
36 #if !defined( BOOST_USE_WINDOWS_H )
37 extern "C" {
38 #if !defined( BOOST_NO_ANSI_APIS )
39 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
40 BOOST_SYMBOL_IMPORT boost::winapi::HANDLE_ WINAPI
41 CreateMutexExA(
42 ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
43 boost::winapi::LPCSTR_ lpName,
44 boost::winapi::DWORD_ dwFlags,
45 boost::winapi::DWORD_ dwDesiredAccess);
46 #endif
47
48 BOOST_SYMBOL_IMPORT boost::winapi::HANDLE_ WINAPI
49 OpenMutexA(
50 boost::winapi::DWORD_ dwDesiredAccess,
51 boost::winapi::BOOL_ bInheritHandle,
52 boost::winapi::LPCSTR_ lpName);
53 #endif // !defined( BOOST_NO_ANSI_APIS )
54
55 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
56 BOOST_SYMBOL_IMPORT boost::winapi::HANDLE_ WINAPI
57 CreateMutexExW(
58 ::_SECURITY_ATTRIBUTES* lpMutexAttributes,
59 boost::winapi::LPCWSTR_ lpName,
60 boost::winapi::DWORD_ dwFlags,
61 boost::winapi::DWORD_ dwDesiredAccess);
62 #endif
63
64 BOOST_SYMBOL_IMPORT boost::winapi::HANDLE_ WINAPI
65 OpenMutexW(
66 boost::winapi::DWORD_ dwDesiredAccess,
67 boost::winapi::BOOL_ bInheritHandle,
68 boost::winapi::LPCWSTR_ lpName);
69
70 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI
71 ReleaseMutex(boost::winapi::HANDLE_ hMutex);
72 } // extern "C"
73 #endif
74
75 namespace boost {
76 namespace winapi {
77
78 #if !defined( BOOST_NO_ANSI_APIS )
79 using ::OpenMutexA;
80 #endif
81 using ::OpenMutexW;
82 using ::ReleaseMutex;
83
84 #if defined( BOOST_USE_WINDOWS_H )
85
86 const DWORD_ MUTEX_ALL_ACCESS_ = MUTEX_ALL_ACCESS;
87 const DWORD_ MUTEX_MODIFY_STATE_ = MUTEX_MODIFY_STATE;
88 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
89 const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = CREATE_MUTEX_INITIAL_OWNER;
90 #endif
91
92 #else // defined( BOOST_USE_WINDOWS_H )
93
94 const DWORD_ MUTEX_ALL_ACCESS_ = 0x001F0001;
95 const DWORD_ MUTEX_MODIFY_STATE_ = 0x00000001;
96 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
97 const DWORD_ CREATE_MUTEX_INITIAL_OWNER_ = 0x00000001;
98 #endif
99
100 #endif // defined( BOOST_USE_WINDOWS_H )
101
102 const DWORD_ mutex_all_access = MUTEX_ALL_ACCESS_;
103 const DWORD_ mutex_modify_state = MUTEX_MODIFY_STATE_;
104 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
105 const DWORD_ create_mutex_initial_owner = CREATE_MUTEX_INITIAL_OWNER_;
106 #endif
107
108 #if !defined( BOOST_NO_ANSI_APIS )
109 BOOST_FORCEINLINE HANDLE_ CreateMutexA(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName)
110 {
111 #if !BOOST_WINAPI_PARTITION_APP_SYSTEM && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
112 const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u;
113 return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access);
114 #else
115 return ::CreateMutexA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName);
116 #endif
117 }
118
119 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
120 BOOST_FORCEINLINE HANDLE_ CreateMutexExA(
121 SECURITY_ATTRIBUTES_* lpMutexAttributes,
122 LPCSTR_ lpName,
123 DWORD_ dwFlags,
124 DWORD_ dwDesiredAccess)
125 {
126 return ::CreateMutexExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess);
127 }
128 #endif
129 #endif
130
131 BOOST_FORCEINLINE HANDLE_ CreateMutexW(SECURITY_ATTRIBUTES_* lpMutexAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName)
132 {
133 #if !BOOST_WINAPI_PARTITION_APP_SYSTEM && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
134 const DWORD_ flags = bInitialOwner ? create_mutex_initial_owner : 0u;
135 return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, flags, mutex_all_access);
136 #else
137 return ::CreateMutexW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), bInitialOwner, lpName);
138 #endif
139 }
140
141 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
142 BOOST_FORCEINLINE HANDLE_ CreateMutexExW(
143 SECURITY_ATTRIBUTES_* lpMutexAttributes,
144 LPCWSTR_ lpName,
145 DWORD_ dwFlags,
146 DWORD_ dwDesiredAccess)
147 {
148 return ::CreateMutexExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpMutexAttributes), lpName, dwFlags, dwDesiredAccess);
149 }
150 #endif
151
152 #if !defined( BOOST_NO_ANSI_APIS )
153 BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCSTR_ lpName)
154 {
155 return winapi::CreateMutexA(lpAttributes, bInitialOwner, lpName);
156 }
157
158 BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName)
159 {
160 return ::OpenMutexA(dwDesiredAccess, bInheritHandle, lpName);
161 }
162 #endif
163
164 BOOST_FORCEINLINE HANDLE_ create_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner, LPCWSTR_ lpName)
165 {
166 return winapi::CreateMutexW(lpAttributes, bInitialOwner, lpName);
167 }
168
169 BOOST_FORCEINLINE HANDLE_ open_mutex(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName)
170 {
171 return ::OpenMutexW(dwDesiredAccess, bInheritHandle, lpName);
172 }
173
174 BOOST_FORCEINLINE HANDLE_ create_anonymous_mutex(SECURITY_ATTRIBUTES_* lpAttributes, BOOL_ bInitialOwner)
175 {
176 return winapi::CreateMutexW(lpAttributes, bInitialOwner, 0);
177 }
178
179 }
180 }
181
182 #endif // BOOST_WINAPI_MUTEX_HPP_INCLUDED_