From 15f29eedee456a17357b8f3feb3c74072de81b16 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 29 Dec 2024 13:53:04 +0100 Subject: [PATCH] Fix atomic_ptr value constructing overloads (#16473) * Fix idm remove idm::remove calls shared_ptr::exchange with a null_ptr. This calls the stored object's constructor with null args. --------- Co-authored-by: Elad <18193363+elad335@users.noreply.github.com> --- rpcs3/Emu/Cell/lv2/sys_storage.cpp | 4 ++-- rpcs3/Emu/NP/np_contexts.cpp | 4 ++-- rpcs3/Emu/NP/np_contexts.h | 4 ++-- rpcs3/util/shared_ptr.hpp | 9 ++++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_storage.cpp b/rpcs3/Emu/Cell/lv2/sys_storage.cpp index 07e2956d31..d83a5b2d39 100644 --- a/rpcs3/Emu/Cell/lv2/sys_storage.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_storage.cpp @@ -16,7 +16,7 @@ namespace struct storage_manager { // This is probably wrong and should be assigned per fd or something - atomic_ptr> asyncequeue; + atomic_ptr asyncequeue; }; } @@ -137,7 +137,7 @@ error_code sys_storage_async_send_device_command(u32 dev_handle, u64 cmd, vm::pt auto& manager = g_fxo->get(); - if (auto q = *manager.asyncequeue.load()) + if (auto q = manager.asyncequeue.load()) { q->send(0, unk, unk, unk); } diff --git a/rpcs3/Emu/NP/np_contexts.cpp b/rpcs3/Emu/NP/np_contexts.cpp index cd9a11f28d..e448a3f56c 100644 --- a/rpcs3/Emu/NP/np_contexts.cpp +++ b/rpcs3/Emu/NP/np_contexts.cpp @@ -238,7 +238,7 @@ matching_ctx::matching_ctx(vm::ptr npId, vm::ptr this->handler = handler; this->arg = arg; } -void matching_ctx::queue_callback(u32 req_id, s32 event, s32 error_code) +void matching_ctx::queue_callback(u32 req_id, s32 event, s32 error_code) const { if (handler) { @@ -249,7 +249,7 @@ void matching_ctx::queue_callback(u32 req_id, s32 event, s32 error_code) }); } } -void matching_ctx::queue_gui_callback(s32 event, s32 error_code) +void matching_ctx::queue_gui_callback(s32 event, s32 error_code) const { if (gui_handler) { diff --git a/rpcs3/Emu/NP/np_contexts.h b/rpcs3/Emu/NP/np_contexts.h index cf11098dd8..d82410c0a2 100644 --- a/rpcs3/Emu/NP/np_contexts.h +++ b/rpcs3/Emu/NP/np_contexts.h @@ -289,8 +289,8 @@ struct matching_ctx { matching_ctx(vm::ptr npid, vm::ptr handler, vm::ptr arg); - void queue_callback(u32 req_id, s32 event, s32 error_code); - void queue_gui_callback(s32 event, s32 error_code); + void queue_callback(u32 req_id, s32 event, s32 error_code) const; + void queue_gui_callback(s32 event, s32 error_code) const; static const u32 id_base = 0x9001; static const u32 id_step = 1; diff --git a/rpcs3/util/shared_ptr.hpp b/rpcs3/util/shared_ptr.hpp index 06f1d2a380..fb3c2c4019 100644 --- a/rpcs3/util/shared_ptr.hpp +++ b/rpcs3/util/shared_ptr.hpp @@ -76,6 +76,8 @@ namespace stx constexpr shared_data() noexcept = default; }; + struct null_ptr_t; + // Simplified unique pointer. In some cases, std::unique_ptr is preferred. // This one is shared_ptr counterpart, it has a control block with refs and deleter. // It's trivially convertible to shared_ptr, and back if refs == 1. @@ -603,9 +605,10 @@ namespace stx template static constexpr bool is_stx_pointer = false - || is_instance_of, shared_ptr>::value - || is_instance_of, single_ptr>::value - || is_instance_of, atomic_ptr>::value; + || is_instance_of, shared_ptr>::value + || is_instance_of, single_ptr>::value + || is_instance_of, atomic_ptr>::value + || std::is_same_v, null_ptr_t>; public: using element_type = std::remove_extent_t;