From 2decf1ecda937c4741e35976abbde066029f65c3 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 17 Mar 2021 23:49:43 +0300 Subject: [PATCH] Rename and move g_tls_current_cpu_thread inside cpu_thread Don't declare extern inside get_current_cpu_thread(). Possible workaround for gcc-11. --- rpcs3/Emu/CPU/CPUThread.cpp | 8 ++++---- rpcs3/Emu/CPU/CPUThread.h | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 63dc0063c4..0e35523535 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -252,7 +252,7 @@ struct cpu_prof using cpu_profiler = named_thread; -thread_local cpu_thread* g_tls_current_cpu_thread = nullptr; +thread_local DECLARE(cpu_thread::g_tls_this_thread) = nullptr; // Total number of CPU threads static atomic_t s_cpu_counter{0}; @@ -403,7 +403,7 @@ namespace cpu_counter void cpu_thread::operator()() { - g_tls_current_cpu_thread = this; + g_tls_this_thread = this; if (g_cfg.core.thread_scheduler_enabled) { @@ -535,7 +535,7 @@ void cpu_thread::operator()() s_cpu_counter--; - g_tls_current_cpu_thread = nullptr; + g_tls_this_thread = nullptr; g_threads_deleted++; @@ -1119,7 +1119,7 @@ bool cpu_thread::suspend_work::push(cpu_thread* _this) noexcept void cpu_thread::stop_all() noexcept { - if (g_tls_current_cpu_thread) + if (g_tls_this_thread) { // Report unsupported but unnecessary case sys_log.fatal("cpu_thread::stop_all() has been called from a CPU thread."); diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 7924a2ac90..18e5e92ad6 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -243,13 +243,16 @@ public: // Send signal to the profiler(s) to flush results static void flush_profilers() noexcept; + +private: + static thread_local cpu_thread* g_tls_this_thread; + + friend cpu_thread* get_current_cpu_thread() noexcept; }; inline cpu_thread* get_current_cpu_thread() noexcept { - extern thread_local cpu_thread* g_tls_current_cpu_thread; - - return g_tls_current_cpu_thread; + return cpu_thread::g_tls_this_thread; } class ppu_thread;