aboutsummaryrefslogtreecommitdiff
path: root/emulators
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2019-10-29 00:54:26 +0000
committerJan Beich <jbeich@FreeBSD.org>2019-10-29 00:54:26 +0000
commit0eb7e917a4f678e5e3a1a918a6b1e1d0f90c92b4 (patch)
tree1820824e5d2095cf7adaa5af66b4c490e4fe1493 /emulators
parentd7f747f2ff8c57e25fed52c0bfb223b25b1ddabd (diff)
downloadports-0eb7e917a4f678e5e3a1a918a6b1e1d0f90c92b4.tar.gz
ports-0eb7e917a4f678e5e3a1a918a6b1e1d0f90c92b4.zip
Notes
Diffstat (limited to 'emulators')
-rw-r--r--emulators/rpcs3/Makefile15
-rw-r--r--emulators/rpcs3/distinfo2
-rw-r--r--emulators/rpcs3/files/extra-patch-no-cotire41
-rw-r--r--emulators/rpcs3/files/extra-patch-revert-4504ac2d1248223
-rw-r--r--emulators/rpcs3/files/extra-patch-revert-5bd17a44c972184
-rw-r--r--emulators/rpcs3/files/extra-patch-revert-6b1e1e402049188
-rw-r--r--emulators/rpcs3/files/extra-patch-revert-9710473a2e3e783
-rw-r--r--emulators/rpcs3/files/extra-patch-revert-db7042b986ab73
-rw-r--r--emulators/rpcs3/files/extra-patch-revert-f9ad6358563b169
9 files changed, 50 insertions, 1628 deletions
diff --git a/emulators/rpcs3/Makefile b/emulators/rpcs3/Makefile
index 0a78a4d686d7..f7f1c32584f7 100644
--- a/emulators/rpcs3/Makefile
+++ b/emulators/rpcs3/Makefile
@@ -4,6 +4,7 @@ PORTNAME= rpcs3
DISTVERSIONPREFIX= v
DISTVERSION= 0.0.7-8941 # git rev-list --count HEAD
DISTVERSIONSUFFIX= -g0ef7ad129
+PORTREVISION= 1
CATEGORIES= emulators
MAINTAINER= jbeich@FreeBSD.org
@@ -48,14 +49,12 @@ LLD_UNSAFE= yes # XXX ports/219089
.endif
# XXX Remove after FreeBSD 11.2/12.0 reach EOL i.e., around 2020-02-01
-# XXX Switch to bundled libc++ to avoid error-prone reverts
-.if !exists(/usr/include/c++/v1/charconv) && exists(/usr/lib/libc++.so)
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-revert-db7042b986ab
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-revert-6b1e1e402049
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-revert-9710473a2e3e
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-revert-f9ad6358563b
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-revert-4504ac2d1248
-EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-revert-5bd17a44c972
+.if make(makesum) || (!exists(/usr/include/c++/v1/charconv) && exists(/usr/lib/libc++.so))
+MASTER_SITES+= https://releases.llvm.org/${LLVM_VER}/:libcxx
+DISTFILES+= libcxx-${LLVM_VER}.src.tar.xz:libcxx
+EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-no-cotire
+CXXFLAGS+= -nostdinc++ -isystem${WRKDIR}/libcxx-${LLVM_VER}.src/include
+LLVM_VER= 8.0.0 # same as FreeBSD 11.3
.endif
OPTIONS_DEFINE= ALSA EVDEV LLVM PULSEAUDIO VULKAN
diff --git a/emulators/rpcs3/distinfo b/emulators/rpcs3/distinfo
index 9950bacb7f5d..888f3985816a 100644
--- a/emulators/rpcs3/distinfo
+++ b/emulators/rpcs3/distinfo
@@ -1,4 +1,6 @@
TIMESTAMP = 1571505618
+SHA256 (libcxx-8.0.0.src.tar.xz) = c2902675e7c84324fb2c1e45489220f250ede016cc3117186785d9dc291f9de2
+SIZE (libcxx-8.0.0.src.tar.xz) = 1752308
SHA256 (RPCS3-rpcs3-v0.0.7-8941-g0ef7ad129_GH0.tar.gz) = daf9c83bc14d274c267cc110bdfe22d1e839eec6bfa0c9ba24d2d4eae279c857
SIZE (RPCS3-rpcs3-v0.0.7-8941-g0ef7ad129_GH0.tar.gz) = 5625433
SHA256 (RPCS3-hidapi-hidapi-0.8.0-rc1-27-g9220f5e_GH0.tar.gz) = 3120e0b701943f452760e45f9fc1ac50bab356ad4c807b4cac4598041c5ca1a5
diff --git a/emulators/rpcs3/files/extra-patch-no-cotire b/emulators/rpcs3/files/extra-patch-no-cotire
new file mode 100644
index 000000000000..dd56ae077c54
--- /dev/null
+++ b/emulators/rpcs3/files/extra-patch-no-cotire
@@ -0,0 +1,41 @@
+- Cotire precompiles system libc++ headers but bundled are needed
+
+--- rpcs3/CMakeLists.txt.orig 2019-10-27 16:17:27 UTC
++++ rpcs3/CMakeLists.txt
+@@ -1,7 +1,5 @@
+ cmake_minimum_required(VERSION 3.8.2)
+
+-include(cotire)
+-
+ # Generate git-version.h at build time.
+ include(${CMAKE_CURRENT_SOURCE_DIR}/git-version.cmake)
+
+@@ -97,12 +95,6 @@ if(WIN32)
+ else()
+ target_link_libraries(rpcs3 ${CMAKE_DL_LIBS})
+ endif()
+-
+-set_target_properties(rpcs3 PROPERTIES
+- COTIRE_CXX_PREFIX_HEADER_INIT "${RPCS3_SRC_DIR}/stdafx.h"
+- COTIRE_ADD_UNITY_BUILD OFF)
+-
+-cotire(rpcs3)
+
+ # Copy icons to executable directory
+ if(APPLE)
+--- rpcs3/Emu/CMakeLists.txt.orig 2019-10-27 16:17:27 UTC
++++ rpcs3/Emu/CMakeLists.txt
+@@ -397,13 +397,3 @@ target_link_libraries(rpcs3_emu
+ PRIVATE
+ 3rdparty::gsl 3rdparty::xxhash
+ )
+-
+-
+-# Setup cotire
+-option(UNITY_BUILD_EMU "Use unity build for rpcs3_emu target" OFF)
+-
+-set_target_properties(rpcs3_emu PROPERTIES
+- COTIRE_CXX_PREFIX_HEADER_INIT "${RPCS3_SRC_DIR}/stdafx.h"
+- COTIRE_ADD_UNITY_BUILD ${UNITY_BUILD_EMU})
+-
+-cotire(rpcs3_emu)
diff --git a/emulators/rpcs3/files/extra-patch-revert-4504ac2d1248 b/emulators/rpcs3/files/extra-patch-revert-4504ac2d1248
deleted file mode 100644
index b2b9d8ce563a..000000000000
--- a/emulators/rpcs3/files/extra-patch-revert-4504ac2d1248
+++ /dev/null
@@ -1,223 +0,0 @@
-rpcs3/util/atomic.cpp:95:3: error: use of undeclared identifier 'fallback_wait'
- fallback_wait(data, size, old_value, timeout);
- ^
-rpcs3/util/atomic.cpp:219:4: error: use of undeclared identifier 'fallback_notify_one'
- fallback_notify_one(data);
- ^
-rpcs3/util/atomic.cpp:307:5: error: use of undeclared identifier 'fallback_notify_all'
- fallback_notify_all(data);
- ^
-
---- rpcs3/util/atomic.cpp.orig 2019-09-13 21:02:48 UTC
-+++ rpcs3/util/atomic.cpp
-@@ -15,14 +15,11 @@ static atomic_t<u64> s_hashtable[s_hashtable_size];
- // Pointer mask without bits used as hash, assuming signed 48-bit pointers
- static constexpr u64 s_pointer_mask = 0xffff'ffff'ffff & (~(s_hashtable_size - 1) << 2);
-
--// Max number of waiters is 32767
--static constexpr u64 s_waiter_mask = 0x7fff'0000'0000'0000;
-+// Max number of waiters is 65535
-+static constexpr u64 s_waiter_mask = 0xffff'0000'0000'0000;
-
--//
--static constexpr u64 s_collision_bit = 0x8000'0000'0000'0000;
--
- // Implementation detail (remaining bits out of 32 available for futex)
--static constexpr u64 s_signal_mask = 0xffffffff & ~(s_waiter_mask | s_pointer_mask | s_collision_bit);
-+static constexpr u64 s_signal_mask = 0xffffffff & ~(s_waiter_mask | s_pointer_mask);
-
- // Callback for wait() function, returns false if wait should return
- static thread_local bool(*s_tls_wait_cb)(const void* data) = [](const void*)
-@@ -182,8 +179,6 @@ void atomic_storage_futex::wait(const void* data, std:
-
- u32 new_value = 0;
-
-- bool fallback = false;
--
- const auto [_, ok] = entry.fetch_op([&](u64& value)
- {
- if ((value & s_waiter_mask) == s_waiter_mask || (value & s_signal_mask) == s_signal_mask)
-@@ -196,17 +191,11 @@ void atomic_storage_futex::wait(const void* data, std:
- {
- // Store pointer bits
- value |= (iptr & s_pointer_mask);
-- fallback = false;
--
--#ifdef _WIN32
-- value += s_signal_mask & -s_signal_mask;
--#endif
- }
- else
- {
-- // Set collision bit
-- value |= s_collision_bit;
-- fallback = true;
-+ // Set pointer bits to all ones (collision, TODO)
-+ value |= s_pointer_mask;
- }
-
- // Add waiter
-@@ -220,12 +209,8 @@ void atomic_storage_futex::wait(const void* data, std:
- return;
- }
-
-- if (fallback)
-+ if (ptr_cmp(data, size, old_value, mask) && s_tls_wait_cb(data))
- {
-- fallback_wait(data, size, old_value, timeout, mask);
-- }
-- else if (ptr_cmp(data, size, old_value, mask) && s_tls_wait_cb(data))
-- {
- #ifdef _WIN32
- LARGE_INTEGER qw;
- qw.QuadPart = -static_cast<s64>(timeout / 100);
-@@ -259,18 +244,6 @@ void atomic_storage_futex::wait(const void* data, std:
- {
- if (value & s_waiter_mask)
- {
--#ifdef _WIN32
-- if (!fallback)
-- {
-- if ((value & s_signal_mask) == 0)
-- {
-- return false;
-- }
--
-- value -= s_signal_mask & -s_signal_mask;
-- }
--#endif
--
- value -= s_waiter_mask & -s_waiter_mask;
-
- if ((value & s_waiter_mask) == 0)
-@@ -279,7 +257,7 @@ void atomic_storage_futex::wait(const void* data, std:
- return false;
- });
-
-- if (ok || fallback)
-+ if (ok)
- {
- break;
- }
-@@ -306,20 +284,15 @@ void atomic_storage_futex::notify_one(const void* data
-
- atomic_t<u64>& entry = s_hashtable[(iptr >> 2) % s_hashtable_size];
-
-+ bool fallback = false;
-+
- const auto [prev, ok] = entry.fetch_op([&](u64& value)
- {
- if (value & s_waiter_mask && (value & s_pointer_mask) == (iptr & s_pointer_mask))
- {
- #ifdef _WIN32
-- if ((value & s_signal_mask) == 0)
-- {
-- // No relevant waiters, do nothing
-- return false;
-- }
--
-- // Try to decrement if possible
-+ // Try to decrement if no collision
- value -= s_waiter_mask & -s_waiter_mask;
-- value -= s_signal_mask & -s_signal_mask;
-
- if ((value & s_waiter_mask) == 0)
- {
-@@ -337,22 +310,30 @@ void atomic_storage_futex::notify_one(const void* data
-
- if ((value & s_signal_mask) == s_signal_mask)
- {
-- // Signal will overflow, fallback to notify_all
-- notify_all(data);
-+ // Signal will overflow, fallback
-+ fallback = true;
- return false;
- }
- #endif
-+
- return true;
- }
-- else if (value & s_waiter_mask && value & s_collision_bit)
-+
-+ if (value & s_waiter_mask && (value & s_pointer_mask) == s_pointer_mask)
- {
-- fallback_notify_one(data);
-- return false;
-+ // Collision, notify everything
-+ fallback = true;
- }
-
- return false;
- });
-
-+ if (fallback)
-+ {
-+ notify_all(data);
-+ return;
-+ }
-+
- if (ok)
- {
- #ifdef _WIN32
-@@ -375,32 +356,11 @@ void atomic_storage_futex::notify_all(const void* data
- {
- if (value & s_waiter_mask)
- {
-- if ((value & s_pointer_mask) == (iptr & s_pointer_mask))
-+ if ((value & s_pointer_mask) == s_pointer_mask || (value & s_pointer_mask) == (iptr & s_pointer_mask))
- {
-- if ((value & s_signal_mask) == 0)
-- {
-- // No relevant waiters, do nothing
-- return false;
-- }
--
-- const u64 count = (value & s_signal_mask) / (s_signal_mask & -s_signal_mask);
-- value -= (s_waiter_mask & -s_waiter_mask) * count;
-- value -= (s_signal_mask & -s_signal_mask) * count;
--
-- if ((value & s_waiter_mask) == 0)
-- {
-- // Reset on last waiter
-- value = 0;
-- }
--
-+ value = 0;
- return true;
- }
--
-- if (value & s_collision_bit)
-- {
-- fallback_notify_all(data);
-- return false;
-- }
- }
-
- return false;
-@@ -411,7 +371,7 @@ void atomic_storage_futex::notify_all(const void* data
- return;
- }
-
-- for (u64 count = old & s_signal_mask; count; count -= s_signal_mask & -s_signal_mask)
-+ for (u64 count = old & s_waiter_mask; count; count -= s_waiter_mask & -s_waiter_mask)
- {
- NtReleaseKeyedEvent(nullptr, &entry, false, nullptr);
- }
-@@ -426,16 +386,10 @@ void atomic_storage_futex::notify_all(const void* data
- return false;
- }
-
-- if ((value & s_pointer_mask) == (iptr & s_pointer_mask))
-+ if ((value & s_pointer_mask) == s_pointer_mask || (value & s_pointer_mask) == (iptr & s_pointer_mask))
- {
- value += s_signal_mask & -s_signal_mask;
- return true;
-- }
--
-- if (value & s_collision_bit)
-- {
-- fallback_notify_all(data);
-- return false;
- }
- }
-
diff --git a/emulators/rpcs3/files/extra-patch-revert-5bd17a44c972 b/emulators/rpcs3/files/extra-patch-revert-5bd17a44c972
deleted file mode 100644
index eabed837f3bc..000000000000
--- a/emulators/rpcs3/files/extra-patch-revert-5bd17a44c972
+++ /dev/null
@@ -1,184 +0,0 @@
-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-13 21:02:48 UTC
-+++ rpcs3/util/atomic.cpp
-@@ -2,10 +2,6 @@
-
- #include "Utilities/sync.h"
-
--#include <map>
--#include <mutex>
--#include <condition_variable>
--
- // Total number of entries, should be a power of 2.
- static constexpr std::uintptr_t s_hashtable_size = 1u << 22;
-
-@@ -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, u64 mask)
-- {
-- 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, mask) && 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, u64 mask)
- {
-- fallback_wait(data, size, old_value, timeout, mask);
--}
--
--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, u64 mask)
--{
- 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))
- {
diff --git a/emulators/rpcs3/files/extra-patch-revert-6b1e1e402049 b/emulators/rpcs3/files/extra-patch-revert-6b1e1e402049
deleted file mode 100644
index 407e44edd69f..000000000000
--- a/emulators/rpcs3/files/extra-patch-revert-6b1e1e402049
+++ /dev/null
@@ -1,188 +0,0 @@
-rpcs3/Emu/GDB.cpp:33:10: fatal error: 'charconv' file not found
-#include <charconv>
- ^~~~~~~~~~
-
---- rpcs3/Emu/GDB.cpp.orig 2019-10-09 18:21:23 UTC
-+++ rpcs3/Emu/GDB.cpp
-@@ -2,7 +2,7 @@
-
- #include "GDB.h"
- #include "Utilities/Log.h"
--#include "Utilities/StrUtil.h"
-+#include <algorithm>
- #include "Emu/Memory/vm.h"
- #include "Emu/System.h"
- #include "Emu/IdManager.h"
-@@ -14,24 +14,17 @@
- #ifdef _WIN32
- #include <WinSock2.h>
- #include <WS2tcpip.h>
--#include <afunix.h> // sockaddr_un
- #else
- #include <errno.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
--#include <netdb.h>
- #include <arpa/inet.h>
- #include <unistd.h>
- #include <fcntl.h>
--#include <sys/un.h> // sockaddr_un
- #endif
-
--#include <algorithm>
--#include <regex>
--#include <charconv>
--
- extern void ppu_set_breakpoint(u32 addr);
- extern void ppu_remove_breakpoint(u32 addr);
-
-@@ -43,22 +36,10 @@ int closesocket(int s)
- return close(s);
- }
-
--void set_nonblocking(int s)
--{
-- fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK);
--}
--
- #define sscanf_s sscanf
- #define HEX_U32 "x"
- #define HEX_U64 "lx"
- #else
--
--void set_nonblocking(int s)
--{
-- u_long mode = 1;
-- ioctlsocket(s, FIONBIO, &mode);
--}
--
- #define HEX_U32 "lx"
- #define HEX_U64 "llx"
- #endif
-@@ -122,93 +103,46 @@ u64 hex_to_u64(std::string val) {
-
- void gdb_thread::start_server()
- {
-- // IPv4 address:port in format 127.0.0.1:2345
-- static const std::regex ipv4_regex("^([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})\\:([0-9]{1,5})$");
-+ server_socket = socket(AF_INET, SOCK_STREAM, 0);
-
-- if (g_cfg.misc.gdb_server.get()[0] == '\0')
-+ if (server_socket == -1)
- {
-- // Empty string or starts with null: GDB server disabled
-- GDB.notice("GDB Server is disabled.");
-+ GDB.error("Error creating server socket.");
- return;
- }
-
-- // Try to detect socket type
-- std::smatch match;
--
-- if (std::regex_match(g_cfg.misc.gdb_server.get(), match, ipv4_regex))
-+#ifdef WIN32
- {
-- struct addrinfo hints{};
-- struct addrinfo* info;
-- hints.ai_flags = AI_PASSIVE;
-- hints.ai_socktype = SOCK_STREAM;
--
-- std::string bind_addr = match[1].str();
-- std::string bind_port = match[2].str();
--
-- if (getaddrinfo(bind_addr.c_str(), bind_port.c_str(), &hints, &info) == 0)
-- {
-- server_socket = socket(info->ai_family, info->ai_socktype, info->ai_protocol);
--
-- if (server_socket == -1)
-- {
-- GDB.error("Error creating IP socket for '%s'.", g_cfg.misc.gdb_server.get());
-- freeaddrinfo(info);
-- return;
-- }
--
-- set_nonblocking(server_socket);
--
-- if (bind(server_socket, info->ai_addr, static_cast<int>(info->ai_addrlen)) != 0)
-- {
-- GDB.error("Failed to bind socket on '%s'.", g_cfg.misc.gdb_server.get());
-- freeaddrinfo(info);
-- return;
-- }
--
-- freeaddrinfo(info);
--
-- if (listen(server_socket, 1) != 0)
-- {
-- GDB.error("Failed to listen on '%s'.", g_cfg.misc.gdb_server.get());
-- return;
-- }
--
-- GDB.notice("Started listening on '%s'.", g_cfg.misc.gdb_server.get());
-- return;
-- }
-+ int mode = 1;
-+ ioctlsocket(server_socket, FIONBIO, (u_long FAR *)&mode);
- }
-+#else
-+ fcntl(server_socket, F_SETFL, fcntl(server_socket, F_GETFL) | O_NONBLOCK);
-+#endif
-
-- // Fallback to UNIX socket
-- server_socket = socket(AF_UNIX, SOCK_STREAM, 0);
-+ int err;
-
-- if (server_socket == -1)
-- {
-- GDB.error("Failed to create Unix socket. Possibly unsupported.");
-- return;
-- }
-+ sockaddr_in server_saddr;
-+ server_saddr.sin_family = AF_INET;
-+ int port = 2345;
-+ server_saddr.sin_port = htons(port);
-+ server_saddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
-- // Delete existing socket (TODO?)
-- fs::remove_file(g_cfg.misc.gdb_server.get());
--
-- set_nonblocking(server_socket);
--
-- sockaddr_un unix_saddr;
-- unix_saddr.sun_family = AF_UNIX;
-- strcpy_trunc(unix_saddr.sun_path, g_cfg.misc.gdb_server.get());
--
-- if (bind(server_socket, (struct sockaddr*) &unix_saddr, sizeof(unix_saddr)) != 0)
-+ err = bind(server_socket, (struct sockaddr *) &server_saddr, sizeof(server_saddr));
-+ if (err == -1)
- {
-- GDB.error("Failed to bind Unix socket '%s'.", g_cfg.misc.gdb_server.get());
-+ GDB.error("Error binding to port %d.", port);
- return;
- }
-
-- if (listen(server_socket, 1) != 0)
-+ err = listen(server_socket, 1);
-+ if (err == -1)
- {
-- GDB.error("Failed to listen on Unix socket '%s'.", g_cfg.misc.gdb_server.get());
-+ GDB.error("Error listening on port %d.", port);
- return;
- }
-
-- GDB.notice("Started listening on Unix socket '%s'.", g_cfg.misc.gdb_server.get());
-+ GDB.notice("Started listening on port %d.", port);
- }
-
- int gdb_thread::read(void* buf, int cnt)
-@@ -852,7 +786,7 @@ void gdb_thread::operator()()
- {
- start_server();
-
-- while (server_socket != -1 && thread_ctrl::state() != thread_state::aborting)
-+ while (thread_ctrl::state() != thread_state::aborting)
- {
- sockaddr_in client;
- socklen_t client_len = sizeof(client);
diff --git a/emulators/rpcs3/files/extra-patch-revert-9710473a2e3e b/emulators/rpcs3/files/extra-patch-revert-9710473a2e3e
deleted file mode 100644
index c08a4213456f..000000000000
--- a/emulators/rpcs3/files/extra-patch-revert-9710473a2e3e
+++ /dev/null
@@ -1,783 +0,0 @@
---- Utilities/sync.h.orig 2019-09-25 20:20:52 UTC
-+++ Utilities/sync.h
-@@ -15,6 +15,7 @@
- #include <linux/futex.h>
- #include <sys/time.h>
- #include <unistd.h>
-+#else
- #endif
- #include <algorithm>
- #include <ctime>
-@@ -24,8 +25,12 @@
- #include <unordered_map>
-
- #ifdef _WIN32
--DYNAMIC_IMPORT("ntdll.dll", NtWaitForSingleObject, NTSTATUS(HANDLE Handle, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
-+DYNAMIC_IMPORT("ntdll.dll", NtWaitForKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
-+DYNAMIC_IMPORT("ntdll.dll", NtReleaseKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
- DYNAMIC_IMPORT("ntdll.dll", NtDelayExecution, NTSTATUS(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval));
-+inline utils::dynamic_import<BOOL(volatile VOID* Address, PVOID CompareAddress, SIZE_T AddressSize, DWORD dwMilliseconds)> OptWaitOnAddress("kernel32.dll", "WaitOnAddress");
-+inline utils::dynamic_import<VOID(PVOID Address)> OptWakeByAddressSingle("kernel32.dll", "WakeByAddressSingle");
-+inline utils::dynamic_import<VOID(PVOID Address)> OptWakeByAddressAll("kernel32.dll", "WakeByAddressAll");
- #endif
-
- #ifndef __linux__
---- rpcs3/util/atomic.cpp.orig 2019-09-25 20:20:52 UTC
-+++ rpcs3/util/atomic.cpp
-@@ -1,24 +1,11 @@
- #include "atomic.hpp"
-
--// USE_FUTEX takes precedence over USE_POSIX
--
--#ifdef __linux__
--#define USE_FUTEX
--#define USE_POSIX
--#endif
--
- #include "Utilities/sync.h"
- #include "Utilities/asm.h"
-
--#ifdef USE_POSIX
--#include <semaphore.h>
--#endif
--
- #include <map>
- #include <mutex>
- #include <condition_variable>
--#include <iterator>
--#include <memory>
-
- // Total number of entries, should be a power of 2.
- static constexpr std::uintptr_t s_hashtable_size = 1u << 22;
-@@ -35,18 +22,8 @@ static constexpr u64 s_waiter_mask = 0x7fff'0000'0000'
- //
- static constexpr u64 s_collision_bit = 0x8000'0000'0000'0000;
-
--#ifdef USE_FUTEX
--static constexpr u64 s_sema_mask = 0;
--#else
--// Number of search groups (defines max semaphore count as gcount * 64)
--static constexpr u32 s_sema_gcount = 64;
--
--// Bits encoding allocated semaphore index (zero = not allocated yet)
--static constexpr u64 s_sema_mask = (64 * s_sema_gcount - 1) << 2;
--#endif
--
- // Implementation detail (remaining bits out of 32 available for futex)
--static constexpr u64 s_signal_mask = 0xffffffff & ~(s_waiter_mask | s_pointer_mask | s_collision_bit | s_sema_mask);
-+static constexpr u64 s_signal_mask = 0xffffffff & ~(s_waiter_mask | s_pointer_mask | s_collision_bit);
-
- // Callback for wait() function, returns false if wait should return
- static thread_local bool(*s_tls_wait_cb)(const void* data) = [](const void*)
-@@ -54,140 +31,6 @@ static thread_local bool(*s_tls_wait_cb)(const void* d
- return true;
- };
-
--#ifndef USE_FUTEX
--
--#ifdef USE_POSIX
--using sema_handle = sem_t;
--#elif defined(_WIN32)
--using sema_handle = HANDLE;
--#else
--namespace
--{
-- struct dumb_sema
-- {
-- u64 count = 0;
-- std::mutex mutex;
-- std::condition_variable cond;
-- };
--}
--
--using sema_handle = std::unique_ptr<dumb_sema>;
--#endif
--
--// Array of native semaphores
--static sema_handle s_sema_list[64 * s_sema_gcount]{};
--
--// Array of associated reference counters
--static atomic_t<u64> s_sema_refs[64 * s_sema_gcount]{};
--
--// Allocation bits (reserve first bit)
--static atomic_t<u64> s_sema_bits[s_sema_gcount]{1};
--
--static u32 sema_alloc()
--{
-- // Diversify search start points to reduce contention and increase immediate success chance
--#ifdef _WIN32
-- const u32 start = GetCurrentProcessorNumber();
--#elif __linux__
-- const u32 start = sched_getcpu();
--#else
-- const u32 start = __rdtsc();
--#endif
--
-- for (u32 i = 0; i < s_sema_gcount * 3; i++)
-- {
-- const u32 group = (i + start) % s_sema_gcount;
--
-- const auto [bits, ok] = s_sema_bits[group].fetch_op([](u64& bits)
-- {
-- if (~bits)
-- {
-- // Set lowest clear bit
-- bits |= bits + 1;
-- return true;
-- }
--
-- return false;
-- });
--
-- if (ok)
-- {
-- // Find lowest clear bit
-- const u32 id = group * 64 + utils::cnttz64(~bits, false);
--
--#ifdef USE_POSIX
-- // Initialize semaphore (should be very fast)
-- sem_init(&s_sema_list[id], 0, 0);
--#elif defined(_WIN32)
-- if (!s_sema_list[id])
-- {
-- s_sema_list[id] = CreateSemaphoreW(nullptr, 0, 0x7fff'ffff, nullptr);
-- }
--#else
-- if (!s_sema_list[id])
-- {
-- s_sema_list[id] = std::make_unique<dumb_sema>();
-- }
--#endif
--
-- // Initialize ref counter
-- if (s_sema_refs[id]++)
-- {
-- std::abort();
-- }
--
-- return id;
-- }
-- }
--
-- return 0;
--}
--
--static void sema_free(u32 id)
--{
-- if (id && id < 64 * s_sema_gcount)
-- {
-- // Dereference first
-- if (--s_sema_refs[id])
-- {
-- return;
-- }
--
--#ifdef USE_POSIX
-- // Destroy semaphore (should be very fast)
-- sem_destroy(&s_sema_list[id]);
--#else
-- // No action required
--#endif
--
-- // Reset allocation bit
-- s_sema_bits[id / 64] &= ~(1ull << (id % 64));
-- }
--}
--
--static bool sema_get(u32 id)
--{
-- if (id && id < 64 * s_sema_gcount)
-- {
-- // Increment only if the semaphore is allocated
-- if (s_sema_refs[id].fetch_op([](u64& refs)
-- {
-- if (refs)
-- {
-- // Increase reference from non-zero value
-- refs++;
-- }
-- }))
-- {
-- return true;
-- }
-- }
--
-- return false;
--}
--
--#endif
--
- static inline bool ptr_cmp(const void* data, std::size_t size, u64 old_value, u64 mask)
- {
- switch (size)
-@@ -308,8 +151,27 @@ namespace
- }
- }
-
-+#if !defined(_WIN32) && !defined(__linux__)
-+
- void atomic_storage_futex::wait(const void* data, std::size_t size, u64 old_value, u64 timeout, u64 mask)
- {
-+ fallback_wait(data, size, old_value, timeout, mask);
-+}
-+
-+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, u64 mask)
-+{
- if (!timeout)
- {
- return;
-@@ -323,8 +185,6 @@ void atomic_storage_futex::wait(const void* data, std:
-
- bool fallback = false;
-
-- u32 sema_id = -1;
--
- const auto [_, ok] = entry.fetch_op([&](u64& value)
- {
- if ((value & s_waiter_mask) == s_waiter_mask || (value & s_signal_mask) == s_signal_mask)
-@@ -333,15 +193,15 @@ void atomic_storage_futex::wait(const void* data, std:
- return false;
- }
-
--#ifndef USE_FUTEX
-- sema_id = (value & s_sema_mask) >> 2;
--#endif
--
- if (!value || (value & s_pointer_mask) == (iptr & s_pointer_mask))
- {
- // Store pointer bits
- value |= (iptr & s_pointer_mask);
- fallback = false;
-+
-+#ifdef _WIN32
-+ value += s_signal_mask & -s_signal_mask;
-+#endif
- }
- else
- {
-@@ -361,93 +221,13 @@ void atomic_storage_futex::wait(const void* data, std:
- return;
- }
-
--#ifndef USE_FUTEX
-- for (u32 loop_count = 0; !fallback && loop_count < 7; loop_count++)
-- {
-- // Try to allocate a semaphore
-- if (!sema_id)
-- {
-- const u32 sema = sema_alloc();
--
-- if (!sema)
-- {
-- break;
-- }
--
-- sema_id = entry.atomic_op([&](u64& value) -> u32
-- {
-- if (value & s_sema_mask)
-- {
-- return (value & s_sema_mask) >> 2;
-- }
--
-- // Insert allocated semaphore
-- value += s_signal_mask & -s_signal_mask;
-- value |= (u64{sema} << 2);
-- return 0;
-- });
--
-- if (sema_id)
-- {
-- // Drop unnecessary allocation
-- sema_free(sema);
-- }
-- else
-- {
-- sema_id = sema;
-- break;
-- }
-- }
--
-- if (!sema_get(sema_id))
-- {
-- sema_id = 0;
-- continue;
-- }
--
-- // Try to increment sig (check semaphore validity)
-- const auto [_old, ok] = entry.fetch_op([&](u64& value)
-- {
-- if ((value & s_signal_mask) == s_signal_mask)
-- {
-- return false;
-- }
--
-- if ((value & s_sema_mask) >> 2 != sema_id)
-- {
-- return false;
-- }
--
-- value += s_signal_mask & -s_signal_mask;
-- return true;
-- });
--
-- if (!ok)
-- {
-- sema_free(sema_id);
-- sema_id = 0;
--
-- if ((_old & s_signal_mask) == s_signal_mask)
-- {
-- // Break on signal overflow
-- break;
-- }
--
-- continue;
-- }
--
-- break;
-- }
--#endif
--
- if (fallback)
- {
- fallback_wait(data, size, old_value, timeout, mask);
- }
-- else if (sema_id && ptr_cmp(data, size, old_value, mask) && s_tls_wait_cb(data))
-+ else if (ptr_cmp(data, size, old_value, mask) && s_tls_wait_cb(data))
- {
--#ifndef USE_FUTEX
--#if defined(_WIN32) && !defined(USE_POSIX)
-+#ifdef _WIN32
- LARGE_INTEGER qw;
- qw.QuadPart = -static_cast<s64>(timeout / 100);
-
-@@ -457,60 +237,13 @@ void atomic_storage_futex::wait(const void* data, std:
- qw.QuadPart -= 1;
- }
-
-- if (!NtWaitForSingleObject(s_sema_list[sema_id], false, timeout + 1 ? &qw : nullptr))
-+ if (!NtWaitForKeyedEvent(nullptr, &entry, false, timeout + 1 ? &qw : nullptr))
- {
-- fallback = true;
-+ // Return if no errors, continue if timed out
-+ s_tls_wait_cb(nullptr);
-+ return;
- }
--#elif defined(USE_POSIX)
-- struct timespec ts;
-- clock_gettime(CLOCK_REALTIME, &ts);
-- ts.tv_sec += timeout / 1'000'000'000;
-- ts.tv_nsec += timeout % 1'000'000'000;
-- ts.tv_sec += ts.tv_nsec / 1'000'000'000;
-- ts.tv_nsec %= 1'000'000'000;
--
-- // It's pretty unreliable because it uses absolute time, which may jump backwards. Sigh.
-- if (timeout + 1)
-- {
-- if (sem_timedwait(&s_sema_list[sema_id], &ts) == 0)
-- {
-- fallback = true;
-- }
-- }
-- else
-- {
-- if (sem_wait(&s_sema_list[sema_id]) == 0)
-- {
-- fallback = true;
-- }
-- }
- #else
-- dumb_sema& sema = *s_sema_list[sema_id];
--
-- std::unique_lock lock(sema.mutex);
--
-- if (timeout + 1)
-- {
-- sema.cond.wait_for(lock, std::chrono::nanoseconds(timeout), [&]
-- {
-- return sema.count > 0;
-- });
-- }
-- else
-- {
-- sema.cond.wait(lock, [&]
-- {
-- return sema.count > 0;
-- });
-- }
--
-- if (sema.count > 0)
-- {
-- sema.count--;
-- fallback = true;
-- }
--#endif
--#else
- struct timespec ts;
- ts.tv_sec = timeout / 1'000'000'000;
- ts.tv_nsec = timeout % 1'000'000'000;
-@@ -519,11 +252,6 @@ void atomic_storage_futex::wait(const void* data, std:
- #endif
- }
-
-- if (!sema_id)
-- {
-- fallback = true;
-- }
--
- while (true)
- {
- // Try to decrement
-@@ -531,21 +259,15 @@ void atomic_storage_futex::wait(const void* data, std:
- {
- if (value & s_waiter_mask)
- {
--#ifndef USE_FUTEX
-- // If timeout
-+#ifdef _WIN32
- if (!fallback)
- {
-- if ((value & s_signal_mask) == 0 || (value & s_sema_mask) >> 2 != sema_id)
-+ if ((value & s_signal_mask) == 0)
- {
- return false;
- }
-
- value -= s_signal_mask & -s_signal_mask;
--
-- if ((value & s_signal_mask) == 0)
-- {
-- value &= ~s_sema_mask;
-- }
- }
- #endif
-
-@@ -568,45 +290,22 @@ void atomic_storage_futex::wait(const void* data, std:
- break;
- }
-
--#ifndef USE_FUTEX
--#if defined(_WIN32) && !defined(USE_POSIX)
-+#ifdef _WIN32
- static LARGE_INTEGER instant{};
-
-- if (!NtWaitForSingleObject(s_sema_list[sema_id], false, &instant))
-+ if (!NtWaitForKeyedEvent(nullptr, &entry, false, &instant))
- {
-- fallback = true;
-+ break;
- }
--#elif defined(USE_POSIX)
-- if (sem_trywait(&s_sema_list[sema_id]) == 0)
-- {
-- fallback = true;
-- }
- #else
-- dumb_sema& sema = *s_sema_list[sema_id];
--
-- std::unique_lock lock(sema.mutex);
--
-- if (sema.count > 0)
-- {
-- sema.count--;
-- fallback = true;
-- }
-+ // Unreachable
-+ std::terminate();
- #endif
--#endif
- }
-
--#ifndef USE_FUTEX
-- if (sema_id)
-- {
-- sema_free(sema_id);
-- }
--#endif
--
- s_tls_wait_cb(nullptr);
- }
-
--#ifdef USE_FUTEX
--
- void atomic_storage_futex::notify_one(const void* data)
- {
- const std::uintptr_t iptr = reinterpret_cast<std::uintptr_t>(data);
-@@ -617,6 +316,23 @@ void atomic_storage_futex::notify_one(const void* data
- {
- if (value & s_waiter_mask && (value & s_pointer_mask) == (iptr & s_pointer_mask))
- {
-+#ifdef _WIN32
-+ if ((value & s_signal_mask) == 0)
-+ {
-+ // No relevant waiters, do nothing
-+ return false;
-+ }
-+
-+ // Try to decrement if possible
-+ value -= s_waiter_mask & -s_waiter_mask;
-+ value -= s_signal_mask & -s_signal_mask;
-+
-+ if ((value & s_waiter_mask) == 0)
-+ {
-+ // Reset on last waiter
-+ value = 0;
-+ }
-+#else
- if ((value & s_signal_mask) == s_signal_mask)
- {
- // Signal overflow, do nothing
-@@ -631,7 +347,7 @@ void atomic_storage_futex::notify_one(const void* data
- notify_all(data);
- return false;
- }
--
-+#endif
- return true;
- }
- else if (value & s_waiter_mask && value & s_collision_bit)
-@@ -645,7 +361,11 @@ void atomic_storage_futex::notify_one(const void* data
-
- if (ok)
- {
-+#ifdef _WIN32
-+ NtReleaseKeyedEvent(nullptr, &entry, false, nullptr);
-+#else
- futex(reinterpret_cast<char*>(&entry) + 4 * IS_BE_MACHINE, FUTEX_WAKE_PRIVATE, 1);
-+#endif
- }
- }
-
-@@ -655,6 +375,53 @@ void atomic_storage_futex::notify_all(const void* data
-
- atomic_t<u64>& entry = s_hashtable[(iptr >> 2) % s_hashtable_size];
-
-+ // Try to consume everything
-+#ifdef _WIN32
-+ const auto [old, ok] = entry.fetch_op([&](u64& value)
-+ {
-+ if (value & s_waiter_mask)
-+ {
-+ if ((value & s_pointer_mask) == (iptr & s_pointer_mask))
-+ {
-+ if ((value & s_signal_mask) == 0)
-+ {
-+ // No relevant waiters, do nothing
-+ return false;
-+ }
-+
-+ const u64 count = (value & s_signal_mask) / (s_signal_mask & -s_signal_mask);
-+ value -= (s_waiter_mask & -s_waiter_mask) * count;
-+ value -= (s_signal_mask & -s_signal_mask) * count;
-+
-+ if ((value & s_waiter_mask) == 0)
-+ {
-+ // Reset on last waiter
-+ value = 0;
-+ }
-+
-+ return true;
-+ }
-+
-+ if (value & s_collision_bit)
-+ {
-+ fallback_notify_all(data);
-+ return false;
-+ }
-+ }
-+
-+ return false;
-+ });
-+
-+ if (!ok)
-+ {
-+ return;
-+ }
-+
-+ for (u64 count = old & s_signal_mask; count; count -= s_signal_mask & -s_signal_mask)
-+ {
-+ NtReleaseKeyedEvent(nullptr, &entry, false, nullptr);
-+ }
-+#else
- const auto [_, ok] = entry.fetch_op([&](u64& value)
- {
- if (value & s_waiter_mask)
-@@ -685,6 +452,7 @@ void atomic_storage_futex::notify_all(const void* data
- {
- futex(reinterpret_cast<char*>(&entry) + 4 * IS_BE_MACHINE, FUTEX_WAKE_PRIVATE, 0x7fffffff);
- }
-+#endif
- }
-
- #endif
-@@ -704,158 +472,3 @@ void atomic_storage_futex::raw_notify(const void* data
- notify_all(data);
- }
- }
--
--#ifndef USE_FUTEX
--
--void atomic_storage_futex::notify_one(const void* data)
--{
-- const std::uintptr_t iptr = reinterpret_cast<std::uintptr_t>(data);
--
-- atomic_t<u64>& entry = s_hashtable[(iptr >> 2) % s_hashtable_size];
--
-- const u64 value = entry;
--
-- if (value & s_waiter_mask && (value & s_pointer_mask) == (iptr & s_pointer_mask))
-- {
-- if ((value & s_signal_mask) == 0 || (value & s_sema_mask) == 0)
-- {
-- // No relevant waiters, do nothing
-- return;
-- }
-- }
-- else if (value & s_waiter_mask && value & s_collision_bit)
-- {
-- fallback_notify_one(data);
-- return;
-- }
-- else
-- {
-- return;
-- }
--
-- const u32 sema_id = (value & s_sema_mask) >> 2;
--
-- if (!sema_get(sema_id))
-- {
-- return;
-- }
--
-- const auto [_, ok] = entry.fetch_op([&](u64& value)
-- {
-- if ((value & s_waiter_mask) == 0 || (value & s_pointer_mask) != (iptr & s_pointer_mask))
-- {
-- return false;
-- }
--
-- if ((value & s_signal_mask) == 0 || (value & s_sema_mask) >> 2 != sema_id)
-- {
-- return false;
-- }
--
-- value -= s_signal_mask & -s_signal_mask;
--
-- // Reset allocated semaphore on last waiter
-- if ((value & s_signal_mask) == 0)
-- {
-- value &= ~s_sema_mask;
-- }
--
-- return true;
-- });
--
-- if (ok)
-- {
--#ifdef USE_POSIX
-- sem_post(&s_sema_list[sema_id]);
--#elif defined(_WIN32)
-- ReleaseSemaphore(s_sema_list[sema_id], 1, nullptr);
--#else
-- dumb_sema& sema = *s_sema_list[sema_id];
--
-- sema.mutex.lock();
-- sema.count += 1;
-- sema.mutex.unlock();
-- sema.cond.notify_one();
--#endif
-- }
--
-- sema_free(sema_id);
--}
--
--void atomic_storage_futex::notify_all(const void* data)
--{
-- const std::uintptr_t iptr = reinterpret_cast<std::uintptr_t>(data);
--
-- atomic_t<u64>& entry = s_hashtable[(iptr >> 2) % s_hashtable_size];
--
-- const u64 value = entry;
--
-- if (value & s_waiter_mask && (value & s_pointer_mask) == (iptr & s_pointer_mask))
-- {
-- if ((value & s_signal_mask) == 0 || (value & s_sema_mask) == 0)
-- {
-- // No relevant waiters, do nothing
-- return;
-- }
-- }
-- else if (value & s_waiter_mask && value & s_collision_bit)
-- {
-- fallback_notify_all(data);
-- return;
-- }
-- else
-- {
-- return;
-- }
--
-- const u32 sema_id = (value & s_sema_mask) >> 2;
--
-- if (!sema_get(sema_id))
-- {
-- return;
-- }
--
-- const auto [_, count] = entry.fetch_op([&](u64& value) -> u32
-- {
-- if ((value & s_waiter_mask) == 0 || (value & s_pointer_mask) != (iptr & s_pointer_mask))
-- {
-- return 0;
-- }
--
-- if ((value & s_signal_mask) == 0 || (value & s_sema_mask) >> 2 != sema_id)
-- {
-- return 0;
-- }
--
-- const u32 r = (value & s_signal_mask) / (s_signal_mask & -s_signal_mask);
-- value &= ~s_sema_mask;
-- value &= ~s_signal_mask;
-- return r;
-- });
--
--#ifdef USE_POSIX
-- for (u32 i = 0; i < count; i++)
-- {
-- sem_post(&s_sema_list[sema_id]);
-- }
--#elif defined(_WIN32)
-- if (count)
-- {
-- ReleaseSemaphore(s_sema_list[sema_id], count, nullptr);
-- }
--#else
-- if (count)
-- {
-- dumb_sema& sema = *s_sema_list[sema_id];
--
-- sema.mutex.lock();
-- sema.count += count;
-- sema.mutex.unlock();
-- sema.cond.notify_all();
-- }
--#endif
--
-- sema_free(sema_id);
--}
--
--#endif
diff --git a/emulators/rpcs3/files/extra-patch-revert-db7042b986ab b/emulators/rpcs3/files/extra-patch-revert-db7042b986ab
deleted file mode 100644
index 69ab514adcc9..000000000000
--- a/emulators/rpcs3/files/extra-patch-revert-db7042b986ab
+++ /dev/null
@@ -1,73 +0,0 @@
---- Utilities/sync.h.orig 2019-10-19 17:20:18 UTC
-+++ Utilities/sync.h
-@@ -24,8 +24,6 @@
- #include <unordered_map>
-
- #ifdef _WIN32
--DYNAMIC_IMPORT("ntdll.dll", NtWaitForKeyedEvent, NTSTATUS(HANDLE, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
--DYNAMIC_IMPORT("ntdll.dll", NtReleaseKeyedEvent, NTSTATUS(HANDLE, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
- DYNAMIC_IMPORT("ntdll.dll", NtWaitForSingleObject, NTSTATUS(HANDLE Handle, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
- DYNAMIC_IMPORT("ntdll.dll", NtDelayExecution, NTSTATUS(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval));
- #endif
---- rpcs3/util/atomic.cpp.orig 2019-10-19 17:20:18 UTC
-+++ rpcs3/util/atomic.cpp
-@@ -59,7 +59,7 @@ static thread_local bool(*s_tls_wait_cb)(const void* d
- #ifdef USE_POSIX
- using sema_handle = sem_t;
- #elif defined(_WIN32)
--using sema_handle = std::uint16_t;
-+using sema_handle = HANDLE;
- #else
- namespace
- {
-@@ -119,7 +119,10 @@ static u32 sema_alloc()
- // Initialize semaphore (should be very fast)
- sem_init(&s_sema_list[id], 0, 0);
- #elif defined(_WIN32)
-- // Do nothing
-+ if (!s_sema_list[id])
-+ {
-+ s_sema_list[id] = CreateSemaphoreW(nullptr, 0, 0x7fff'ffff, nullptr);
-+ }
- #else
- if (!s_sema_list[id])
- {
-@@ -454,7 +457,7 @@ void atomic_storage_futex::wait(const void* data, std:
- qw.QuadPart -= 1;
- }
-
-- if (!NtWaitForKeyedEvent(nullptr, &s_sema_list[sema_id], false, timeout + 1 ? &qw : nullptr))
-+ if (!NtWaitForSingleObject(s_sema_list[sema_id], false, timeout + 1 ? &qw : nullptr))
- {
- fallback = true;
- }
-@@ -569,7 +572,7 @@ void atomic_storage_futex::wait(const void* data, std:
- #if defined(_WIN32) && !defined(USE_POSIX)
- static LARGE_INTEGER instant{};
-
-- if (!NtWaitForKeyedEvent(nullptr, &s_sema_list[sema_id], false, &instant))
-+ if (!NtWaitForSingleObject(s_sema_list[sema_id], false, &instant))
- {
- fallback = true;
- }
-@@ -765,7 +768,7 @@ void atomic_storage_futex::notify_one(const void* data
- #ifdef USE_POSIX
- sem_post(&s_sema_list[sema_id]);
- #elif defined(_WIN32)
-- NtReleaseKeyedEvent(nullptr, &s_sema_list[sema_id], 1, nullptr);
-+ ReleaseSemaphore(s_sema_list[sema_id], 1, nullptr);
- #else
- dumb_sema& sema = *s_sema_list[sema_id];
-
-@@ -836,9 +839,9 @@ void atomic_storage_futex::notify_all(const void* data
- sem_post(&s_sema_list[sema_id]);
- }
- #elif defined(_WIN32)
-- for (u32 i = 0; i < count; i++)
-+ if (count)
- {
-- NtReleaseKeyedEvent(nullptr, &s_sema_list[sema_id], count, nullptr);
-+ ReleaseSemaphore(s_sema_list[sema_id], count, nullptr);
- }
- #else
- if (count)
diff --git a/emulators/rpcs3/files/extra-patch-revert-f9ad6358563b b/emulators/rpcs3/files/extra-patch-revert-f9ad6358563b
deleted file mode 100644
index 8bbb014aac53..000000000000
--- a/emulators/rpcs3/files/extra-patch-revert-f9ad6358563b
+++ /dev/null
@@ -1,169 +0,0 @@
-In file included from rpcs3/Emu/RSX/GL/GLGSRender.cpp:4:
-In file included from rpcs3/Emu/RSX/GL/GLGSRender.h:8:
-In file included from rpcs3/Emu/RSX/GL/GLTextOut.h:5:
-rpcs3/Emu/RSX/GL/../Common/TextGlyphs.h:4:10: fatal error: 'charconv' file not found
-#include <charconv>
- ^~~~~~~~~~
-rpcs3/Emu/RSX/GL/../Common/TextGlyphs.h:174:9: error:
- no member named 'from_chars' in namespace 'std'
- std::from_chars(index.data(), index.data() + index.size(), this_glyph.character, 16);
- ~~~~~^
-rpcs3/Emu/RSX/GL/../Common/TextGlyphs.h:182:11: error:
- no member named 'from_chars' in namespace 'std'
- std::from_chars(line.data(), line.data() + line.size(), this_glyph...
- ~~~~~^
-
---- rpcs3/Emu/RSX/Common/TextGlyphs.h.orig 2019-06-10 11:57:03 UTC
-+++ rpcs3/Emu/RSX/Common/TextGlyphs.h
-@@ -1,13 +1,9 @@
- #pragma once
-
--#include <array>
--#include <charconv>
--#include <string_view>
--#include <unordered_map>
- #include <vector>
-+#include <unordered_map>
-+#include <Utilities/types.h>
-
--#include "Utilities/types.h"
--
- /**
- * FONT GLYPHS GO HERE
- * Any font in hex format should work here.
-@@ -16,7 +12,7 @@
- * This example is the GNU unifont glyph set
- */
-
--constexpr std::array<std::string_view, 128> GNU_UNIFONT_GLYPHS =
-+const static std::string GNU_UNIFONT_GLYPHS[128] =
- {
- "0000 : AAAA00018000000180004A51EA505A51C99E0001800000018000000180005555",
- "0001 : AAAA00018000000180003993C252325F8A527193800000018000000180005555",
-@@ -157,37 +153,40 @@ class GlyphManager (private)
- u8 character;
- u32 glyph_point_offset;
- u32 points_count;
-- std::array<u8, 16> plot;
-+ std::vector<u8> plot;
- };
-
-- std::vector<glyph> glyph_map;
-+ std::unordered_map<u8, glyph> glyph_map;
-
-- void decode_glyph_map(const std::array<std::string_view, 128>& font_glyphs)
-+ void decode_glyph_map(const std::string glyphs[128])
- {
-- glyph_map.reserve(font_glyphs.size());
--
-- for (const auto &font_glyph : font_glyphs)
-+ for (int i = 0; i < 128; ++i)
- {
-- glyph this_glyph{};
-+ std::string character = glyphs[i];
-+ std::string index = character.substr(0, 4);
-+ std::string glyph_data = character.substr(7);
-
-- const auto index = font_glyph.substr(0, 4);
-- std::from_chars(index.data(), index.data() + index.size(), this_glyph.character, 16);
-+ glyph this_glyph;
-+ this_glyph.character = (u8)strtol(index.c_str(), nullptr, 16);
-+ this_glyph.plot.reserve(16);
-
-- const auto glyph_data = font_glyph.substr(7);
- if (glyph_data.length() == 32)
- {
-- for (std::size_t n = 0; n < this_glyph.plot.size(); ++n)
-+ for (int n = 0; n < 16; ++n)
- {
-- const auto line = glyph_data.substr(n * 2, 2);
-- std::from_chars(line.data(), line.data() + line.size(), this_glyph.plot[n], 16);
-+ std::string line = glyph_data.substr(n * 2, 2);
-+ u8 value = (u8)strtol(line.c_str(), nullptr, 16);
-+ this_glyph.plot.push_back(value);
- }
- }
- else
- {
-- // TODO: Support 16-wide characters
-+ //TODO: Support 16-wide characters
-+ for (int n = 0; n < 16; ++n)
-+ this_glyph.plot.push_back(0);
- }
-
-- glyph_map.push_back(this_glyph);
-+ glyph_map[this_glyph.character] = this_glyph;
- }
- }
-
-@@ -198,12 +197,13 @@ class GlyphManager (private)
- float x;
- float y;
-
-- explicit glyph_point(float _x, float _y) : x(_x), y(_y)
-+ glyph_point(float _x, float _y) : x(_x), y(_y)
- {}
- };
-
- GlyphManager()
- {
-+ glyph_map = {};
- decode_glyph_map(GNU_UNIFONT_GLYPHS);
- }
-
-@@ -213,11 +213,12 @@ class GlyphManager (private)
-
- for (auto &entry : glyph_map)
- {
-- entry.glyph_point_offset = (u32)result.size();
-+ glyph& text = entry.second;
-+ text.glyph_point_offset = (u32)result.size();
-
-- for (std::size_t j = 0; j < entry.plot.size(); ++j)
-+ for (int j = 0; j < 16; ++j)
- {
-- const auto &line = entry.plot[j];
-+ auto &line = text.plot[j];
- if (line == 0)
- continue;
-
-@@ -225,29 +226,28 @@ class GlyphManager (private)
- {
- if (line & (1 << i))
- {
-- // Font is inverted, so we correct it for conventional renderers
-- const auto x = (float)(7 - i);
-- const auto y = (float)(15 - j);
-- result.emplace_back(x, y);
-+ //Font is inverted, so we correct it for conventional renderers
-+ float x = (float)(7 - i);
-+ float y = (float)(15 - j);
-+ result.push_back({ x, y });
- }
- }
- }
-
-- entry.points_count = (u32)result.size() - entry.glyph_point_offset;
-+ text.points_count = (u32)result.size() - text.glyph_point_offset;
- }
-
- return result;
- }
-
-- std::unordered_map<u8, std::pair<u32, u32>> get_glyph_offsets() const
-+ std::unordered_map<u8, std::pair<u32, u32>> get_glyph_offsets()
- {
- std::unordered_map<u8, std::pair<u32, u32>> result = {};
--
-- for (const auto &entry : glyph_map)
-+ for (auto &entry : glyph_map)
- {
-- result[entry.character] = std::make_pair(entry.glyph_point_offset, entry.points_count);
-+ result[entry.second.character] = std::make_pair(entry.second.glyph_point_offset, entry.second.points_count);
- }
-
- return result;
- }
--};
-+};
-\ No newline at end of file