32 static unsigned __stdcall ThreadCallback(
void *param) {
33 struct ThreadInfo *
info =
reinterpret_cast<struct ThreadInfo *
>(param);
34 info->func(info->param);
40 unsigned RequestedStackSize) {
41 struct ThreadInfo param = { Fn, UserData };
43 HANDLE hThread = (HANDLE)::_beginthreadex(NULL,
44 RequestedStackSize, ThreadCallback,
53 (void)::WaitForSingleObject(hThread, INFINITE);
54 ::CloseHandle(hThread);
59 return uint64_t(::GetCurrentThreadId());
66 constexpr
DWORD MS_VC_EXCEPTION = 0x406D1388;
69 struct THREADNAME_INFO {
84 ::RaiseException(MS_VC_EXCEPTION, 0,
sizeof(info) /
sizeof(ULONG_PTR),
87 __except (EXCEPTION_EXECUTE_HANDLER) {
95 SmallString<64> Storage;
96 StringRef NameStr = Name.toNullTerminatedStringRef(Storage);
97 SetThreadName(::GetCurrentThreadId(), NameStr.data());
void set_thread_name(const Twine &Name)
Set the name of the current thread.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
uint32_t get_max_thread_name_length()
Get the maximum length of a thread name on this platform.
void get_thread_name(SmallVectorImpl< char > &Name)
Get the name of the current thread.
uint64_t get_threadid()
Return the current thread id, as used in various OS system calls.
void llvm_execute_on_thread(void(*UserFn)(void *), void *UserData, unsigned RequestedStackSize=0)
llvm_execute_on_thread - Execute the given UserFn on a separate thread, passing it the provided UserD...