]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
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 | */ | |
7c673cae | 8 | |
b32b8144 FG |
9 | #ifndef BOOST_WINAPI_EVENT_HPP_INCLUDED_ |
10 | #define BOOST_WINAPI_EVENT_HPP_INCLUDED_ | |
7c673cae | 11 | |
b32b8144 | 12 | #include <boost/winapi/basic_types.hpp> |
20effc67 | 13 | #include <boost/winapi/detail/header.hpp> |
7c673cae FG |
14 | |
15 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
16 | #pragma once | |
17 | #endif | |
18 | ||
b32b8144 | 19 | #if !defined( BOOST_USE_WINDOWS_H ) && BOOST_WINAPI_PARTITION_APP_SYSTEM |
7c673cae FG |
20 | extern "C" { |
21 | #if !defined( BOOST_NO_ANSI_APIS ) | |
20effc67 | 22 | BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
23 | CreateEventA( |
24 | ::_SECURITY_ATTRIBUTES* lpEventAttributes, | |
b32b8144 FG |
25 | boost::winapi::BOOL_ bManualReset, |
26 | boost::winapi::BOOL_ bInitialState, | |
27 | boost::winapi::LPCSTR_ lpName); | |
7c673cae FG |
28 | #endif |
29 | ||
20effc67 | 30 | BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC |
b32b8144 FG |
31 | CreateEventW( |
32 | ::_SECURITY_ATTRIBUTES* lpEventAttributes, | |
33 | boost::winapi::BOOL_ bManualReset, | |
34 | boost::winapi::BOOL_ bInitialState, | |
35 | boost::winapi::LPCWSTR_ lpName); | |
36 | } // extern "C" | |
37 | #endif // !defined( BOOST_USE_WINDOWS_H ) && BOOST_WINAPI_PARTITION_APP_SYSTEM | |
38 | ||
39 | #if !defined( BOOST_USE_WINDOWS_H ) | |
40 | extern "C" { | |
41 | #if !defined( BOOST_NO_ANSI_APIS ) | |
7c673cae | 42 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 |
20effc67 | 43 | BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
44 | CreateEventExA( |
45 | ::_SECURITY_ATTRIBUTES *lpEventAttributes, | |
b32b8144 FG |
46 | boost::winapi::LPCSTR_ lpName, |
47 | boost::winapi::DWORD_ dwFlags, | |
48 | boost::winapi::DWORD_ dwDesiredAccess); | |
7c673cae FG |
49 | #endif |
50 | ||
20effc67 | 51 | BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC |
7c673cae | 52 | OpenEventA( |
b32b8144 FG |
53 | boost::winapi::DWORD_ dwDesiredAccess, |
54 | boost::winapi::BOOL_ bInheritHandle, | |
55 | boost::winapi::LPCSTR_ lpName); | |
56 | #endif // !defined( BOOST_NO_ANSI_APIS ) | |
7c673cae FG |
57 | |
58 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 | |
20effc67 | 59 | BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
60 | CreateEventExW( |
61 | ::_SECURITY_ATTRIBUTES *lpEventAttributes, | |
b32b8144 FG |
62 | boost::winapi::LPCWSTR_ lpName, |
63 | boost::winapi::DWORD_ dwFlags, | |
64 | boost::winapi::DWORD_ dwDesiredAccess); | |
7c673cae FG |
65 | #endif |
66 | ||
20effc67 | 67 | BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC |
7c673cae | 68 | OpenEventW( |
b32b8144 FG |
69 | boost::winapi::DWORD_ dwDesiredAccess, |
70 | boost::winapi::BOOL_ bInheritHandle, | |
71 | boost::winapi::LPCWSTR_ lpName); | |
7c673cae FG |
72 | |
73 | // Windows CE define SetEvent/ResetEvent as inline functions in kfuncs.h | |
74 | #if !defined( UNDER_CE ) | |
20effc67 | 75 | BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC |
b32b8144 | 76 | SetEvent(boost::winapi::HANDLE_ hEvent); |
7c673cae | 77 | |
20effc67 | 78 | BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC |
b32b8144 | 79 | ResetEvent(boost::winapi::HANDLE_ hEvent); |
7c673cae | 80 | #endif |
b32b8144 | 81 | } // extern "C" |
7c673cae FG |
82 | #endif |
83 | ||
84 | namespace boost { | |
7c673cae FG |
85 | namespace winapi { |
86 | ||
87 | #if !defined( BOOST_NO_ANSI_APIS ) | |
88 | using ::OpenEventA; | |
89 | #endif | |
90 | using ::OpenEventW; | |
91 | using ::SetEvent; | |
92 | using ::ResetEvent; | |
93 | ||
94 | #if defined( BOOST_USE_WINDOWS_H ) | |
95 | ||
92f5a8d4 TL |
96 | BOOST_CONSTEXPR_OR_CONST DWORD_ EVENT_ALL_ACCESS_ = EVENT_ALL_ACCESS; |
97 | BOOST_CONSTEXPR_OR_CONST DWORD_ EVENT_MODIFY_STATE_ = EVENT_MODIFY_STATE; | |
7c673cae | 98 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 |
92f5a8d4 TL |
99 | BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_EVENT_INITIAL_SET_ = CREATE_EVENT_INITIAL_SET; |
100 | BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_EVENT_MANUAL_RESET_ = CREATE_EVENT_MANUAL_RESET; | |
7c673cae FG |
101 | #endif |
102 | ||
103 | #else // defined( BOOST_USE_WINDOWS_H ) | |
104 | ||
92f5a8d4 TL |
105 | BOOST_CONSTEXPR_OR_CONST DWORD_ EVENT_ALL_ACCESS_ = 0x001F0003; |
106 | BOOST_CONSTEXPR_OR_CONST DWORD_ EVENT_MODIFY_STATE_ = 0x00000002; | |
7c673cae | 107 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 |
92f5a8d4 TL |
108 | BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_EVENT_INITIAL_SET_ = 0x00000002; |
109 | BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_EVENT_MANUAL_RESET_ = 0x00000001; | |
7c673cae FG |
110 | #endif |
111 | ||
112 | #endif // defined( BOOST_USE_WINDOWS_H ) | |
113 | ||
114 | // Undocumented and not present in Windows SDK. Enables NtQueryEvent. | |
115 | // http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FEvent%2FNtQueryEvent.html | |
92f5a8d4 | 116 | BOOST_CONSTEXPR_OR_CONST DWORD_ EVENT_QUERY_STATE_ = 0x00000001; |
7c673cae | 117 | |
92f5a8d4 TL |
118 | BOOST_CONSTEXPR_OR_CONST DWORD_ event_all_access = EVENT_ALL_ACCESS_; |
119 | BOOST_CONSTEXPR_OR_CONST DWORD_ event_modify_state = EVENT_MODIFY_STATE_; | |
7c673cae | 120 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 |
92f5a8d4 TL |
121 | BOOST_CONSTEXPR_OR_CONST DWORD_ create_event_initial_set = CREATE_EVENT_INITIAL_SET_; |
122 | BOOST_CONSTEXPR_OR_CONST DWORD_ create_event_manual_reset = CREATE_EVENT_MANUAL_RESET_; | |
7c673cae FG |
123 | #endif |
124 | ||
125 | #if !defined( BOOST_NO_ANSI_APIS ) | |
126 | BOOST_FORCEINLINE HANDLE_ CreateEventA(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName) | |
127 | { | |
b32b8144 | 128 | #if !BOOST_WINAPI_PARTITION_APP_SYSTEM && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 |
7c673cae FG |
129 | const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u); |
130 | return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access); | |
131 | #else | |
132 | return ::CreateEventA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName); | |
133 | #endif | |
134 | } | |
135 | ||
136 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 | |
137 | BOOST_FORCEINLINE HANDLE_ CreateEventExA(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) | |
138 | { | |
139 | return ::CreateEventExA(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess); | |
140 | } | |
141 | #endif | |
142 | #endif | |
143 | ||
144 | BOOST_FORCEINLINE HANDLE_ CreateEventW(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName) | |
145 | { | |
b32b8144 | 146 | #if !BOOST_WINAPI_PARTITION_APP_SYSTEM && BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 |
7c673cae FG |
147 | const DWORD_ flags = (bManualReset ? create_event_manual_reset : 0u) | (bInitialState ? create_event_initial_set : 0u); |
148 | return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, flags, event_all_access); | |
149 | #else | |
150 | return ::CreateEventW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), bManualReset, bInitialState, lpName); | |
151 | #endif | |
152 | } | |
153 | ||
154 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 | |
155 | BOOST_FORCEINLINE HANDLE_ CreateEventExW(SECURITY_ATTRIBUTES_* lpEventAttributes, LPCWSTR_ lpName, DWORD_ dwFlags, DWORD_ dwDesiredAccess) | |
156 | { | |
157 | return ::CreateEventExW(reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpEventAttributes), lpName, dwFlags, dwDesiredAccess); | |
158 | } | |
159 | #endif | |
160 | ||
161 | #if !defined( BOOST_NO_ANSI_APIS ) | |
162 | BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCSTR_ lpName) | |
163 | { | |
164 | return winapi::CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName); | |
165 | } | |
166 | ||
167 | BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName) | |
168 | { | |
169 | return ::OpenEventA(dwDesiredAccess, bInheritHandle, lpName); | |
170 | } | |
171 | #endif | |
172 | ||
173 | BOOST_FORCEINLINE HANDLE_ create_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState, LPCWSTR_ lpName) | |
174 | { | |
175 | return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpName); | |
176 | } | |
177 | ||
178 | BOOST_FORCEINLINE HANDLE_ open_event(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName) | |
179 | { | |
180 | return ::OpenEventW(dwDesiredAccess, bInheritHandle, lpName); | |
181 | } | |
182 | ||
183 | BOOST_FORCEINLINE HANDLE_ create_anonymous_event(SECURITY_ATTRIBUTES_* lpEventAttributes, BOOL_ bManualReset, BOOL_ bInitialState) | |
184 | { | |
185 | return winapi::CreateEventW(lpEventAttributes, bManualReset, bInitialState, 0); | |
186 | } | |
187 | ||
7c673cae FG |
188 | } |
189 | } | |
190 | ||
20effc67 TL |
191 | #include <boost/winapi/detail/footer.hpp> |
192 | ||
b32b8144 | 193 | #endif // BOOST_WINAPI_EVENT_HPP_INCLUDED_ |