185 lines
6.2 KiB
Plaintext
185 lines
6.2 KiB
Plaintext
rpcs3/util/atomic.cpp:55:51: error: no type named 'node_type' in 'std::__1::multimap<const void *, (anonymous namespace)::waiter, std::__1::less<const void *>, std::__1::allocator<std::__1::pair<const void *const, (anonymous namespace)::waiter> > >'; did you mean 'size_type'?
|
|
thread_local std::multimap<const void*, waiter>::node_type s_tls_waiter = []()
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
|
|
size_type
|
|
/usr/include/c++/v1/map:1507:60: note: 'size_type' declared here
|
|
typedef typename __alloc_traits::size_type size_type;
|
|
^
|
|
rpcs3/util/atomic.cpp:59:16: error: no member named 'extract' in 'std::__1::multimap<const void *, (anonymous namespace)::waiter, std::__1::less<const void *>, std::__1::allocator<std::__1::pair<const void *const, (anonymous namespace)::waiter> > >'
|
|
return dummy.extract(dummy.emplace(nullptr, &s_tls_waiter));
|
|
~~~~~ ^
|
|
rpcs3/util/atomic.cpp:55:61: error: cannot initialize a variable of type 'std::multimap<const void *, waiter>::size_type' (aka 'unsigned long') with an rvalue of type 'void'
|
|
thread_local std::multimap<const void*, waiter>::node_type s_tls_waiter = []()
|
|
^ ~~~~
|
|
rpcs3/util/atomic.cpp:92:69: error: no type named 'node_type' in 'std::__1::multimap<const void *, (anonymous namespace)::waiter, std::__1::less<const void *>, std::__1::allocator<std::__1::pair<const void *const, (anonymous namespace)::waiter> > >'; did you mean 'size_type'?
|
|
const auto ptls = static_cast<std::multimap<const void*, waiter>::node_type*>(found->second.tls_ptr);
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
|
|
size_type
|
|
/usr/include/c++/v1/map:1507:60: note: 'size_type' declared here
|
|
typedef typename __alloc_traits::size_type size_type;
|
|
^
|
|
rpcs3/util/atomic.cpp:93:21: error: no member named 'extract' in 'std::__1::multimap<const void *, (anonymous namespace)::waiter, std::__1::less<const void *>, std::__1::allocator<std::__1::pair<const void *const, (anonymous namespace)::waiter> > >'
|
|
*ptls = wmap.list.extract(found);
|
|
~~~~~~~~~ ^
|
|
rpcs3/util/atomic.cpp:94:7: error: member reference base type 'unsigned long' is not a structure or union
|
|
ptls->mapped().cond.notify_one();
|
|
~~~~^ ~~~~~~
|
|
|
|
--- rpcs3/util/atomic.cpp.orig 2019-09-10 16:25:39 UTC
|
|
+++ rpcs3/util/atomic.cpp
|
|
@@ -2,10 +2,6 @@
|
|
|
|
#include "Utilities/sync.h"
|
|
|
|
-#include <map>
|
|
-#include <mutex>
|
|
-#include <condition_variable>
|
|
-
|
|
// Should be at least 65536, currently 2097152.
|
|
static constexpr std::uintptr_t s_hashtable_size = 1u << 21;
|
|
|
|
@@ -40,134 +36,8 @@ static inline bool ptr_cmp(const void* data, std::size
|
|
return false;
|
|
}
|
|
|
|
-// Fallback implementation
|
|
-namespace
|
|
-{
|
|
- struct waiter
|
|
- {
|
|
- std::condition_variable cond;
|
|
- void* const tls_ptr;
|
|
-
|
|
- explicit waiter(void* tls_ptr)
|
|
- : tls_ptr(tls_ptr)
|
|
- {
|
|
- }
|
|
- };
|
|
-
|
|
- struct waiter_map
|
|
- {
|
|
- std::mutex mutex;
|
|
- std::multimap<const void*, waiter> list;
|
|
- };
|
|
-
|
|
- // Thread's unique node to insert without allocation
|
|
- thread_local std::multimap<const void*, waiter>::node_type s_tls_waiter = []()
|
|
- {
|
|
- // Initialize node from a dummy container (there is no separate node constructor)
|
|
- std::multimap<const void*, waiter> dummy;
|
|
- return dummy.extract(dummy.emplace(nullptr, &s_tls_waiter));
|
|
- }();
|
|
-
|
|
- waiter_map& get_fallback_map(const void* ptr)
|
|
- {
|
|
- static waiter_map s_waiter_maps[4096];
|
|
-
|
|
- return s_waiter_maps[std::hash<const void*>()(ptr) % std::size(s_waiter_maps)];
|
|
- }
|
|
-
|
|
- void fallback_wait(const void* data, std::size_t size, u64 old_value, u64 timeout)
|
|
- {
|
|
- auto& wmap = get_fallback_map(data);
|
|
-
|
|
- if (!timeout)
|
|
- {
|
|
- return;
|
|
- }
|
|
-
|
|
- // Update node key
|
|
- s_tls_waiter.key() = data;
|
|
-
|
|
- if (std::unique_lock lock(wmap.mutex); ptr_cmp(data, size, old_value) && s_tls_wait_cb(data))
|
|
- {
|
|
- // Add node to the waiter list
|
|
- const auto iter = wmap.list.insert(std::move(s_tls_waiter));
|
|
-
|
|
- // Wait until the node is returned to its TLS location
|
|
- if (timeout + 1)
|
|
- {
|
|
- if (!iter->second.cond.wait_for(lock, std::chrono::nanoseconds(timeout), [&]
|
|
- {
|
|
- return 1 && s_tls_waiter;
|
|
- }))
|
|
- {
|
|
- // Put it back
|
|
- s_tls_waiter = wmap.list.extract(iter);
|
|
- }
|
|
-
|
|
- return;
|
|
- }
|
|
-
|
|
- while (!s_tls_waiter)
|
|
- {
|
|
- iter->second.cond.wait(lock);
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- void fallback_notify(waiter_map& wmap, std::multimap<const void*, waiter>::iterator found)
|
|
- {
|
|
- // Return notified node to its TLS location
|
|
- const auto ptls = static_cast<std::multimap<const void*, waiter>::node_type*>(found->second.tls_ptr);
|
|
- *ptls = wmap.list.extract(found);
|
|
- ptls->mapped().cond.notify_one();
|
|
- }
|
|
-
|
|
- void fallback_notify_one(const void* data)
|
|
- {
|
|
- auto& wmap = get_fallback_map(data);
|
|
-
|
|
- std::lock_guard lock(wmap.mutex);
|
|
-
|
|
- if (auto found = wmap.list.find(data); found != wmap.list.end())
|
|
- {
|
|
- fallback_notify(wmap, found);
|
|
- }
|
|
- }
|
|
-
|
|
- void fallback_notify_all(const void* data)
|
|
- {
|
|
- auto& wmap = get_fallback_map(data);
|
|
-
|
|
- std::lock_guard lock(wmap.mutex);
|
|
-
|
|
- for (auto it = wmap.list.lower_bound(data); it != wmap.list.end() && it->first == data;)
|
|
- {
|
|
- fallback_notify(wmap, it++);
|
|
- }
|
|
- }
|
|
-}
|
|
-
|
|
-#if !defined(_WIN32) && !defined(__linux__)
|
|
-
|
|
void atomic_storage_futex::wait(const void* data, std::size_t size, u64 old_value, u64 timeout)
|
|
{
|
|
- fallback_wait(data, size, old_value, timeout);
|
|
-}
|
|
-
|
|
-void atomic_storage_futex::notify_one(const void* data)
|
|
-{
|
|
- fallback_notify_one(data);
|
|
-}
|
|
-
|
|
-void atomic_storage_futex::notify_all(const void* data)
|
|
-{
|
|
- fallback_notify_all(data);
|
|
-}
|
|
-
|
|
-#else
|
|
-
|
|
-void atomic_storage_futex::wait(const void* data, std::size_t size, u64 old_value, u64 timeout)
|
|
-{
|
|
if (!timeout)
|
|
{
|
|
return;
|
|
@@ -402,8 +272,6 @@ void atomic_storage_futex::notify_all(const void* data
|
|
}
|
|
#endif
|
|
}
|
|
-
|
|
-#endif
|
|
|
|
void atomic_storage_futex::set_wait_callback(bool(*cb)(const void* data))
|
|
{
|