From ff186b2498e5f3119e0d03a859754722e1948c62 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 16 Jan 2021 00:25:29 -0800 Subject: core: hle: kernel: object: Implement Finalize() virtual method. --- src/core/hle/kernel/client_port.h | 2 ++ src/core/hle/kernel/client_session.h | 2 ++ src/core/hle/kernel/handle_table.cpp | 4 ++++ src/core/hle/kernel/k_synchronization_object.cpp | 2 +- src/core/hle/kernel/object.h | 2 ++ src/core/hle/kernel/process.h | 2 ++ src/core/hle/kernel/readable_event.h | 2 ++ src/core/hle/kernel/resource_limit.h | 2 ++ src/core/hle/kernel/server_port.h | 2 ++ src/core/hle/kernel/server_session.h | 2 ++ src/core/hle/kernel/session.h | 2 ++ src/core/hle/kernel/shared_memory.h | 2 ++ src/core/hle/kernel/transfer_memory.h | 2 ++ src/core/hle/kernel/writable_event.cpp | 4 ---- src/core/hle/kernel/writable_event.h | 3 ++- 15 files changed, 29 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index 9762bbf0d..77559ebf9 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -51,6 +51,8 @@ public: */ void ConnectionClosed(); + void Finalize() override {} + private: std::shared_ptr server_port; ///< ServerPort associated with this client port. u32 max_sessions = 0; ///< Maximum number of simultaneous sessions the port can have diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index a914c0990..85aafeaf4 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -51,6 +51,8 @@ public: bool IsSignaled() const override; + void Finalize() override {} + private: static ResultVal> Create(KernelCore& kernel, std::shared_ptr parent, diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 10a4e0510..1a2fa9cd8 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -89,6 +89,10 @@ ResultCode HandleTable::Close(Handle handle) { const u16 slot = GetSlot(handle); + if (objects[slot].use_count() == 1) { + objects[slot]->Finalize(); + } + objects[slot] = nullptr; generations[slot] = next_free_slot; diff --git a/src/core/hle/kernel/k_synchronization_object.cpp b/src/core/hle/kernel/k_synchronization_object.cpp index 61432fef8..18e7026f5 100644 --- a/src/core/hle/kernel/k_synchronization_object.cpp +++ b/src/core/hle/kernel/k_synchronization_object.cpp @@ -136,7 +136,7 @@ ResultCode KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index, KSynchronizationObject::KSynchronizationObject(KernelCore& kernel) : Object{kernel} {} -KSynchronizationObject ::~KSynchronizationObject() = default; +KSynchronizationObject::~KSynchronizationObject() = default; void KSynchronizationObject::NotifyAvailable(ResultCode result) { KScopedSchedulerLock lock(kernel); diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h index 27124ef67..be7fcb5fb 100644 --- a/src/core/hle/kernel/object.h +++ b/src/core/hle/kernel/object.h @@ -61,6 +61,8 @@ public: */ bool IsWaitable() const; + virtual void Finalize() = 0; + protected: /// The kernel instance this object was created under. KernelCore& kernel; diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 5a2cfdb36..917babfb4 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -308,6 +308,8 @@ public: bool IsSignaled() const override; + void Finalize() override {} + /////////////////////////////////////////////////////////////////////////////////////////////// // Thread-local storage management diff --git a/src/core/hle/kernel/readable_event.h b/src/core/hle/kernel/readable_event.h index 34e477274..2195710c2 100644 --- a/src/core/hle/kernel/readable_event.h +++ b/src/core/hle/kernel/readable_event.h @@ -47,6 +47,8 @@ public: bool IsSignaled() const override; + void Finalize() override {} + private: explicit ReadableEvent(KernelCore& kernel); diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h index 936cc4d0f..464d4f2a6 100644 --- a/src/core/hle/kernel/resource_limit.h +++ b/src/core/hle/kernel/resource_limit.h @@ -85,6 +85,8 @@ public: */ ResultCode SetLimitValue(ResourceType resource, s64 value); + void Finalize() override {} + private: // TODO(Subv): Increment resource limit current values in their respective Kernel::T::Create // functions diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index 6470df993..29b4f2509 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -81,6 +81,8 @@ public: bool IsSignaled() const override; + void Finalize() override {} + private: /// ServerSessions waiting to be accepted by the port std::vector> pending_sessions; diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index d45cddec3..c42d5ee59 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h @@ -126,6 +126,8 @@ public: bool IsSignaled() const override; + void Finalize() override {} + private: /// Queues a sync request from the emulated application. ResultCode QueueSyncRequest(std::shared_ptr thread, Core::Memory::Memory& memory); diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index f6dd2c1d2..fa3c5651a 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h @@ -39,6 +39,8 @@ public: bool IsSignaled() const override; + void Finalize() override {} + std::shared_ptr Client() { if (auto result{client.lock()}) { return result; diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index 0ef87235c..623bd8b11 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -71,6 +71,8 @@ public: return device_memory.GetPointer(physical_address + offset); } + void Finalize() override {} + private: Core::DeviceMemory& device_memory; Process* owner_process{}; diff --git a/src/core/hle/kernel/transfer_memory.h b/src/core/hle/kernel/transfer_memory.h index 05e9f7464..777799d12 100644 --- a/src/core/hle/kernel/transfer_memory.h +++ b/src/core/hle/kernel/transfer_memory.h @@ -72,6 +72,8 @@ public: /// is closed. ResultCode Reset(); + void Finalize() override {} + private: /// The base address for the memory managed by this instance. VAddr base_address{}; diff --git a/src/core/hle/kernel/writable_event.cpp b/src/core/hle/kernel/writable_event.cpp index dbe34472b..142212ee4 100644 --- a/src/core/hle/kernel/writable_event.cpp +++ b/src/core/hle/kernel/writable_event.cpp @@ -38,8 +38,4 @@ void WritableEvent::Clear() { readable->Clear(); } -bool WritableEvent::IsSignaled() const { - return readable->IsSignaled(); -} - } // namespace Kernel diff --git a/src/core/hle/kernel/writable_event.h b/src/core/hle/kernel/writable_event.h index 6189cf65c..467eb2c21 100644 --- a/src/core/hle/kernel/writable_event.h +++ b/src/core/hle/kernel/writable_event.h @@ -46,7 +46,8 @@ public: void Signal(); void Clear(); - bool IsSignaled() const; + + void Finalize() override {} private: explicit WritableEvent(KernelCore& kernel); -- cgit v1.2.3