mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
36 lines
753 B
C++
36 lines
753 B
C++
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#endif
|
|
#include "base/threadutil.h"
|
|
|
|
void setCurrentThreadName(const char* szThreadName)
|
|
{
|
|
#ifdef _WIN32
|
|
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
|
|
|
#pragma pack(push,8)
|
|
struct THREADNAME_INFO
|
|
{
|
|
DWORD dwType; // must be 0x1000
|
|
LPCSTR szName; // pointer to name (in user addr space)
|
|
DWORD dwThreadID; // thread ID (-1=caller thread)
|
|
DWORD dwFlags; // reserved for future use, must be zero
|
|
} info;
|
|
#pragma pack(pop)
|
|
|
|
info.dwType = 0x1000;
|
|
info.szName = szThreadName;
|
|
info.dwThreadID = -1; //dwThreadID;
|
|
info.dwFlags = 0;
|
|
|
|
__try
|
|
{
|
|
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
|
}
|
|
__except(EXCEPTION_CONTINUE_EXECUTION)
|
|
{}
|
|
#else
|
|
// Do nothing
|
|
#endif
|
|
}
|