forked from audetto/AppleWin
/
winbase.cpp
109 lines (87 loc) · 1.96 KB
/
winbase.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "winbase.h"
#include <errno.h>
#include <iostream>
#include <chrono>
#include <thread>
#include <unistd.h>
#include <sstream>
DWORD WINAPI GetLastError(void)
{
return errno;
}
void DeleteCriticalSection(CRITICAL_SECTION * criticalSection)
{
}
void InitializeCriticalSection(CRITICAL_SECTION * criticalSection)
{
}
void EnterCriticalSection(CRITICAL_SECTION * criticalSection)
{
}
void LeaveCriticalSection(CRITICAL_SECTION * criticalSection)
{
}
BOOL SetCurrentDirectory(LPCSTR path)
{
const int res = chdir(path);
return res == 0;
}
void OutputDebugString(const char * str)
{
std::cerr << str;
}
void ExitProcess(int status)
{
std::ostringstream buffer("ExitProcess: ");
buffer << status;
throw std::runtime_error(buffer.str());
}
DWORD WINAPI WaitForMultipleObjects(DWORD,const HANDLE*,BOOL,DWORD)
{
return WAIT_FAILED;
}
DWORD WINAPI WaitForSingleObject(const HANDLE,DWORD)
{
return WAIT_FAILED;
}
BOOL WINAPI GetExitCodeThread(HANDLE,LPDWORD code)
{
*code = 0;
return TRUE;
}
BOOL WINAPI SetEvent(HANDLE)
{
return TRUE;
}
VOID WINAPI Sleep(DWORD ms)
{
std::this_thread::sleep_for (std::chrono::milliseconds(ms));
}
BOOL WINAPI SetThreadPriority(HANDLE,INT)
{
return TRUE;
}
HANDLE WINAPI CreateEvent(LPSECURITY_ATTRIBUTES,BOOL,BOOL,LPCSTR)
{
return INVALID_HANDLE_VALUE;
}
HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES,SIZE_T,LPTHREAD_START_ROUTINE,LPVOID,DWORD,LPDWORD)
{
return INVALID_HANDLE_VALUE;
}
BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER*counter)
{
const auto now = std::chrono::steady_clock::now();
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch());
counter->QuadPart = ms.count();
return TRUE;
}
HANDLE CreateSemaphore(
LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
LONG lInitialCount,
LONG lMaximumCount,
LPCSTR lpName
)
{
return INVALID_HANDLE_VALUE;
}