]> git.proxmox.com Git - rustc.git/blob - vendor/winapi/src/um/synchapi.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / vendor / winapi / src / um / synchapi.rs
1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! ApiSet Contract for api-ms-win-core-synch-l1
7 use shared::basetsd::SIZE_T;
8 use shared::minwindef::{BOOL, DWORD, LPLONG, LPVOID, PBOOL, ULONG};
9 use um::minwinbase::{
10 LPCRITICAL_SECTION, LPSECURITY_ATTRIBUTES, PCRITICAL_SECTION, PREASON_CONTEXT,
11 };
12 use um::winnt::{
13 BOOLEAN, HANDLE, LARGE_INTEGER, LONG, LPCSTR, LPCWSTR, PRTL_BARRIER, PRTL_RUN_ONCE,
14 PVOID, RTL_BARRIER, RTL_CONDITION_VARIABLE, RTL_CONDITION_VARIABLE_INIT,
15 RTL_RUN_ONCE, RTL_SRWLOCK, RTL_SRWLOCK_INIT, VOID
16 };
17 pub const SRWLOCK_INIT: SRWLOCK = RTL_SRWLOCK_INIT;
18 pub type SRWLOCK = RTL_SRWLOCK;
19 pub type PSRWLOCK = *mut RTL_SRWLOCK;
20 extern "system" {
21 pub fn InitializeSRWLock(
22 SRWLock: PSRWLOCK,
23 );
24 pub fn ReleaseSRWLockExclusive(
25 SRWLock: PSRWLOCK,
26 );
27 pub fn ReleaseSRWLockShared(
28 SRWLock: PSRWLOCK,
29 );
30 pub fn AcquireSRWLockExclusive(
31 SRWLock: PSRWLOCK,
32 );
33 pub fn AcquireSRWLockShared(
34 SRWLock: PSRWLOCK,
35 );
36 pub fn TryAcquireSRWLockExclusive(
37 SRWLock: PSRWLOCK,
38 ) -> BOOLEAN;
39 pub fn TryAcquireSRWLockShared(
40 SRWLock: PSRWLOCK,
41 ) -> BOOLEAN;
42 pub fn InitializeCriticalSection(
43 lpCriticalSection: LPCRITICAL_SECTION,
44 );
45 pub fn EnterCriticalSection(
46 lpCriticalSection: LPCRITICAL_SECTION,
47 );
48 pub fn LeaveCriticalSection(
49 lpCriticalSection: LPCRITICAL_SECTION,
50 );
51 pub fn InitializeCriticalSectionAndSpinCount(
52 lpCriticalSection: LPCRITICAL_SECTION,
53 dwSpinCount: DWORD,
54 ) -> BOOL;
55 pub fn InitializeCriticalSectionEx(
56 lpCriticalSection: LPCRITICAL_SECTION,
57 dwSpinCount: DWORD,
58 Flags: DWORD,
59 ) -> BOOL;
60 pub fn SetCriticalSectionSpinCount(
61 lpCriticalSection: LPCRITICAL_SECTION,
62 dwSpinCount: DWORD,
63 ) -> DWORD;
64 pub fn TryEnterCriticalSection(
65 lpCriticalSection: LPCRITICAL_SECTION,
66 ) -> BOOL;
67 pub fn DeleteCriticalSection(
68 lpCriticalSection: LPCRITICAL_SECTION,
69 );
70 }
71 pub type INIT_ONCE = RTL_RUN_ONCE;
72 pub type PINIT_ONCE = PRTL_RUN_ONCE;
73 pub type LPINIT_ONCE = PRTL_RUN_ONCE;
74 //pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = RTL_RUN_ONCE_INIT;
75 //pub const INIT_ONCE_CHECK_ONLY: ULONG = RTL_RUN_ONCE_CHECK_ONLY;
76 //pub const INIT_ONCE_ASYNC: ULONG = RTL_RUN_ONCE_ASYNC;
77 //pub const INIT_ONCE_INIT_FAILED: ULONG = RTL_RUN_ONCE_INIT_FAILED;
78 //pub const INIT_ONCE_CTX_RESERVED_BITS: usize = RTL_RUN_ONCE_CTX_RESERVED_BITS;
79 FN!{stdcall PINIT_ONCE_FN(
80 InitOnce: PINIT_ONCE,
81 Parameter: PVOID,
82 Context: *mut PVOID,
83 ) -> BOOL}
84 extern "system" {
85 pub fn InitOnceInitialize(
86 InitOnce: PINIT_ONCE,
87 );
88 pub fn InitOnceExecuteOnce(
89 InitOnce: PINIT_ONCE,
90 InitFn: PINIT_ONCE_FN,
91 Parameter: PVOID,
92 Context: *mut LPVOID,
93 ) -> BOOL;
94 pub fn InitOnceBeginInitialize(
95 lpInitOnce: LPINIT_ONCE,
96 dwFlags: DWORD,
97 fPending: PBOOL,
98 lpContext: *mut LPVOID,
99 ) -> BOOL;
100 pub fn InitOnceComplete(
101 lpInitOnce: LPINIT_ONCE,
102 dwFlags: DWORD,
103 lpContext: LPVOID,
104 ) -> BOOL;
105 }
106 pub type CONDITION_VARIABLE = RTL_CONDITION_VARIABLE;
107 pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE;
108 pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = RTL_CONDITION_VARIABLE_INIT;
109 //pub const CONDITION_VARIABLE_LOCKMODE_SHARED: ULONG = RTL_CONDITION_VARIABLE_LOCKMODE_SHARED;
110 extern "system" {
111 pub fn InitializeConditionVariable(
112 ConditionVariable: PCONDITION_VARIABLE,
113 );
114 pub fn WakeConditionVariable(
115 ConditionVariable: PCONDITION_VARIABLE,
116 );
117 pub fn WakeAllConditionVariable(
118 ConditionVariable: PCONDITION_VARIABLE,
119 );
120 pub fn SleepConditionVariableCS(
121 ConditionVariable: PCONDITION_VARIABLE,
122 CriticalSection: PCRITICAL_SECTION,
123 dwMilliseconds: DWORD,
124 ) -> BOOL;
125 pub fn SleepConditionVariableSRW(
126 ConditionVariable: PCONDITION_VARIABLE,
127 SRWLock: PSRWLOCK,
128 dwMilliseconds: DWORD,
129 Flags: ULONG,
130 ) -> BOOL;
131 pub fn SetEvent(
132 hEvent: HANDLE,
133 ) -> BOOL;
134 pub fn ResetEvent(
135 hEvent: HANDLE,
136 ) -> BOOL;
137 pub fn ReleaseSemaphore(
138 hSemaphore: HANDLE,
139 lReleaseCount: LONG,
140 lpPreviousCount: LPLONG,
141 ) -> BOOL;
142 pub fn ReleaseMutex(
143 hMutex: HANDLE,
144 ) -> BOOL;
145 pub fn WaitForSingleObject(
146 hHandle: HANDLE,
147 dwMilliseconds: DWORD,
148 ) -> DWORD;
149 pub fn SleepEx(
150 dwMilliseconds: DWORD,
151 bAlertable: BOOL,
152 ) -> DWORD;
153 pub fn WaitForSingleObjectEx(
154 hHandle: HANDLE,
155 dwMilliseconds: DWORD,
156 bAlertable: BOOL,
157 ) -> DWORD;
158 pub fn WaitForMultipleObjectsEx(
159 nCount: DWORD,
160 lpHandles: *const HANDLE,
161 bWaitAll: BOOL,
162 dwMilliseconds: DWORD,
163 bAlertable: BOOL,
164 ) -> DWORD;
165 }
166 //pub const MUTEX_MODIFY_STATE: DWORD = MUTANT_QUERY_STATE;
167 //pub const MUTEX_ALL_ACCESS: DWORD = MUTANT_ALL_ACCESS;
168 extern "system" {
169 pub fn CreateMutexA(
170 lpMutexAttributes: LPSECURITY_ATTRIBUTES,
171 bInitialOwner: BOOL,
172 lpName: LPCSTR,
173 ) -> HANDLE;
174 pub fn CreateMutexW(
175 lpMutexAttributes: LPSECURITY_ATTRIBUTES,
176 bInitialOwner: BOOL,
177 lpName: LPCWSTR,
178 ) -> HANDLE;
179 pub fn OpenMutexW(
180 dwDesiredAccess: DWORD,
181 bInheritHandle: BOOL,
182 lpName: LPCWSTR,
183 ) -> HANDLE;
184 pub fn CreateEventA(
185 lpEventAttributes: LPSECURITY_ATTRIBUTES,
186 bManualReset: BOOL,
187 bInitialState: BOOL,
188 lpName: LPCSTR,
189 ) -> HANDLE;
190 pub fn CreateEventW(
191 lpEventAttributes: LPSECURITY_ATTRIBUTES,
192 bManualReset: BOOL,
193 bInitialState: BOOL,
194 lpName: LPCWSTR,
195 ) -> HANDLE;
196 pub fn OpenEventA(
197 dwDesiredAccess: DWORD,
198 bInheritHandle: BOOL,
199 lpName: LPCSTR,
200 ) -> HANDLE;
201 pub fn OpenEventW(
202 dwDesiredAccess: DWORD,
203 bInheritHandle: BOOL,
204 lpName: LPCWSTR,
205 ) -> HANDLE;
206 pub fn OpenSemaphoreW(
207 dwDesiredAccess: DWORD,
208 bInheritHandle: BOOL,
209 lpName: LPCWSTR,
210 ) -> HANDLE;
211 }
212 FN!{stdcall PTIMERAPCROUTINE(
213 lpArgToCompletionRoutine: LPVOID,
214 dwTimerLowValue: DWORD,
215 dwTimerHighValue: DWORD,
216 ) -> ()}
217 extern "system" {
218 pub fn OpenWaitableTimerW(
219 dwDesiredAccess: DWORD,
220 bInheritHandle: BOOL,
221 lpTimerName: LPCWSTR,
222 ) -> HANDLE;
223 pub fn SetWaitableTimerEx(
224 hTimer: HANDLE,
225 lpDueTime: *const LARGE_INTEGER,
226 lPeriod: LONG,
227 pfnCompletionRoutine: PTIMERAPCROUTINE,
228 lpArgToCompletionRoutine: LPVOID,
229 WakeContext: PREASON_CONTEXT,
230 TolerableDelay: ULONG,
231 ) -> BOOL;
232 pub fn SetWaitableTimer(
233 hTimer: HANDLE,
234 lpDueTime: *const LARGE_INTEGER,
235 lPeriod: LONG,
236 pfnCompletionRoutine: PTIMERAPCROUTINE,
237 lpArgToCompletionRoutine: LPVOID,
238 fResume: BOOL,
239 ) -> BOOL;
240 pub fn CancelWaitableTimer(
241 hTimer: HANDLE,
242 ) -> BOOL;
243 }
244 pub const CREATE_MUTEX_INITIAL_OWNER: DWORD = 0x00000001;
245 extern "system" {
246 pub fn CreateMutexExA(
247 lpMutexAttributes: LPSECURITY_ATTRIBUTES,
248 lpName: LPCSTR,
249 dwFlags: DWORD,
250 dwDesiredAccess: DWORD,
251 ) -> HANDLE;
252 pub fn CreateMutexExW(
253 lpMutexAttributes: LPSECURITY_ATTRIBUTES,
254 lpName: LPCWSTR,
255 dwFlags: DWORD,
256 dwDesiredAccess: DWORD,
257 ) -> HANDLE;
258 }
259 pub const CREATE_EVENT_MANUAL_RESET: DWORD = 0x00000001;
260 pub const CREATE_EVENT_INITIAL_SET: DWORD = 0x00000002;
261 extern "system" {
262 pub fn CreateEventExA(
263 lpEventAttributes: LPSECURITY_ATTRIBUTES,
264 lpName: LPCSTR,
265 dwFlags: DWORD,
266 dwDesiredAccess: DWORD,
267 ) -> HANDLE;
268 pub fn CreateEventExW(
269 lpEventAttributes: LPSECURITY_ATTRIBUTES,
270 lpName: LPCWSTR,
271 dwFlags: DWORD,
272 dwDesiredAccess: DWORD,
273 ) -> HANDLE;
274 pub fn CreateSemaphoreExW(
275 lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES,
276 lInitialCount: LONG,
277 lMaximumCount: LONG,
278 lpName: LPCWSTR,
279 dwFlags: DWORD,
280 dwDesiredAccess: DWORD,
281 ) -> HANDLE;
282 }
283 pub const CREATE_WAITABLE_TIMER_MANUAL_RESET: DWORD = 0x00000001;
284 extern "system" {
285 pub fn CreateWaitableTimerExW(
286 lpTimerAttributes: LPSECURITY_ATTRIBUTES,
287 lpTimerName: LPCWSTR,
288 dwFlags: DWORD,
289 dwDesiredAccess: DWORD,
290 ) -> HANDLE;
291 }
292 pub type SYNCHRONIZATION_BARRIER = RTL_BARRIER;
293 pub type PSYNCHRONIZATION_BARRIER = PRTL_BARRIER;
294 pub type LPSYNCHRONIZATION_BARRIER = PRTL_BARRIER;
295 pub const SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY: DWORD = 0x01;
296 pub const SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY: DWORD = 0x02;
297 pub const SYNCHRONIZATION_BARRIER_FLAGS_NO_DELETE: DWORD = 0x04;
298 extern "system" {
299 pub fn EnterSynchronizationBarrier(
300 lpBarrier: LPSYNCHRONIZATION_BARRIER,
301 dwFlags: DWORD,
302 ) -> BOOL;
303 pub fn InitializeSynchronizationBarrier(
304 lpBarrier: LPSYNCHRONIZATION_BARRIER,
305 lTotalThreads: LONG,
306 lSpinCount: LONG,
307 ) -> BOOL;
308 pub fn DeleteSynchronizationBarrier(
309 lpBarrier: LPSYNCHRONIZATION_BARRIER,
310 ) -> BOOL;
311 pub fn Sleep(
312 dwMilliseconds: DWORD,
313 );
314 pub fn WaitOnAddress(
315 Address: *mut VOID,
316 CompareAddress: PVOID,
317 AddressSize: SIZE_T,
318 dwMilliseconds: DWORD,
319 ) -> BOOL;
320 pub fn WakeByAddressSingle(
321 Address: PVOID,
322 );
323 pub fn WakeByAddressAll(
324 Address: PVOID,
325 );
326 pub fn SignalObjectAndWait(
327 hObjectToSignal: HANDLE,
328 hObjectToWaitOn: HANDLE,
329 dwMilliseconds: DWORD,
330 bAlertable: BOOL,
331 ) -> DWORD;
332 pub fn WaitForMultipleObjects(
333 nCount: DWORD,
334 lpHandles: *const HANDLE,
335 bWaitAll: BOOL,
336 dwMilliseconds: DWORD,
337 ) -> DWORD;
338 pub fn CreateSemaphoreW(
339 lpSemaphoreAttributes: LPSECURITY_ATTRIBUTES,
340 lInitialCount: LONG,
341 lMaximumCount: LONG,
342 lpName: LPCWSTR,
343 ) -> HANDLE;
344 pub fn CreateWaitableTimerW(
345 lpTimerAttributes: LPSECURITY_ATTRIBUTES,
346 bManualReset: BOOL,
347 lpTimerName: LPCWSTR,
348 ) -> HANDLE;
349 }