diff options
| author | 2022-06-16 10:35:52 -0400 | |
|---|---|---|
| committer | 2022-06-23 00:28:00 -0400 | |
| commit | 2c56e94702e897c609711d82057d8267d8f4d0b3 (patch) | |
| tree | b037c6951383408517b460577b709f4383a61da0 /src/core/hle/kernel/kernel.cpp | |
| parent | Merge pull request #8491 from Morph1984/extra-assert (diff) | |
| download | yuzu-2c56e94702e897c609711d82057d8267d8f4d0b3.tar.gz yuzu-2c56e94702e897c609711d82057d8267d8f4d0b3.tar.xz yuzu-2c56e94702e897c609711d82057d8267d8f4d0b3.zip | |
kernel: make current thread pointer thread local
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 94953e257..0009193be 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -331,6 +331,8 @@ struct KernelCore::Impl { | |||
| 331 | return is_shutting_down.load(std::memory_order_relaxed); | 331 | return is_shutting_down.load(std::memory_order_relaxed); |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | static inline thread_local KThread* current_thread{nullptr}; | ||
| 335 | |||
| 334 | KThread* GetCurrentEmuThread() { | 336 | KThread* GetCurrentEmuThread() { |
| 335 | // If we are shutting down the kernel, none of this is relevant anymore. | 337 | // If we are shutting down the kernel, none of this is relevant anymore. |
| 336 | if (IsShuttingDown()) { | 338 | if (IsShuttingDown()) { |
| @@ -341,7 +343,12 @@ struct KernelCore::Impl { | |||
| 341 | if (thread_id >= Core::Hardware::NUM_CPU_CORES) { | 343 | if (thread_id >= Core::Hardware::NUM_CPU_CORES) { |
| 342 | return GetHostDummyThread(); | 344 | return GetHostDummyThread(); |
| 343 | } | 345 | } |
| 344 | return schedulers[thread_id]->GetCurrentThread(); | 346 | |
| 347 | return current_thread; | ||
| 348 | } | ||
| 349 | |||
| 350 | void SetCurrentEmuThread(KThread* thread) { | ||
| 351 | current_thread = thread; | ||
| 345 | } | 352 | } |
| 346 | 353 | ||
| 347 | void DeriveInitialMemoryLayout() { | 354 | void DeriveInitialMemoryLayout() { |
| @@ -1024,6 +1031,10 @@ KThread* KernelCore::GetCurrentEmuThread() const { | |||
| 1024 | return impl->GetCurrentEmuThread(); | 1031 | return impl->GetCurrentEmuThread(); |
| 1025 | } | 1032 | } |
| 1026 | 1033 | ||
| 1034 | void KernelCore::SetCurrentEmuThread(KThread* thread) { | ||
| 1035 | impl->SetCurrentEmuThread(thread); | ||
| 1036 | } | ||
| 1037 | |||
| 1027 | KMemoryManager& KernelCore::MemoryManager() { | 1038 | KMemoryManager& KernelCore::MemoryManager() { |
| 1028 | return *impl->memory_manager; | 1039 | return *impl->memory_manager; |
| 1029 | } | 1040 | } |