blob: 374b18506570e5d7f9c5d520a3d743e73d4c8414 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include "objects.h"
#ifdef WIN_DRIVER
extern "C" EXCEPTION_DISPOSITION __cdecl __CxxFrameHandler3(int a, int b, int c, int d)
{
return ExceptionContinueSearch;
}
#endif
/**
* CriticalSection
*/
CriticalSection::CriticalSection(CRITICAL_SECTION &critical_section)
: critical_section_(critical_section)
{
#ifdef VMP_GNU
pthread_mutex_lock(&critical_section_);
#elif defined(WIN_DRIVER)
KeWaitForMutexObject(&critical_section_, Executive, KernelMode, FALSE, NULL);
#else
EnterCriticalSection(&critical_section_);
#endif
}
CriticalSection::~CriticalSection()
{
#ifdef VMP_GNU
pthread_mutex_unlock(&critical_section_);
#elif defined(WIN_DRIVER)
KeReleaseMutex(&critical_section_, FALSE);
#else
LeaveCriticalSection(&critical_section_);
#endif
}
void CriticalSection::Init(CRITICAL_SECTION &critical_section)
{
#ifdef VMP_GNU
pthread_mutex_init(&critical_section, NULL);
#elif defined(WIN_DRIVER)
KeInitializeMutex(&critical_section, 0);
#else
InitializeCriticalSection(&critical_section);
#endif
}
void CriticalSection::Free(CRITICAL_SECTION &critical_section)
{
#ifdef VMP_GNU
pthread_mutex_destroy(&critical_section);
#elif defined(WIN_DRIVER)
// do nothing
#else
DeleteCriticalSection(&critical_section);
#endif
}
|