From d2f81d2ca212d8f7d668c67fce256ada69ecbb6b Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 12 Jan 2021 01:27:38 -0800 Subject: [PATCH] ams: save 0x11000 of memory in spl via minor tweaks --- libraries/libstratosphere/source/ams/ams_environment.cpp | 9 +++++++-- .../libstratosphere/source/os/impl/os_thread_manager.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/libstratosphere/source/ams/ams_environment.cpp b/libraries/libstratosphere/source/ams/ams_environment.cpp index 3a0bb3ed9..0c92a6434 100644 --- a/libraries/libstratosphere/source/ams/ams_environment.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment.cpp @@ -197,10 +197,15 @@ extern "C" { } +namespace { + + constinit ams::os::Mutex g_abort_lock(true); + +} + /* Custom abort handler, so that std::abort will trigger these. */ void abort() { - static ams::os::Mutex abort_lock(true); - std::scoped_lock lk(abort_lock); + std::scoped_lock lk(g_abort_lock); ams::AbortImpl(); __builtin_unreachable(); diff --git a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp index d58c4c321..f063812de 100644 --- a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp +++ b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp @@ -220,7 +220,7 @@ namespace ams::os::impl { 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)); - std::snprintf(thread->name_buffer, sizeof(thread->name_buffer), "%s%016lX", ThreadNamePrefix, func); + util::SNPrintf(thread->name_buffer, sizeof(thread->name_buffer), "%s%016lX", ThreadNamePrefix, func); } thread->name_pointer = thread->name_buffer;