Per MS documentation [1] the SetThreadDescription function should be called from the kernel32.dll library and not from the kernelbase.dll library.
[1] - https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription --- mingw-w64-libraries/winpthreads/src/misc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/src/misc.c b/mingw-w64-libraries/winpthreads/src/misc.c index d000dde4862a..e444e69ba916 100644 --- a/mingw-w64-libraries/winpthreads/src/misc.c +++ b/mingw-w64-libraries/winpthreads/src/misc.c @@ -55,6 +55,9 @@ static void winpthreads_init(void) _pthread_get_tick_count_64 = (ULONGLONG (WINAPI *)(VOID))(void*) GetProcAddress(mod, "GetTickCount64"); + _pthread_set_thread_description = + (HRESULT (WINAPI *)(HANDLE, PCWSTR))(void*) GetProcAddress(mod, "SetThreadDescription"); + /* <1us precision on Windows 10 */ _pthread_get_system_time_best_as_file_time = (void (WINAPI *)(LPFILETIME))(void*) GetProcAddress(mod, "GetSystemTimePreciseAsFileTime"); @@ -63,13 +66,6 @@ static void winpthreads_init(void) if (!_pthread_get_system_time_best_as_file_time) /* >15ms precision on Windows 10 */ _pthread_get_system_time_best_as_file_time = GetSystemTimeAsFileTime; - - mod = GetModuleHandleA("kernelbase.dll"); - if (mod) - { - _pthread_set_thread_description = - (HRESULT (WINAPI *)(HANDLE, PCWSTR))(void*) GetProcAddress(mod, "SetThreadDescription"); - } } #if defined(__GNUC__) && __GNUC__ >= 9 && !defined(__clang__) #pragma GCC diagnostic pop -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
