mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 01:38:37 +12:00
vm::atomic initial structure
This commit is contained in:
parent
dbd49a55c6
commit
b6f8700b8b
10 changed files with 156 additions and 30 deletions
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "Emu/Memory/vm_atomic.h"
|
||||
|
||||
bool SM_IsAborted();
|
||||
void SM_Sleep();
|
||||
|
@ -24,9 +25,9 @@ template
|
|||
>
|
||||
class SMutexBase
|
||||
{
|
||||
static_assert(sizeof(T) == sizeof(std::atomic<T>), "Invalid SMutexBase type");
|
||||
static_assert(sizeof(T) == sizeof(vm::atomic_le<T>), "Invalid SMutexBase type");
|
||||
T owner;
|
||||
typedef std::atomic<T> AT;
|
||||
typedef vm::atomic_le<T> AT;
|
||||
|
||||
public:
|
||||
static const T GetFreeValue()
|
||||
|
@ -46,11 +47,6 @@ public:
|
|||
owner = GetFreeValue();
|
||||
}
|
||||
|
||||
//SMutexBase()
|
||||
//{
|
||||
// initialize();
|
||||
//}
|
||||
|
||||
void finalize()
|
||||
{
|
||||
owner = GetDeadValue();
|
||||
|
@ -67,9 +63,9 @@ public:
|
|||
{
|
||||
return SMR_ABORT;
|
||||
}
|
||||
T old = GetFreeValue();
|
||||
T old = reinterpret_cast<AT&>(owner).compare_and_swap(GetFreeValue(), tid);
|
||||
|
||||
if (!reinterpret_cast<AT&>(owner).compare_exchange_strong(old, tid))
|
||||
if (old != GetFreeValue())
|
||||
{
|
||||
if (old == tid)
|
||||
{
|
||||
|
@ -91,9 +87,9 @@ public:
|
|||
{
|
||||
return SMR_ABORT;
|
||||
}
|
||||
T old = tid;
|
||||
T old = reinterpret_cast<AT&>(owner).compare_and_swap(tid, to);
|
||||
|
||||
if (!reinterpret_cast<AT&>(owner).compare_exchange_strong(old, to))
|
||||
if (old != tid)
|
||||
{
|
||||
if (old == GetFreeValue())
|
||||
{
|
||||
|
@ -132,5 +128,4 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef SMutexBase<u32>
|
||||
SMutex;
|
||||
typedef SMutexBase<u32> SMutex;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue