]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/winapi/include/boost/detail/winapi/semaphore.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / winapi / include / boost / detail / winapi / semaphore.hpp
CommitLineData
7c673cae
FG
1// semaphore.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_SEMAPHORE_HPP
11#define BOOST_DETAIL_WINAPI_SEMAPHORE_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
25CreateSemaphoreA(
26 ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
27 boost::detail::winapi::LONG_ lInitialCount,
28 boost::detail::winapi::LONG_ lMaximumCount,
29 boost::detail::winapi::LPCSTR_ lpName);
30#endif
31
32#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
33BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
34CreateSemaphoreExA(
35 ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
36 boost::detail::winapi::LONG_ lInitialCount,
37 boost::detail::winapi::LONG_ lMaximumCount,
38 boost::detail::winapi::LPCSTR_ lpName,
39 boost::detail::winapi::DWORD_ dwFlags,
40 boost::detail::winapi::DWORD_ dwDesiredAccess);
41#endif
42
43BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
44OpenSemaphoreA(
45 boost::detail::winapi::DWORD_ dwDesiredAccess,
46 boost::detail::winapi::BOOL_ bInheritHandle,
47 boost::detail::winapi::LPCSTR_ lpName);
48#endif
49
50BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
51CreateSemaphoreW(
52 ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
53 boost::detail::winapi::LONG_ lInitialCount,
54 boost::detail::winapi::LONG_ lMaximumCount,
55 boost::detail::winapi::LPCWSTR_ lpName);
56
57#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
58BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
59CreateSemaphoreExW(
60 ::_SECURITY_ATTRIBUTES* lpSemaphoreAttributes,
61 boost::detail::winapi::LONG_ lInitialCount,
62 boost::detail::winapi::LONG_ lMaximumCount,
63 boost::detail::winapi::LPCWSTR_ lpName,
64 boost::detail::winapi::DWORD_ dwFlags,
65 boost::detail::winapi::DWORD_ dwDesiredAccess);
66#endif
67
68BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
69OpenSemaphoreW(
70 boost::detail::winapi::DWORD_ dwDesiredAccess,
71 boost::detail::winapi::BOOL_ bInheritHandle,
72 boost::detail::winapi::LPCWSTR_ lpName);
73
74BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
75ReleaseSemaphore(
76 boost::detail::winapi::HANDLE_ hSemaphore,
77 boost::detail::winapi::LONG_ lReleaseCount,
78 boost::detail::winapi::LPLONG_ lpPreviousCount);
79}
80#endif
81
82namespace boost {
83namespace detail {
84namespace winapi {
85
86#if !defined( BOOST_NO_ANSI_APIS )
87using ::OpenSemaphoreA;
88#endif
89using ::OpenSemaphoreW;
90using ::ReleaseSemaphore;
91
92#if defined( BOOST_USE_WINDOWS_H )
93
94const DWORD_ SEMAPHORE_ALL_ACCESS_ = SEMAPHORE_ALL_ACCESS;
95const DWORD_ SEMAPHORE_MODIFY_STATE_ = SEMAPHORE_MODIFY_STATE;
96
97#else // defined( BOOST_USE_WINDOWS_H )
98
99const DWORD_ SEMAPHORE_ALL_ACCESS_ = 0x001F0003;
100const DWORD_ SEMAPHORE_MODIFY_STATE_ = 0x00000002;
101
102#endif // defined( BOOST_USE_WINDOWS_H )
103
104// Undocumented and not present in Windows SDK. Enables NtQuerySemaphore.
105// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FEvent%2FNtQueryEvent.html
106const DWORD_ SEMAPHORE_QUERY_STATE_ = 0x00000001;
107
108const DWORD_ semaphore_all_access = SEMAPHORE_ALL_ACCESS_;
109const DWORD_ semaphore_modify_state = SEMAPHORE_MODIFY_STATE_;
110
111
112#if !defined( BOOST_NO_ANSI_APIS )
113BOOST_FORCEINLINE HANDLE_ CreateSemaphoreA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName)
114{
115#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
116 return ::CreateSemaphoreExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, 0, semaphore_all_access);
117#else
118 return ::CreateSemaphoreA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName);
119#endif
120}
121
122#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
123BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExA(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess)
124{
125 return ::CreateSemaphoreExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess);
126}
127#endif
128#endif
129
130BOOST_FORCEINLINE HANDLE_ CreateSemaphoreW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName)
131{
132#if BOOST_PLAT_WINDOWS_RUNTIME && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
133 return ::CreateSemaphoreExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, 0, semaphore_all_access);
134#else
135 return ::CreateSemaphoreW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName);
136#endif
137}
138
139#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
140BOOST_FORCEINLINE HANDLE_ CreateSemaphoreExW(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess)
141{
142 return ::CreateSemaphoreExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName, dwFlags, dwDesiredAccess);
143}
144#endif
145
146#if !defined( BOOST_NO_ANSI_APIS )
147BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCSTR_ lpName)
148{
149 return winapi::CreateSemaphoreA(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName);
150}
151
152BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName)
153{
154 return ::OpenSemaphoreA(dwDesiredAccess, bInheritHandle, lpName);
155}
156#endif
157
158BOOST_FORCEINLINE HANDLE_ create_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount, LPCWSTR_ lpName)
159{
160 return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName);
161}
162
163BOOST_FORCEINLINE HANDLE_ open_semaphore(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName)
164{
165 return ::OpenSemaphoreW(dwDesiredAccess, bInheritHandle, lpName);
166}
167
168BOOST_FORCEINLINE HANDLE_ create_anonymous_semaphore(SECURITY_ATTRIBUTES_* lpSemaphoreAttributes, LONG_ lInitialCount, LONG_ lMaximumCount)
169{
170 return winapi::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, 0);
171}
172
173}
174}
175}
176
177#endif // BOOST_DETAIL_WINAPI_SEMAPHORE_HPP