mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 21:11:25 +12:00
Initial support for HLE in internal API
atomic_storage<>: add compare_exchange_hle_acq and fetch_add_hle_rel
shared_mutex: add methods (un)lock_hle and (un)lock_shared_hle
Clang: 👅
This commit is contained in:
parent
58358e85dd
commit
f50d9cc136
2 changed files with 95 additions and 0 deletions
|
@ -46,6 +46,22 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void lock_shared_hle()
|
||||
{
|
||||
const u32 value = m_value.load();
|
||||
|
||||
if (LIKELY(value < c_one - 1))
|
||||
{
|
||||
u32 old = value;
|
||||
if (LIKELY(atomic_storage<u32>::compare_exchange_hle_acq(m_value.raw(), old, value + 1)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
imp_lock_shared(value);
|
||||
}
|
||||
|
||||
void unlock_shared()
|
||||
{
|
||||
// Unconditional decrement (can result in broken state)
|
||||
|
@ -57,6 +73,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void unlock_shared_hle()
|
||||
{
|
||||
const u32 value = atomic_storage<u32>::fetch_add_hle_rel(m_value.raw(), -1);
|
||||
|
||||
if (UNLIKELY(value >= c_one))
|
||||
{
|
||||
imp_unlock_shared(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool try_lock()
|
||||
{
|
||||
return m_value.compare_and_swap_test(0, c_one);
|
||||
|
@ -72,6 +98,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void lock_hle()
|
||||
{
|
||||
u32 value = 0;
|
||||
|
||||
if (UNLIKELY(!atomic_storage<u32>::compare_exchange_hle_acq(m_value.raw(), value, c_one)))
|
||||
{
|
||||
imp_lock(value);
|
||||
}
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
// Unconditional decrement (can result in broken state)
|
||||
|
@ -83,6 +119,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void unlock_hle()
|
||||
{
|
||||
const u32 value = atomic_storage<u32>::fetch_add_hle_rel(m_value.raw(), -c_one);
|
||||
|
||||
if (UNLIKELY(value != c_one))
|
||||
{
|
||||
imp_unlock(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool try_lock_upgrade()
|
||||
{
|
||||
const u32 value = m_value.load();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue