From ca676357c06628dcbada869190c0bc0756160608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 21:24:15 +0200 Subject: [PATCH] Win32: Remove timeGetTime fallback for timer The performance counter API is guaranteed to succeed on Windows XP and later so there is no need for a fallback. This removes our last dependency on winmm. (cherry picked from commit b6834bf2a144917e8e82de863d87d6cf5553e6af) --- src/win32_init.c | 14 -------------- src/win32_platform.h | 10 ---------- src/win32_time.c | 24 ++++-------------------- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 86b2558c..40eb795f 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -72,17 +72,6 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) // static GLFWbool loadLibraries(void) { - _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll"); - if (!_glfw.win32.winmm.instance) - { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - "Win32: Failed to load winmm.dll"); - return GLFW_FALSE; - } - - _glfw.win32.winmm.GetTime = (PFN_timeGetTime) - GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime"); - _glfw.win32.user32.instance = LoadLibraryA("user32.dll"); if (!_glfw.win32.user32.instance) { @@ -180,9 +169,6 @@ static void freeLibraries(void) if (_glfw.win32.dinput8.instance) FreeLibrary(_glfw.win32.dinput8.instance); - if (_glfw.win32.winmm.instance) - FreeLibrary(_glfw.win32.winmm.instance); - if (_glfw.win32.user32.instance) FreeLibrary(_glfw.win32.user32.instance); diff --git a/src/win32_platform.h b/src/win32_platform.h index 4419c3be..b964e135 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -218,10 +218,6 @@ typedef enum #define DIDFT_OPTIONAL 0x80000000 #endif -// winmm.dll function pointer typedefs -typedef DWORD (WINAPI * PFN_timeGetTime)(void); -#define timeGetTime _glfw.win32.winmm.GetTime - // xinput.dll function pointer typedefs typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*); typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*); @@ -350,11 +346,6 @@ typedef struct _GLFWlibraryWin32 int rawInputSize; UINT mouseTrailSize; - struct { - HINSTANCE instance; - PFN_timeGetTime GetTime; - } winmm; - struct { HINSTANCE instance; PFN_DirectInput8Create Create; @@ -422,7 +413,6 @@ typedef struct _GLFWcursorWin32 // typedef struct _GLFWtimerWin32 { - GLFWbool hasPC; uint64_t frequency; } _GLFWtimerWin32; diff --git a/src/win32_time.c b/src/win32_time.c index 75594637..b4e31ab2 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -38,18 +38,7 @@ // void _glfwInitTimerWin32(void) { - uint64_t frequency; - - if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) - { - _glfw.timer.win32.hasPC = GLFW_TRUE; - _glfw.timer.win32.frequency = frequency; - } - else - { - _glfw.timer.win32.hasPC = GLFW_FALSE; - _glfw.timer.win32.frequency = 1000; - } + QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency); } @@ -59,14 +48,9 @@ void _glfwInitTimerWin32(void) uint64_t _glfwPlatformGetTimerValue(void) { - if (_glfw.timer.win32.hasPC) - { - uint64_t value; - QueryPerformanceCounter((LARGE_INTEGER*) &value); - return value; - } - else - return (uint64_t) timeGetTime(); + uint64_t value; + QueryPerformanceCounter((LARGE_INTEGER*) &value); + return value; } uint64_t _glfwPlatformGetTimerFrequency(void)