mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 00:59:18 +01:00
Use memory barriers in Linux fiber implementation
Prevent compilers from caching TLS variables across swapcontext calls
This commit is contained in:
parent
524188bb7a
commit
62889adfde
@ -1,5 +1,6 @@
|
||||
#include "Fiber.h"
|
||||
#include <ucontext.h>
|
||||
#include <atomic>
|
||||
|
||||
thread_local Fiber* sCurrentFiber{};
|
||||
|
||||
@ -44,7 +45,9 @@ void Fiber::Switch(Fiber& targetFiber)
|
||||
{
|
||||
Fiber* leavingFiber = sCurrentFiber;
|
||||
sCurrentFiber = &targetFiber;
|
||||
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||
swapcontext((ucontext_t*)(leavingFiber->m_implData), (ucontext_t*)(targetFiber.m_implData));
|
||||
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||
}
|
||||
|
||||
void* Fiber::GetFiberPrivateData()
|
||||
|
Loading…
Reference in New Issue
Block a user