diff options
| author | 2022-11-22 17:47:53 -0500 | |
|---|---|---|
| committer | 2022-11-22 17:47:53 -0500 | |
| commit | 168c9ee3415bf6400ef0b0cc0eb2dfa73fac2464 (patch) | |
| tree | 135fb961ff5f842da81a1f06e2835ed8e49b5e25 | |
| parent | Merge pull request #9219 from german77/nfc_impl (diff) | |
| parent | k_handle_table: Remove cast to void* in GetObjectForIpc (diff) | |
| download | yuzu-168c9ee3415bf6400ef0b0cc0eb2dfa73fac2464.tar.gz yuzu-168c9ee3415bf6400ef0b0cc0eb2dfa73fac2464.tar.xz yuzu-168c9ee3415bf6400ef0b0cc0eb2dfa73fac2464.zip | |
Merge pull request #9299 from lioncash/cast
k_handle_table: Remove cast to void* in GetObjectForIpc
| -rw-r--r-- | src/core/hle/kernel/k_handle_table.cpp | 17 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_handle_table.h | 16 |
2 files changed, 18 insertions, 15 deletions
diff --git a/src/core/hle/kernel/k_handle_table.cpp b/src/core/hle/kernel/k_handle_table.cpp index 1c7a766c8..3535ddc0c 100644 --- a/src/core/hle/kernel/k_handle_table.cpp +++ b/src/core/hle/kernel/k_handle_table.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/kernel/k_handle_table.h" | 4 | #include "core/hle/kernel/k_handle_table.h" |
| 5 | #include "core/hle/kernel/k_process.h" | ||
| 5 | 6 | ||
| 6 | namespace Kernel { | 7 | namespace Kernel { |
| 7 | 8 | ||
| @@ -82,6 +83,22 @@ Result KHandleTable::Add(Handle* out_handle, KAutoObject* obj) { | |||
| 82 | R_SUCCEED(); | 83 | R_SUCCEED(); |
| 83 | } | 84 | } |
| 84 | 85 | ||
| 86 | KScopedAutoObject<KAutoObject> KHandleTable::GetObjectForIpc(Handle handle, | ||
| 87 | KThread* cur_thread) const { | ||
| 88 | // Handle pseudo-handles. | ||
| 89 | ASSERT(cur_thread != nullptr); | ||
| 90 | if (handle == Svc::PseudoHandle::CurrentProcess) { | ||
| 91 | auto* const cur_process = cur_thread->GetOwnerProcess(); | ||
| 92 | ASSERT(cur_process != nullptr); | ||
| 93 | return cur_process; | ||
| 94 | } | ||
| 95 | if (handle == Svc::PseudoHandle::CurrentThread) { | ||
| 96 | return cur_thread; | ||
| 97 | } | ||
| 98 | |||
| 99 | return GetObjectForIpcWithoutPseudoHandle(handle); | ||
| 100 | } | ||
| 101 | |||
| 85 | Result KHandleTable::Reserve(Handle* out_handle) { | 102 | Result KHandleTable::Reserve(Handle* out_handle) { |
| 86 | KScopedDisableDispatch dd{m_kernel}; | 103 | KScopedDisableDispatch dd{m_kernel}; |
| 87 | KScopedSpinLock lk(m_lock); | 104 | KScopedSpinLock lk(m_lock); |
diff --git a/src/core/hle/kernel/k_handle_table.h b/src/core/hle/kernel/k_handle_table.h index 65cae3b27..37a24e7d9 100644 --- a/src/core/hle/kernel/k_handle_table.h +++ b/src/core/hle/kernel/k_handle_table.h | |||
| @@ -113,21 +113,7 @@ public: | |||
| 113 | return this->GetObjectImpl(handle); | 113 | return this->GetObjectImpl(handle); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | KScopedAutoObject<KAutoObject> GetObjectForIpc(Handle handle, KThread* cur_thread) const { | 116 | KScopedAutoObject<KAutoObject> GetObjectForIpc(Handle handle, KThread* cur_thread) const; |
| 117 | // Handle pseudo-handles. | ||
| 118 | ASSERT(cur_thread != nullptr); | ||
| 119 | if (handle == Svc::PseudoHandle::CurrentProcess) { | ||
| 120 | auto* const cur_process = | ||
| 121 | static_cast<KAutoObject*>(static_cast<void*>(cur_thread->GetOwnerProcess())); | ||
| 122 | ASSERT(cur_process != nullptr); | ||
| 123 | return cur_process; | ||
| 124 | } | ||
| 125 | if (handle == Svc::PseudoHandle::CurrentThread) { | ||
| 126 | return static_cast<KAutoObject*>(cur_thread); | ||
| 127 | } | ||
| 128 | |||
| 129 | return GetObjectForIpcWithoutPseudoHandle(handle); | ||
| 130 | } | ||
| 131 | 117 | ||
| 132 | KScopedAutoObject<KAutoObject> GetObjectByIndex(Handle* out_handle, size_t index) const { | 118 | KScopedAutoObject<KAutoObject> GetObjectByIndex(Handle* out_handle, size_t index) const { |
| 133 | KScopedDisableDispatch dd{m_kernel}; | 119 | KScopedDisableDispatch dd{m_kernel}; |