diff --git a/src/common/thread.cpp b/src/common/thread.cpp index f5abe46324..cc78587c36 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -83,8 +83,6 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) { void SetCurrentThreadName(const char* name) { if (auto pf = (decltype(&SetThreadDescription))(void*)GetProcAddress(GetModuleHandle(TEXT("KernelBase.dll")), "SetThreadDescription"); pf) pf(GetCurrentThread(), UTF8ToUTF16W(name).data()); // Windows 10+ - else - ; // No-op } #else // !MSVC_VER, so must be POSIX threads diff --git a/src/common/windows/timer_resolution.cpp b/src/common/windows/timer_resolution.cpp index 29c6e5c7e1..bf29823455 100644 --- a/src/common/windows/timer_resolution.cpp +++ b/src/common/windows/timer_resolution.cpp @@ -63,13 +63,12 @@ TimerResolution GetTimerResolution() { void SetHighQoS() { // https://learn.microsoft.com/en-us/windows/win32/procthread/quality-of-service PROCESS_POWER_THROTTLING_STATE PowerThrottling{ - .Version{PROCESS_POWER_THROTTLING_CURRENT_VERSION}, - .ControlMask{PROCESS_POWER_THROTTLING_EXECUTION_SPEED | - PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION}, - .StateMask{}, + .Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION, + .ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION, + .StateMask = 0, }; - SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling, - sizeof(PROCESS_POWER_THROTTLING_STATE)); + if (auto pf = (decltype(&SetProcessInformation))(void*)GetProcAddress(GetModuleHandle(TEXT("Kernel32.dll")), "SetProcessInformation"); pf) + pf(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling, sizeof(PROCESS_POWER_THROTTLING_STATE)); // Windows 7+ } } // Anonymous namespace