From de0a16ab6507697d0c6539d9a5480faee8430cf4 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 4 Nov 2024 17:34:56 +0300 Subject: [PATCH 1/6] Use constinit in logs.cpp Not sure if it will compile yet. --- rpcs3/util/logs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index 8ef9404e20..42e355f75f 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -397,8 +397,8 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co g_tls_log_control(fmt, 0); // Get text, extract va_args - /*constinit thread_local*/ std::string text; - /*constinit thread_local*/ std::basic_string args; + constinit thread_local std::string text; + constinit thread_local std::vector args; static constexpr fmt_type_info empty_sup{}; From c31cb216d2cfa272d26e0df1057a1b01df382f00 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 5 Nov 2024 21:51:31 +0300 Subject: [PATCH 2/6] Workaround constinit in logs.cpp Use unique_ptr wrapper --- rpcs3/util/logs.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index 42e355f75f..e08a687e8b 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -397,8 +397,14 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co g_tls_log_control(fmt, 0); // Get text, extract va_args - constinit thread_local std::string text; - constinit thread_local std::vector args; + constinit thread_local std::unique_ptr text_; + constinit thread_local std::unique_ptr> args_; + if (!text_) + text_ = std::make_unique(); + if (!args_) + args_ = std::make_unique>(); + auto& text = *text_.get(); + auto& args = *args_.get(); static constexpr fmt_type_info empty_sup{}; From 63d0917e3474586fc79b6a64f26ace2c3191fba0 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 5 Nov 2024 21:59:39 +0300 Subject: [PATCH 3/6] Update logs.cpp Fix std::string reuse --- rpcs3/util/logs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index e08a687e8b..ff5b4490b7 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -412,7 +412,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co for (auto v = sup; v && v->fmt_string; v++) args_count++; - text.reserve(50000); + text.clear(); args.resize(args_count); va_list c_args; From 5f6ac1e08450dcb931d7b10ea5d53e69d2389b11 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 5 Nov 2024 23:20:46 +0300 Subject: [PATCH 4/6] Update logs.cpp --- rpcs3/util/logs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index ff5b4490b7..4b3c505a96 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -397,14 +397,14 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co g_tls_log_control(fmt, 0); // Get text, extract va_args - constinit thread_local std::unique_ptr text_; - constinit thread_local std::unique_ptr> args_; + constinit thread_local std::unique_ptr text(); + constinit thread_local std::unique_ptr> args_(); if (!text_) text_ = std::make_unique(); if (!args_) args_ = std::make_unique>(); - auto& text = *text_.get(); - auto& args = *args_.get(); + auto& text = *text_; + auto& args = *args_; static constexpr fmt_type_info empty_sup{}; From caf5cc78c5de26039c3dab58fdea143cb2263910 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 5 Nov 2024 23:30:19 +0300 Subject: [PATCH 5/6] Update logs.cpp --- rpcs3/util/logs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index 4b3c505a96..191b02ad0c 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -397,8 +397,8 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co g_tls_log_control(fmt, 0); // Get text, extract va_args - constinit thread_local std::unique_ptr text(); - constinit thread_local std::unique_ptr> args_(); + constinit thread_local std::unique_ptr text{}; + constinit thread_local std::unique_ptr> args_{}; if (!text_) text_ = std::make_unique(); if (!args_) From 65abf2c2cb0dc8d286922f02623706a2540984d7 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 5 Nov 2024 23:56:10 +0300 Subject: [PATCH 6/6] Update logs.cpp --- rpcs3/util/logs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index 191b02ad0c..5132129c72 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -397,7 +397,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co g_tls_log_control(fmt, 0); // Get text, extract va_args - constinit thread_local std::unique_ptr text{}; + constinit thread_local std::unique_ptr text_{}; constinit thread_local std::unique_ptr> args_{}; if (!text_) text_ = std::make_unique();