mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add code to set the thread name
This commit is contained in:
parent
2e561248b8
commit
a4b7a0cb13
2 changed files with 38 additions and 0 deletions
35
base/threadutil.cpp
Normal file
35
base/threadutil.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#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
|
||||
}
|
3
base/threadutil.h
Normal file
3
base/threadutil.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
void setCurrentThreadName(const char *name);
|
Loading…
Add table
Reference in a new issue