Skip to content

Commit

Permalink
threads-win32: support UWP in mp_thread_set_name
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 authored and Dudemanguy committed Nov 8, 2023
1 parent add2f3c commit 2ae56e7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions osdep/threads-win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,22 @@ static inline int mp_thread_detach(mp_thread thread)
wchar_t *mp_from_utf8(void *talloc_ctx, const char *s);
static inline void mp_thread_set_name(const char *name)
{
HRESULT (WINAPI *pSetThreadDescription)(HANDLE, PCWSTR);
#if !HAVE_UWP
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
if (!kernel32)
return;
HRESULT (WINAPI *pSetThreadDescription)(HANDLE, PCWSTR) =
(void *) GetProcAddress(kernel32, "SetThreadDescription");
pSetThreadDescription = (void *) GetProcAddress(kernel32, "SetThreadDescription");
if (!pSetThreadDescription)
return;
#else
WINBASEAPI HRESULT WINAPI
SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription);
pSetThreadDescription = &SetThreadDescription;
#endif
wchar_t *wname = mp_from_utf8(NULL, name);
pSetThreadDescription(GetCurrentThread(), wname);
talloc_free(wname);
#endif
}

static inline int64_t mp_thread_cpu_time_ns(mp_thread_id thread)
Expand Down

0 comments on commit 2ae56e7

Please sign in to comment.