#ifdef _MSC_VER
#pragma once
#endif // _MSC_VER
#ifndef _SYNCHAPI_H_
#define _SYNCHAPI_H_
#include <apiset.h>
#include <apisetcconv.h>
#include <minwindef.h>
#include <minwinbase.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#pragma region Application or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
#define SRWLOCK_INIT RTL_SRWLOCK_INIT
typedef
, *
;
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#pragma region Application or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
#if (_WIN32_WINNT >= 0x0600)
(
);
_Releases_exclusive_lock_(*SRWLock)
(
);
_Releases_shared_lock_(*SRWLock)
(
);
_Acquires_exclusive_lock_(*SRWLock)
(
);
_Acquires_shared_lock_(*SRWLock)
(
);
_When_(return!=0, _Acquires_exclusive_lock_(*SRWLock))
TryAcquireSRWLockExclusive
(
);
_When_(return!=0, _Acquires_shared_lock_(*SRWLock))
(
);
#endif // (_WIN32_WINNT >= 0x0600)
#if (_WIN32_WINNT < 0x0600)
_Maybe_raises_SEH_exception_
WINBASEAPI
VOID
WINAPI
InitializeCriticalSection(
_Out_ LPCRITICAL_SECTION lpCriticalSection
);
#else
InitializeCriticalSection
(
_Out_ LPCRITICAL_SECTION lpCriticalSection
);
#endif // (_WIN32_WINNT < 0x0600)
(
_Inout_ LPCRITICAL_SECTION lpCriticalSection
);
(
_Inout_ LPCRITICAL_SECTION lpCriticalSection
);
_Must_inspect_result_
InitializeCriticalSectionAndSpinCount
(
_Out_ LPCRITICAL_SECTION lpCriticalSection,
);
#if (_WIN32_WINNT >= 0x0600)
InitializeCriticalSectionEx
(
_Out_ LPCRITICAL_SECTION lpCriticalSection,
);
#endif // (_WIN32_WINNT >= 0x0600)
SetCriticalSectionSpinCount
(
_Inout_ LPCRITICAL_SECTION lpCriticalSection,
);
#if (_WIN32_WINNT >= 0x0400)
(
_Inout_ LPCRITICAL_SECTION lpCriticalSection
);
#endif /* _WIN32_WINNT >= 0x0400 */
(
_Inout_ LPCRITICAL_SECTION lpCriticalSection
);
typedef
;
typedef
;
typedef
;
#define INIT_ONCE_STATIC_INIT RTL_RUN_ONCE_INIT
#define INIT_ONCE_CHECK_ONLY RTL_RUN_ONCE_CHECK_ONLY
#define INIT_ONCE_ASYNC RTL_RUN_ONCE_ASYNC
#define INIT_ONCE_INIT_FAILED RTL_RUN_ONCE_INIT_FAILED
#define INIT_ONCE_CTX_RESERVED_BITS RTL_RUN_ONCE_CTX_RESERVED_BITS
typedef
(WINAPI *PINIT_ONCE_FN) (
_Inout_ PINIT_ONCE InitOnce,
_Inout_opt_ PVOID Parameter,
_Outptr_opt_result_maybenull_ PVOID *Context
);
#if (_WIN32_WINNT >= 0x0600)
(
_Out_ PINIT_ONCE InitOnce
);
(
_Inout_ PINIT_ONCE InitOnce,
_In_ __callback PINIT_ONCE_FN InitFn,
_Inout_opt_ PVOID Parameter,
_Outptr_opt_result_maybenull_ LPVOID* Context
);
(
_Inout_ LPINIT_ONCE lpInitOnce,
_Outptr_opt_result_maybenull_ LPVOID* lpContext
);
(
_Inout_ LPINIT_ONCE lpInitOnce,
_In_opt_ LPVOID lpContext
);
#endif // (_WIN32_WINNT >= 0x0600)
typedef
, *
;
#define CONDITION_VARIABLE_INIT RTL_CONDITION_VARIABLE_INIT
#define CONDITION_VARIABLE_LOCKMODE_SHARED RTL_CONDITION_VARIABLE_LOCKMODE_SHARED
#if (_WIN32_WINNT >= 0x0600)
InitializeConditionVariable
(
_Out_ PCONDITION_VARIABLE ConditionVariable
);
(
_Inout_ PCONDITION_VARIABLE ConditionVariable
);
(
_Inout_ PCONDITION_VARIABLE ConditionVariable
);
(
_Inout_ PCONDITION_VARIABLE ConditionVariable,
_Inout_ PCRITICAL_SECTION CriticalSection,
_In_ DWORD dwMilliseconds
);
SleepConditionVariableSRW
(
_Inout_ PCONDITION_VARIABLE ConditionVariable,
_Inout_ PSRWLOCK SRWLock,
_In_ DWORD dwMilliseconds,
);
#endif // (_WIN32_WINNT >= 0x0600)
(
);
(
);
(
_Out_opt_ LPLONG lpPreviousCount
);
(
);
(
_In_ DWORD dwMilliseconds
);
(
_In_ DWORD dwMilliseconds,
);
(
_In_ DWORD dwMilliseconds,
);
(
_In_reads_(nCount) CONST HANDLE* lpHandles,
_In_ DWORD dwMilliseconds,
);
#define MUTEX_MODIFY_STATE MUTANT_QUERY_STATE
#define MUTEX_ALL_ACCESS MUTANT_ALL_ACCESS
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpMutexAttributes,
);
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpMutexAttributes,
);
#ifdef UNICODE
#define CreateMutex CreateMutexW
#else
#define CreateMutex CreateMutexA
#endif // !UNICODE
_Ret_maybenull_
(
_In_ DWORD dwDesiredAccess,
_In_ BOOL bInheritHandle,
);
#ifdef UNICODE
#define OpenMutex OpenMutexW
#endif
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpEventAttributes,
);
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpEventAttributes,
);
#ifdef UNICODE
#define CreateEvent CreateEventW
#else
#define CreateEvent CreateEventA
#endif // !UNICODE
_Ret_maybenull_
(
_In_ DWORD dwDesiredAccess,
_In_ BOOL bInheritHandle,
);
_Ret_maybenull_
(
_In_ DWORD dwDesiredAccess,
_In_ BOOL bInheritHandle,
);
#ifdef UNICODE
#define OpenEvent OpenEventW
#else
#define OpenEvent OpenEventA
#endif // !UNICODE
_Ret_maybenull_
(
_In_ DWORD dwDesiredAccess,
_In_ BOOL bInheritHandle,
);
#ifdef UNICODE
#define OpenSemaphore OpenSemaphoreW
#endif
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
typedef
(APIENTRY *PTIMERAPCROUTINE)(
_In_opt_ LPVOID lpArgToCompletionRoutine,
lpArgToCompletionRoutine,
_In_ DWORD dwTimerLowValue,
_In_ DWORD dwTimerHighValue
);
_Ret_maybenull_
(
_In_ DWORD dwDesiredAccess,
_In_ BOOL bInheritHandle,
);
#ifdef UNICODE
#define OpenWaitableTimer OpenWaitableTimerW
#endif
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
(
_In_ const LARGE_INTEGER* lpDueTime,
_In_opt_ PTIMERAPCROUTINE pfnCompletionRoutine,
_In_opt_ LPVOID lpArgToCompletionRoutine,
_In_opt_ PREASON_CONTEXT WakeContext,
_In_ ULONG TolerableDelay
);
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
(
_In_ const LARGE_INTEGER* lpDueTime,
_In_opt_ PTIMERAPCROUTINE pfnCompletionRoutine,
_In_opt_ LPVOID lpArgToCompletionRoutine,
);
(
);
#if (_WIN32_WINNT >= 0x0600)
#define CREATE_MUTEX_INITIAL_OWNER 0x00000001
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpMutexAttributes,
_In_ DWORD dwDesiredAccess
);
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpMutexAttributes,
_In_ DWORD dwDesiredAccess
);
#ifdef UNICODE
#define CreateMutexEx CreateMutexExW
#else
#define CreateMutexEx CreateMutexExA
#endif // !UNICODE
#define CREATE_EVENT_MANUAL_RESET 0x00000001
#define CREATE_EVENT_INITIAL_SET 0x00000002
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpEventAttributes,
_In_ DWORD dwDesiredAccess
);
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpEventAttributes,
_In_ DWORD dwDesiredAccess
);
#ifdef UNICODE
#define CreateEventEx CreateEventExW
#else
#define CreateEventEx CreateEventExA
#endif // !UNICODE
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
_Reserved_ DWORD dwFlags,
_In_ DWORD dwDesiredAccess
);
#ifdef UNICODE
#define CreateSemaphoreEx CreateSemaphoreExW
#endif
#define CREATE_WAITABLE_TIMER_MANUAL_RESET 0x00000001
#if (_WIN32_WINNT >= _NT_TARGET_VERSION_WIN10_RS4)
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x00000002
#endif
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpTimerAttributes,
_In_opt_ LPCWSTR lpTimerName,
_In_ DWORD dwDesiredAccess
);
#ifdef UNICODE
#define CreateWaitableTimerEx CreateWaitableTimerExW
#endif
#endif // (_WIN32_WINNT >= 0x0600)
#endif // (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#pragma region Desktop or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
typedef
;
typedef
;
typedef
LPSYNCHRONIZATION_BARRIER
;
#define SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY 0x01
#define SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY 0x02
#define SYNCHRONIZATION_BARRIER_FLAGS_NO_DELETE 0x04
EnterSynchronizationBarrier
(
_Inout_ LPSYNCHRONIZATION_BARRIER lpBarrier,
LPSYNCHRONIZATION_BARRIER
,
);
InitializeSynchronizationBarrier
(
_Out_ LPSYNCHRONIZATION_BARRIER lpBarrier,
LPSYNCHRONIZATION_BARRIER
,
);
DeleteSynchronizationBarrier
(
_Inout_ LPSYNCHRONIZATION_BARRIER lpBarrier
LPSYNCHRONIZATION_BARRIER
);
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#pragma region Application or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
(
_In_ DWORD dwMilliseconds
);
(
_In_reads_bytes_(AddressSize) volatile VOID* Address,
_In_reads_bytes_(AddressSize) PVOID CompareAddress,
_In_opt_ DWORD dwMilliseconds
);
(
);
(
);
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#pragma region Desktop or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#ifndef MIDL_PASS
(
_In_ HANDLE hObjectToSignal,
_In_ HANDLE hObjectToWaitOn,
_In_ DWORD dwMilliseconds,
);
#endif
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#pragma region Application or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
(
_In_reads_(nCount) CONST HANDLE* lpHandles,
_In_ DWORD dwMilliseconds
);
(
_In_opt_ LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
);
#ifdef UNICODE
#define CreateSemaphore CreateSemaphoreW
#endif
_Ret_maybenull_
(
_In_opt_ LPSECURITY_ATTRIBUTES lpTimerAttributes,
_In_opt_ LPCWSTR lpTimerName
);
#ifdef UNICODE
#define CreateWaitableTimer CreateWaitableTimerW
#endif
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#ifdef __cplusplus
}
#endif
#endif // _SYNCHAPI_H_