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>
This commit is contained in:
Megamouse 2024-12-29 13:53:04 +01:00 committed by GitHub
parent 439d665096
commit 15f29eedee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 9 deletions

View File

@ -16,7 +16,7 @@ namespace
struct storage_manager
{
// This is probably wrong and should be assigned per fd or something
atomic_ptr<shared_ptr<lv2_event_queue>> asyncequeue;
atomic_ptr<lv2_event_queue> 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<storage_manager>();
if (auto q = *manager.asyncequeue.load())
if (auto q = manager.asyncequeue.load())
{
q->send(0, unk, unk, unk);
}

View File

@ -238,7 +238,7 @@ matching_ctx::matching_ctx(vm::ptr<SceNpId> npId, vm::ptr<SceNpMatchingHandler>
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)
{

View File

@ -289,8 +289,8 @@ struct matching_ctx
{
matching_ctx(vm::ptr<SceNpId> npid, vm::ptr<SceNpMatchingHandler> handler, vm::ptr<void> 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;

View File

@ -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 <typename T1>
static constexpr bool is_stx_pointer = false
|| is_instance_of<std::remove_cv_t<T1>, shared_ptr>::value
|| is_instance_of<std::remove_cv_t<T1>, single_ptr>::value
|| is_instance_of<std::remove_cv_t<T1>, atomic_ptr>::value;
|| is_instance_of<std::remove_cvref_t<T1>, shared_ptr>::value
|| is_instance_of<std::remove_cvref_t<T1>, single_ptr>::value
|| is_instance_of<std::remove_cvref_t<T1>, atomic_ptr>::value
|| std::is_same_v<std::remove_cvref_t<T1>, null_ptr_t>;
public:
using element_type = std::remove_extent_t<T>;