summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/handle_table.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-04 08:22:07 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:50 +0200
commit086db71e942dc3468bccb741cabf62fdd221e790 (patch)
tree46dda7ba6a9d2a1590b09ddddb450595879b2896 /src/core/hle/kernel/handle_table.cpp
parenthle: kernel: Migrate KProcess to KAutoObject. (diff)
downloadyuzu-086db71e942dc3468bccb741cabf62fdd221e790.tar
yuzu-086db71e942dc3468bccb741cabf62fdd221e790.tar.gz
yuzu-086db71e942dc3468bccb741cabf62fdd221e790.tar.bz2
yuzu-086db71e942dc3468bccb741cabf62fdd221e790.tar.lz
yuzu-086db71e942dc3468bccb741cabf62fdd221e790.tar.xz
yuzu-086db71e942dc3468bccb741cabf62fdd221e790.tar.zst
yuzu-086db71e942dc3468bccb741cabf62fdd221e790.zip
Diffstat (limited to 'src/core/hle/kernel/handle_table.cpp')
-rw-r--r--src/core/hle/kernel/handle_table.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index f746c4888..427c6fc1b 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -47,9 +47,21 @@ ResultCode HandleTable::SetSize(s32 handle_table_size) {
return RESULT_SUCCESS;
}
-ResultVal<Handle> HandleTable::Create(std::shared_ptr<Object> obj) {
+ResultVal<Handle> HandleTable::Create(Object* obj) {
DEBUG_ASSERT(obj != nullptr);
+ switch (obj->GetHandleType()) {
+ case HandleType::SharedMemory:
+ case HandleType::Thread:
+ case HandleType::Process: {
+ Handle handle{};
+ Add(&handle, reinterpret_cast<KAutoObject*>(obj), {});
+ return MakeResult<Handle>(handle);
+ }
+ default:
+ break;
+ }
+
const u16 slot = next_free_slot;
if (slot >= table_size) {
LOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use.");
@@ -66,7 +78,7 @@ ResultVal<Handle> HandleTable::Create(std::shared_ptr<Object> obj) {
}
generations[slot] = generation;
- objects[slot] = std::move(obj);
+ objects[slot] = std::move(SharedFrom(obj));
Handle handle = generation | (slot << 15);
return MakeResult<Handle>(handle);
@@ -100,12 +112,12 @@ ResultCode HandleTable::Add(Handle* out_handle, KAutoObject* obj, u16 type) {
}
ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
- std::shared_ptr<Object> object = SharedFrom(GetGeneric(handle));
+ auto object = GetGeneric(handle);
if (object == nullptr) {
LOG_ERROR(Kernel, "Tried to duplicate invalid handle: {:08X}", handle);
return ResultInvalidHandle;
}
- return Create(std::move(object));
+ return Create(object);
}
bool HandleTable::Remove(Handle handle) {