mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-22 04:25:19 +00:00
Remove ignored bits in waitable atomics
It was not implemented correctly.
This commit is contained in:
parent
829047ecdb
commit
e1db6cef6f
1 changed files with 5 additions and 8 deletions
|
@ -2,11 +2,8 @@
|
|||
|
||||
#include "Utilities/sync.h"
|
||||
|
||||
// Should be at least 65536, currently 1048576.
|
||||
static constexpr std::uintptr_t s_hashtable_size = 1u << 20;
|
||||
|
||||
// ^2 means adjacent addresses within the same aligned u32 word will always collide.
|
||||
static constexpr uint s_ignored_lsbits = 2;
|
||||
// Should be at least 65536, currently 2097152.
|
||||
static constexpr std::uintptr_t s_hashtable_size = 1u << 21;
|
||||
|
||||
// TODO: it's probably better to implement more effective futex emulation for OSX/BSD here.
|
||||
static atomic_t<s64> s_hashtable[s_hashtable_size];
|
||||
|
@ -36,7 +33,7 @@ void atomic_storage_futex::wait(const void* data, std::size_t size, u64 old_valu
|
|||
|
||||
const std::intptr_t iptr = reinterpret_cast<std::intptr_t>(data);
|
||||
|
||||
atomic_t<s64>& entry = s_hashtable[(iptr >> s_ignored_lsbits) % s_hashtable_size];
|
||||
atomic_t<s64>& entry = s_hashtable[iptr % s_hashtable_size];
|
||||
|
||||
u32 new_value = 0;
|
||||
|
||||
|
@ -130,7 +127,7 @@ void atomic_storage_futex::notify_one(const void* data)
|
|||
|
||||
const std::intptr_t iptr = reinterpret_cast<std::intptr_t>(data);
|
||||
|
||||
atomic_t<s64>& entry = s_hashtable[(iptr >> s_ignored_lsbits) % s_hashtable_size];
|
||||
atomic_t<s64>& entry = s_hashtable[iptr % s_hashtable_size];
|
||||
|
||||
const auto [prev, ok] = entry.fetch_op([&](s64& value)
|
||||
{
|
||||
|
@ -191,7 +188,7 @@ void atomic_storage_futex::notify_all(const void* data)
|
|||
|
||||
const std::intptr_t iptr = reinterpret_cast<std::intptr_t>(data);
|
||||
|
||||
atomic_t<s64>& entry = s_hashtable[(iptr >> s_ignored_lsbits) % s_hashtable_size];
|
||||
atomic_t<s64>& entry = s_hashtable[iptr % s_hashtable_size];
|
||||
|
||||
// Consume everything
|
||||
#ifdef _WIN32
|
||||
|
|
Loading…
Add table
Reference in a new issue