From 79bce0a5f2303a875949e8a1dae63041c70fd968 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 15 Sep 2013 10:46:54 +0000 Subject: [PATCH] sync: add semaphore implementation [SVN r85673] --- include/boost/detail/win/synchronization.hpp | 58 ++++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/include/boost/detail/win/synchronization.hpp b/include/boost/detail/win/synchronization.hpp index 8fe015b..d899b41 100644 --- a/include/boost/detail/win/synchronization.hpp +++ b/include/boost/detail/win/synchronization.hpp @@ -27,7 +27,7 @@ namespace win32 using ::TryEnterCriticalSection; using ::LeaveCriticalSection; using ::DeleteCriticalSection; - + # ifdef BOOST_NO_ANSI_APIS using ::CreateMutexW; using ::CreateEventW; @@ -46,6 +46,12 @@ namespace win32 using ::WaitForMultipleObjects; using ::WaitForSingleObject; using ::QueueUserAPC; + + static const DWORD_ wait_abandoned = WAIT_ABANDONED; + static const DWORD_ wait_object_0 = WAIT_OBJECT_0; + static const DWORD_ wait_timeout = WAIT_TIMEOUT; + static const DWORD_ wait_failed = WAIT_FAILED; + #else extern "C" { struct CRITICAL_SECTION_ @@ -62,61 +68,67 @@ extern "C" { #endif }; - __declspec(dllimport) void __stdcall + __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION_ *); - __declspec(dllimport) void __stdcall + __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION_ *); - __declspec(dllimport) bool __stdcall + __declspec(dllimport) bool __stdcall TryEnterCriticalSection(CRITICAL_SECTION_ *); - __declspec(dllimport) void __stdcall + __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION_ *); - __declspec(dllimport) void __stdcall + __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION_ *); - + struct _SECURITY_ATTRIBUTES; # ifdef BOOST_NO_ANSI_APIS - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall CreateMutexW(_SECURITY_ATTRIBUTES*,int,wchar_t const*); - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall CreateSemaphoreW(_SECURITY_ATTRIBUTES*,long,long,wchar_t const*); - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall CreateEventW(_SECURITY_ATTRIBUTES*,int,int,wchar_t const*); - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall OpenEventW(unsigned long,int,wchar_t const*); # else - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall CreateMutexA(_SECURITY_ATTRIBUTES*,int,char const*); - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall CreateSemaphoreA(_SECURITY_ATTRIBUTES*,long,long,char const*); - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall CreateEventA(_SECURITY_ATTRIBUTES*,int,int,char const*); - __declspec(dllimport) void* __stdcall + __declspec(dllimport) void* __stdcall OpenEventA(unsigned long,int,char const*); # endif - __declspec(dllimport) int __stdcall + __declspec(dllimport) int __stdcall ReleaseMutex(void*); - __declspec(dllimport) unsigned long __stdcall + __declspec(dllimport) unsigned long __stdcall WaitForSingleObject(void*,unsigned long); - __declspec(dllimport) unsigned long __stdcall + __declspec(dllimport) unsigned long __stdcall WaitForMultipleObjects(unsigned long nCount, void* const * lpHandles, int bWaitAll, unsigned long dwMilliseconds); - __declspec(dllimport) int __stdcall + __declspec(dllimport) int __stdcall ReleaseSemaphore(void*,long,long*); typedef void (__stdcall *PAPCFUNC8)(ulong_ptr); - __declspec(dllimport) unsigned long __stdcall + __declspec(dllimport) unsigned long __stdcall QueueUserAPC(PAPCFUNC8,void*,ulong_ptr); # ifndef UNDER_CE - __declspec(dllimport) int __stdcall + __declspec(dllimport) int __stdcall SetEvent(void*); - __declspec(dllimport) int __stdcall + __declspec(dllimport) int __stdcall ResetEvent(void*); # else using ::SetEvent; using ::ResetEvent; + + static const DWORD_ wait_abandoned = 0x00000080L; + static const DWORD_ wait_object_0 = 0x00000000L; + static const DWORD_ wait_timeout = 0x00000102L; + static const DWORD_ wait_failed = (DWORD_)0xFFFFFFFF; + # endif -} +} #endif } }