mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
timer, windows: allow building high resolution code with old SDKs.
This commit is contained in:
@@ -24,6 +24,11 @@
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
/* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag was added in Windows 10 version 1803. */
|
||||
#ifndef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x2
|
||||
#endif
|
||||
|
||||
typedef HANDLE (WINAPI *CreateWaitableTimerExW_t)(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess);
|
||||
static CreateWaitableTimerExW_t pCreateWaitableTimerExW;
|
||||
|
||||
@@ -35,7 +40,6 @@ static void SDL_CleanupWaitableHandle(void *handle)
|
||||
CloseHandle(handle);
|
||||
}
|
||||
|
||||
#ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||
static HANDLE SDL_GetWaitableTimer(void)
|
||||
{
|
||||
static SDL_TLSID TLS_timer_handle;
|
||||
@@ -67,7 +71,6 @@ static HANDLE SDL_GetWaitableTimer(void)
|
||||
}
|
||||
return timer;
|
||||
}
|
||||
#endif // CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||
|
||||
static HANDLE SDL_GetWaitableEvent(void)
|
||||
{
|
||||
@@ -102,11 +105,6 @@ Uint64 SDL_GetPerformanceFrequency(void)
|
||||
|
||||
void SDL_SYS_DelayNS(Uint64 ns)
|
||||
{
|
||||
/* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag was added in Windows 10 version 1803.
|
||||
*
|
||||
* Use the compiler version to determine availability.
|
||||
*/
|
||||
#ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
|
||||
HANDLE timer = SDL_GetWaitableTimer();
|
||||
if (timer) {
|
||||
LARGE_INTEGER due_time;
|
||||
@@ -116,7 +114,6 @@ void SDL_SYS_DelayNS(Uint64 ns)
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
const Uint64 max_delay = 0xffffffffLL * SDL_NS_PER_MS;
|
||||
if (ns > max_delay) {
|
||||
|
Reference in New Issue
Block a user