29
29
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x2
30
30
#endif
31
31
32
- // typedef HANDLE (WINAPI *CreateWaitableTimerExW_t)(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess);
33
- // static CreateWaitableTimerExW_t pCreateWaitableTimerExW;
34
-
35
- // typedef BOOL (WINAPI *SetWaitableTimerEx_t)(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay);
36
- // static SetWaitableTimerEx_t pSetWaitableTimerEx;
37
-
38
- // static void SDL_CleanupWaitableHandle(void *handle)
39
- // {
40
- // CloseHandle(handle);
41
- // }
42
-
43
- // static HANDLE SDL_GetWaitableTimer(void)
44
- // {
45
- // static SDL_TLSID TLS_timer_handle;
46
- // HANDLE timer;
47
-
48
- // if (!pCreateWaitableTimerExW || !pSetWaitableTimerEx) {
49
- // static bool initialized;
50
-
51
- // if (!initialized) {
52
- // HMODULE module = GetModuleHandle(TEXT("kernel32.dll"));
53
- // if (module) {
54
- // pCreateWaitableTimerExW = (CreateWaitableTimerExW_t)GetProcAddress(module, "CreateWaitableTimerExW");
55
- // pSetWaitableTimerEx = (SetWaitableTimerEx_t)GetProcAddress(module, "SetWaitableTimerEx");
56
- // }
57
- // initialized = true;
58
- // }
59
-
60
- // if (!pCreateWaitableTimerExW || !pSetWaitableTimerEx) {
61
- // return NULL;
62
- // }
63
- // }
64
-
65
- // timer = SDL_GetTLS(&TLS_timer_handle);
66
- // if (!timer) {
67
- // timer = pCreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
68
- // if (timer) {
69
- // SDL_SetTLS(&TLS_timer_handle, timer, SDL_CleanupWaitableHandle);
70
- // }
71
- // }
72
- // return timer;
73
- // }
74
-
75
- // static HANDLE SDL_GetWaitableEvent(void)
76
- // {
77
- // static SDL_TLSID TLS_event_handle;
78
- // HANDLE event;
79
-
80
- // event = SDL_GetTLS(&TLS_event_handle);
81
- // if (!event) {
82
- // event = CreateEvent(NULL, FALSE, FALSE, NULL);
83
- // if (event) {
84
- // SDL_SetTLS(&TLS_event_handle, event, SDL_CleanupWaitableHandle);
85
- // }
86
- // }
87
- // return event;
88
- // }
89
-
90
32
Uint64 SDL_GetPerformanceCounter (void )
91
33
{
92
34
LARGE_INTEGER counter ;
@@ -103,36 +45,13 @@ Uint64 SDL_GetPerformanceFrequency(void)
103
45
return (Uint64 )frequency .QuadPart ;
104
46
}
105
47
106
- NTSYSAPI DWORD NTAPI NtDelayExecution ( BOOLEAN Alertable , PLARGE_INTEGER DelayInterval );
107
- // typedef DWORD (NTAPI *NtDelayExecution_t)(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval);
108
- // static NtDelayExecution_t pNtDelayExecution;
109
- // static void SDL_NtDelayExecution(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval)
110
- // {
111
- // if (!pNtDelayExecution) {
112
- // static bool initialized;
113
-
114
- // if (!initialized) {
115
- // HMODULE module = GetModuleHandle(TEXT("ntdll.dll"));
116
- // if (module) {
117
- // pNtDelayExecution = (NtDelayExecution_t)GetProcAddress(module, "NtDelayExecution");
118
- // }
119
- // initialized = true;
120
- // }
121
-
122
- // if (!pNtDelayExecution) {
123
- // return;
124
- // }
125
- // }
126
-
127
- // pNtDelayExecution(Alertable, DelayInterval);
128
- // }
129
48
130
49
void SDL_SYS_DelayNS (Uint64 ns )
131
50
{
132
51
Sint64 tick = ns ;
133
52
tick /= 100 ;
134
53
tick *= -1 ;
135
- // SDL_NtDelayExecution(0, ( PLARGE_INTEGER)&tick );
54
+ NTSYSAPI DWORD NTAPI NtDelayExecution ( BOOLEAN Alertable , PLARGE_INTEGER DelayInterval );
136
55
NtDelayExecution (0 , (PLARGE_INTEGER )& tick );
137
56
}
138
57
0 commit comments