From 3eac814268bba075c195523d361b368f6bf48b43 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 1 Oct 2021 00:41:35 -0700 Subject: [PATCH] os: improve thread name codegen --- .../libstratosphere/source/os/impl/os_thread_manager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp index a4e593e80..1453c752d 100644 --- a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp +++ b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp @@ -213,14 +213,19 @@ namespace ams::os::impl { /* TODO void ThreadManager::GetThreadContext(ThreadContextInfo *out_context, const ThreadType *thread); */ + namespace { + + constexpr inline const char MainThreadName[] = "MainThread"; + constexpr inline const char ThreadNamePrefix[] = "Thread_0x"; + + } + void ThreadManager::SetInitialThreadNameUnsafe(ThreadType *thread) { if (thread == std::addressof(this->main_thread)) { - constexpr const char MainThreadName[] = "MainThread"; static_assert(sizeof(thread->name_buffer) >= sizeof(MainThreadName)); static_assert(MainThreadName[sizeof(MainThreadName) - 1] == '\x00'); std::memcpy(thread->name_buffer, MainThreadName, sizeof(MainThreadName)); } else { - constexpr const char ThreadNamePrefix[] = "Thread_0x"; constexpr size_t ThreadNamePrefixSize = sizeof(ThreadNamePrefix) - 1; const u64 func = reinterpret_cast(thread->function); static_assert(ThreadNamePrefixSize + sizeof(func) * 2 + 1 <= sizeof(thread->name_buffer));