Skip to content

Commit 1c60b7d

Browse files
authored
[Support] [Windows] Conditionally compile the SetThreadInformation calls (#151388)
The declarations for this API are missing in older mingw-w64 headers (versions before v12). This API is also hidden if building with MS WinSDK if targeting versions before Windows 10. Check whether THREAD_POWER_THROTTLING_CURRENT_VERSION is defined before using this API; this constant is a #define in both WinSDK and mingw-w64.
1 parent 17ab8a3 commit 1c60b7d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/lib/Support/Windows/Threading.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ HMODULE loadSystemModuleSecure(LPCWSTR lpModuleName) {
136136
} // namespace llvm::sys::windows
137137

138138
SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
139+
#ifdef THREAD_POWER_THROTTLING_CURRENT_VERSION
139140
HMODULE kernelM = llvm::sys::windows::loadSystemModuleSecure(L"kernel32.dll");
140141
if (kernelM) {
141142
// SetThreadInformation is only available on Windows 8 and later. Since we
@@ -166,6 +167,7 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
166167
: 0);
167168
}
168169
}
170+
#endif
169171

170172
// https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-setthreadpriority
171173
// Begin background processing mode. The system lowers the resource scheduling

0 commit comments

Comments
 (0)