From ece7e1ae93bf2dd256555b08b727138d8e2b36ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 8 Sep 2015 20:51:00 -0700 Subject: [PATCH] Added thread name for Windows. --- include/bx/thread.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/include/bx/thread.h b/include/bx/thread.h index 31c9964..f10a91c 100644 --- a/include/bx/thread.h +++ b/include/bx/thread.h @@ -141,10 +141,35 @@ namespace bx void setThreadName(const char* _name) { -#if BX_PLATFORM_OSX|BX_PLATFORM_IOS +#if BX_PLATFORM_OSX || BX_PLATFORM_IOS pthread_setname_np(_name); #elif BX_PLATFORM_POSIX pthread_setname_np(m_handle, _name); +#elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC + struct ThreadName + { + DWORD type; + LPCSTR name; + DWORD id; + DWORD flags; + }; + ThreadName tn; + tn.type = 0x1000; + tn.name = _name; + tn.id = GetThreadId(m_handle); + tn.flags = 0; + + __try + { + RaiseException(0x406d1388 + , 0 + , sizeof(tn)/4 + , reinterpret_cast(&tn) + ); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + } #else BX_UNUSED(_name); #endif // BX_PLATFORM_