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}
;
10 LPCRITICAL_SECTION
, LPSECURITY_ATTRIBUTES
, PCRITICAL_SECTION
, PREASON_CONTEXT
,
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
17 pub const SRWLOCK_INIT
: SRWLOCK
= RTL_SRWLOCK_INIT
;
18 pub type SRWLOCK
= RTL_SRWLOCK
;
19 pub type PSRWLOCK
= *mut RTL_SRWLOCK
;
21 pub fn InitializeSRWLock(
24 pub fn ReleaseSRWLockExclusive(
27 pub fn ReleaseSRWLockShared(
30 pub fn AcquireSRWLockExclusive(
33 pub fn AcquireSRWLockShared(
36 pub fn TryAcquireSRWLockExclusive(
39 pub fn TryAcquireSRWLockShared(
42 pub fn InitializeCriticalSection(
43 lpCriticalSection
: LPCRITICAL_SECTION
,
45 pub fn EnterCriticalSection(
46 lpCriticalSection
: LPCRITICAL_SECTION
,
48 pub fn LeaveCriticalSection(
49 lpCriticalSection
: LPCRITICAL_SECTION
,
51 pub fn InitializeCriticalSectionAndSpinCount(
52 lpCriticalSection
: LPCRITICAL_SECTION
,
55 pub fn InitializeCriticalSectionEx(
56 lpCriticalSection
: LPCRITICAL_SECTION
,
60 pub fn SetCriticalSectionSpinCount(
61 lpCriticalSection
: LPCRITICAL_SECTION
,
64 pub fn TryEnterCriticalSection(
65 lpCriticalSection
: LPCRITICAL_SECTION
,
67 pub fn DeleteCriticalSection(
68 lpCriticalSection
: LPCRITICAL_SECTION
,
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(
85 pub fn InitOnceInitialize(
88 pub fn InitOnceExecuteOnce(
90 InitFn
: PINIT_ONCE_FN
,
94 pub fn InitOnceBeginInitialize(
95 lpInitOnce
: LPINIT_ONCE
,
98 lpContext
: *mut LPVOID
,
100 pub fn InitOnceComplete(
101 lpInitOnce
: LPINIT_ONCE
,
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;
111 pub fn InitializeConditionVariable(
112 ConditionVariable
: PCONDITION_VARIABLE
,
114 pub fn WakeConditionVariable(
115 ConditionVariable
: PCONDITION_VARIABLE
,
117 pub fn WakeAllConditionVariable(
118 ConditionVariable
: PCONDITION_VARIABLE
,
120 pub fn SleepConditionVariableCS(
121 ConditionVariable
: PCONDITION_VARIABLE
,
122 CriticalSection
: PCRITICAL_SECTION
,
123 dwMilliseconds
: DWORD
,
125 pub fn SleepConditionVariableSRW(
126 ConditionVariable
: PCONDITION_VARIABLE
,
128 dwMilliseconds
: DWORD
,
137 pub fn ReleaseSemaphore(
140 lpPreviousCount
: LPLONG
,
145 pub fn WaitForSingleObject(
147 dwMilliseconds
: DWORD
,
150 dwMilliseconds
: DWORD
,
153 pub fn WaitForSingleObjectEx(
155 dwMilliseconds
: DWORD
,
158 pub fn WaitForMultipleObjectsEx(
160 lpHandles
: *const HANDLE
,
162 dwMilliseconds
: DWORD
,
166 //pub const MUTEX_MODIFY_STATE: DWORD = MUTANT_QUERY_STATE;
167 //pub const MUTEX_ALL_ACCESS: DWORD = MUTANT_ALL_ACCESS;
170 lpMutexAttributes
: LPSECURITY_ATTRIBUTES
,
175 lpMutexAttributes
: LPSECURITY_ATTRIBUTES
,
180 dwDesiredAccess
: DWORD
,
181 bInheritHandle
: BOOL
,
185 lpEventAttributes
: LPSECURITY_ATTRIBUTES
,
191 lpEventAttributes
: LPSECURITY_ATTRIBUTES
,
197 dwDesiredAccess
: DWORD
,
198 bInheritHandle
: BOOL
,
202 dwDesiredAccess
: DWORD
,
203 bInheritHandle
: BOOL
,
206 pub fn OpenSemaphoreW(
207 dwDesiredAccess
: DWORD
,
208 bInheritHandle
: BOOL
,
212 FN
!{stdcall
PTIMERAPCROUTINE(
213 lpArgToCompletionRoutine
: LPVOID
,
214 dwTimerLowValue
: DWORD
,
215 dwTimerHighValue
: DWORD
,
218 pub fn OpenWaitableTimerW(
219 dwDesiredAccess
: DWORD
,
220 bInheritHandle
: BOOL
,
221 lpTimerName
: LPCWSTR
,
223 pub fn SetWaitableTimerEx(
225 lpDueTime
: *const LARGE_INTEGER
,
227 pfnCompletionRoutine
: PTIMERAPCROUTINE
,
228 lpArgToCompletionRoutine
: LPVOID
,
229 WakeContext
: PREASON_CONTEXT
,
230 TolerableDelay
: ULONG
,
232 pub fn SetWaitableTimer(
234 lpDueTime
: *const LARGE_INTEGER
,
236 pfnCompletionRoutine
: PTIMERAPCROUTINE
,
237 lpArgToCompletionRoutine
: LPVOID
,
240 pub fn CancelWaitableTimer(
244 pub const CREATE_MUTEX_INITIAL_OWNER
: DWORD
= 0x00000001;
246 pub fn CreateMutexExA(
247 lpMutexAttributes
: LPSECURITY_ATTRIBUTES
,
250 dwDesiredAccess
: DWORD
,
252 pub fn CreateMutexExW(
253 lpMutexAttributes
: LPSECURITY_ATTRIBUTES
,
256 dwDesiredAccess
: DWORD
,
259 pub const CREATE_EVENT_MANUAL_RESET
: DWORD
= 0x00000001;
260 pub const CREATE_EVENT_INITIAL_SET
: DWORD
= 0x00000002;
262 pub fn CreateEventExA(
263 lpEventAttributes
: LPSECURITY_ATTRIBUTES
,
266 dwDesiredAccess
: DWORD
,
268 pub fn CreateEventExW(
269 lpEventAttributes
: LPSECURITY_ATTRIBUTES
,
272 dwDesiredAccess
: DWORD
,
274 pub fn CreateSemaphoreExW(
275 lpSemaphoreAttributes
: LPSECURITY_ATTRIBUTES
,
280 dwDesiredAccess
: DWORD
,
283 pub const CREATE_WAITABLE_TIMER_MANUAL_RESET
: DWORD
= 0x00000001;
285 pub fn CreateWaitableTimerExW(
286 lpTimerAttributes
: LPSECURITY_ATTRIBUTES
,
287 lpTimerName
: LPCWSTR
,
289 dwDesiredAccess
: DWORD
,
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;
299 pub fn EnterSynchronizationBarrier(
300 lpBarrier
: LPSYNCHRONIZATION_BARRIER
,
303 pub fn InitializeSynchronizationBarrier(
304 lpBarrier
: LPSYNCHRONIZATION_BARRIER
,
308 pub fn DeleteSynchronizationBarrier(
309 lpBarrier
: LPSYNCHRONIZATION_BARRIER
,
312 dwMilliseconds
: DWORD
,
314 pub fn WaitOnAddress(
316 CompareAddress
: PVOID
,
318 dwMilliseconds
: DWORD
,
320 pub fn WakeByAddressSingle(
323 pub fn WakeByAddressAll(
326 pub fn SignalObjectAndWait(
327 hObjectToSignal
: HANDLE
,
328 hObjectToWaitOn
: HANDLE
,
329 dwMilliseconds
: DWORD
,
332 pub fn WaitForMultipleObjects(
334 lpHandles
: *const HANDLE
,
336 dwMilliseconds
: DWORD
,
338 pub fn CreateSemaphoreW(
339 lpSemaphoreAttributes
: LPSECURITY_ATTRIBUTES
,
344 pub fn CreateWaitableTimerW(
345 lpTimerAttributes
: LPSECURITY_ATTRIBUTES
,
347 lpTimerName
: LPCWSTR
,