time: Fix UWP build

main
Frank Praznik 2024-04-01 10:52:24 -04:00
parent 650ba8f3ec
commit a00ac61514
1 changed files with 10 additions and 3 deletions

View File

@ -79,14 +79,20 @@ found_date:
int SDL_GetCurrentTime(SDL_Time *ticks)
{
static pfnGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime = NULL;
static SDL_bool load_attempted = SDL_FALSE;
FILETIME ft;
if (!ticks) {
return SDL_InvalidParamError("ticks");
}
SDL_zero(ft);
#ifdef SDL_PLATFORM_WINRT
GetSystemTimePreciseAsFileTime(&ft);
#else
static pfnGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime = NULL;
static SDL_bool load_attempted = SDL_FALSE;
/* Only available in Win8/Server 2012 or higher. */
if (!pGetSystemTimePreciseAsFileTime && !load_attempted) {
HANDLE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
@ -96,12 +102,13 @@ int SDL_GetCurrentTime(SDL_Time *ticks)
load_attempted = SDL_TRUE;
}
SDL_zero(ft);
if (pGetSystemTimePreciseAsFileTime) {
pGetSystemTimePreciseAsFileTime(&ft);
} else {
GetSystemTimeAsFileTime(&ft);
}
#endif
*ticks = SDL_TimeFromWindows(ft.dwLowDateTime, ft.dwHighDateTime);
return 0;