sync: add semaphore implementation

[SVN r85673]
This commit is contained in:
Tim Blechmann
2013-09-15 10:46:54 +00:00
parent 6a98633c6c
commit 79bce0a5f2

View File

@@ -27,7 +27,7 @@ namespace win32
using ::TryEnterCriticalSection; using ::TryEnterCriticalSection;
using ::LeaveCriticalSection; using ::LeaveCriticalSection;
using ::DeleteCriticalSection; using ::DeleteCriticalSection;
# ifdef BOOST_NO_ANSI_APIS # ifdef BOOST_NO_ANSI_APIS
using ::CreateMutexW; using ::CreateMutexW;
using ::CreateEventW; using ::CreateEventW;
@@ -46,6 +46,12 @@ namespace win32
using ::WaitForMultipleObjects; using ::WaitForMultipleObjects;
using ::WaitForSingleObject; using ::WaitForSingleObject;
using ::QueueUserAPC; 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 #else
extern "C" { extern "C" {
struct CRITICAL_SECTION_ struct CRITICAL_SECTION_
@@ -62,61 +68,67 @@ extern "C" {
#endif #endif
}; };
__declspec(dllimport) void __stdcall __declspec(dllimport) void __stdcall
InitializeCriticalSection(CRITICAL_SECTION_ *); InitializeCriticalSection(CRITICAL_SECTION_ *);
__declspec(dllimport) void __stdcall __declspec(dllimport) void __stdcall
EnterCriticalSection(CRITICAL_SECTION_ *); EnterCriticalSection(CRITICAL_SECTION_ *);
__declspec(dllimport) bool __stdcall __declspec(dllimport) bool __stdcall
TryEnterCriticalSection(CRITICAL_SECTION_ *); TryEnterCriticalSection(CRITICAL_SECTION_ *);
__declspec(dllimport) void __stdcall __declspec(dllimport) void __stdcall
LeaveCriticalSection(CRITICAL_SECTION_ *); LeaveCriticalSection(CRITICAL_SECTION_ *);
__declspec(dllimport) void __stdcall __declspec(dllimport) void __stdcall
DeleteCriticalSection(CRITICAL_SECTION_ *); DeleteCriticalSection(CRITICAL_SECTION_ *);
struct _SECURITY_ATTRIBUTES; struct _SECURITY_ATTRIBUTES;
# ifdef BOOST_NO_ANSI_APIS # ifdef BOOST_NO_ANSI_APIS
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
CreateMutexW(_SECURITY_ATTRIBUTES*,int,wchar_t const*); CreateMutexW(_SECURITY_ATTRIBUTES*,int,wchar_t const*);
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
CreateSemaphoreW(_SECURITY_ATTRIBUTES*,long,long,wchar_t const*); CreateSemaphoreW(_SECURITY_ATTRIBUTES*,long,long,wchar_t const*);
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
CreateEventW(_SECURITY_ATTRIBUTES*,int,int,wchar_t const*); CreateEventW(_SECURITY_ATTRIBUTES*,int,int,wchar_t const*);
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
OpenEventW(unsigned long,int,wchar_t const*); OpenEventW(unsigned long,int,wchar_t const*);
# else # else
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
CreateMutexA(_SECURITY_ATTRIBUTES*,int,char const*); CreateMutexA(_SECURITY_ATTRIBUTES*,int,char const*);
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
CreateSemaphoreA(_SECURITY_ATTRIBUTES*,long,long,char const*); CreateSemaphoreA(_SECURITY_ATTRIBUTES*,long,long,char const*);
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
CreateEventA(_SECURITY_ATTRIBUTES*,int,int,char const*); CreateEventA(_SECURITY_ATTRIBUTES*,int,int,char const*);
__declspec(dllimport) void* __stdcall __declspec(dllimport) void* __stdcall
OpenEventA(unsigned long,int,char const*); OpenEventA(unsigned long,int,char const*);
# endif # endif
__declspec(dllimport) int __stdcall __declspec(dllimport) int __stdcall
ReleaseMutex(void*); ReleaseMutex(void*);
__declspec(dllimport) unsigned long __stdcall __declspec(dllimport) unsigned long __stdcall
WaitForSingleObject(void*,unsigned long); WaitForSingleObject(void*,unsigned long);
__declspec(dllimport) unsigned long __stdcall __declspec(dllimport) unsigned long __stdcall
WaitForMultipleObjects(unsigned long nCount, WaitForMultipleObjects(unsigned long nCount,
void* const * lpHandles, void* const * lpHandles,
int bWaitAll, int bWaitAll,
unsigned long dwMilliseconds); unsigned long dwMilliseconds);
__declspec(dllimport) int __stdcall __declspec(dllimport) int __stdcall
ReleaseSemaphore(void*,long,long*); ReleaseSemaphore(void*,long,long*);
typedef void (__stdcall *PAPCFUNC8)(ulong_ptr); typedef void (__stdcall *PAPCFUNC8)(ulong_ptr);
__declspec(dllimport) unsigned long __stdcall __declspec(dllimport) unsigned long __stdcall
QueueUserAPC(PAPCFUNC8,void*,ulong_ptr); QueueUserAPC(PAPCFUNC8,void*,ulong_ptr);
# ifndef UNDER_CE # ifndef UNDER_CE
__declspec(dllimport) int __stdcall __declspec(dllimport) int __stdcall
SetEvent(void*); SetEvent(void*);
__declspec(dllimport) int __stdcall __declspec(dllimport) int __stdcall
ResetEvent(void*); ResetEvent(void*);
# else # else
using ::SetEvent; using ::SetEvent;
using ::ResetEvent; 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
} }
#endif #endif
} }
} }