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