mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-12 21:45:19 -04:00
Assign names to threads
Visible in debuggers etc
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
#include <memory>
|
||||
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dusk/os.h"
|
||||
|
||||
#if _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// Malloc-based allocator to bypass JKRHeap operator new/delete
|
||||
@@ -744,6 +750,30 @@ OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OSSetCurrentThreadName(const char* name) {
|
||||
// "Why is this current thread only?", you might ask?
|
||||
// Because macOS requires that. For some reason.
|
||||
|
||||
#if _WIN32
|
||||
wchar_t buffer[256];
|
||||
const auto converted = MultiByteToWideChar(
|
||||
CP_UTF8,
|
||||
0,
|
||||
name,
|
||||
-1,
|
||||
buffer,
|
||||
sizeof(buffer)/sizeof(wchar_t));
|
||||
if (converted == 0) {
|
||||
CRASH("OSSetThreadName: MultiByteToWideChar failed");
|
||||
}
|
||||
|
||||
const auto result = SetThreadDescription(GetCurrentThread(), buffer);
|
||||
if (!SUCCEEDED(result)) {
|
||||
CRASH("OSSetThreadName: SetThreadDescription failed");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "dusk/os.h"
|
||||
|
||||
#if PLATFORM_GCN
|
||||
const int stack_size = 3072;
|
||||
#else
|
||||
@@ -65,6 +67,11 @@ static void mDoDvdErr_Watch(void*) {
|
||||
OSDisableInterrupts();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if TARGET_PC
|
||||
OSSetCurrentThreadName("DVD error thread");
|
||||
#endif
|
||||
|
||||
JKRThread(OSGetCurrentThread(), 0);
|
||||
|
||||
JKRSetCurrentHeap(mDoExt_getAssertHeap());
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "m_Do/m_Do_MemCardRWmng.h"
|
||||
#include "m_Do/m_Do_Reset.h"
|
||||
#include "os_report.h"
|
||||
#include "dusk/os.h"
|
||||
|
||||
#if PLATFORM_WII || PLATFORM_SHIELD
|
||||
#include <revolution/nand.h>
|
||||
@@ -866,6 +867,10 @@ mDoMemCd_Ctrl_c g_mDoMemCd_control;
|
||||
static int mDoMemCd_main(void*) {
|
||||
JKRThread(OSGetCurrentThread(), 0);
|
||||
|
||||
#if TARGET_PC
|
||||
OSSetCurrentThreadName("MemCardThread");
|
||||
#endif
|
||||
|
||||
JKRSetCurrentHeap(mDoExt_getAssertHeap());
|
||||
|
||||
g_mDoMemCd_control.main();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "JSystem/JKernel/JKRDvdRipper.h"
|
||||
#include "JSystem/JKernel/JKRExpHeap.h"
|
||||
#include "JSystem/JKernel/JKRMemArchive.h"
|
||||
#include "dusk/os.h"
|
||||
#include "m_Do/m_Do_Reset.h"
|
||||
#include "m_Do/m_Do_controller_pad.h"
|
||||
#include "m_Do/m_Do_ext.h"
|
||||
@@ -17,6 +18,9 @@
|
||||
|
||||
s32 mDoDvdThd::main(void* param_0) {
|
||||
JKRThread(OSGetCurrentThread(), 0);
|
||||
#if TARGET_PC
|
||||
OSSetCurrentThreadName("DVD thread");
|
||||
#endif
|
||||
JKRSetCurrentHeap(mDoExt_getAssertHeap());
|
||||
mDoDvdThd_param_c* param = static_cast<mDoDvdThd_param_c*>(param_0);
|
||||
param->mainLoop();
|
||||
|
||||
Reference in New Issue
Block a user