diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/kernel/k_handle_table.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_handle_table.h | 34 |
2 files changed, 12 insertions, 30 deletions
diff --git a/src/core/hle/kernel/k_handle_table.cpp b/src/core/hle/kernel/k_handle_table.cpp index cf95f0852..db7512ee7 100644 --- a/src/core/hle/kernel/k_handle_table.cpp +++ b/src/core/hle/kernel/k_handle_table.cpp | |||
| @@ -63,7 +63,7 @@ bool KHandleTable::Remove(Handle handle) { | |||
| 63 | return true; | 63 | return true; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj, u16 type) { | 66 | ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj) { |
| 67 | KScopedDisableDispatch dd(kernel); | 67 | KScopedDisableDispatch dd(kernel); |
| 68 | KScopedSpinLock lk(m_lock); | 68 | KScopedSpinLock lk(m_lock); |
| 69 | 69 | ||
| @@ -75,7 +75,7 @@ ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj, u16 type) { | |||
| 75 | const auto linear_id = this->AllocateLinearId(); | 75 | const auto linear_id = this->AllocateLinearId(); |
| 76 | const auto index = this->AllocateEntry(); | 76 | const auto index = this->AllocateEntry(); |
| 77 | 77 | ||
| 78 | m_entry_infos[index].info = {.linear_id = linear_id, .type = type}; | 78 | m_entry_infos[index].linear_id = linear_id; |
| 79 | m_objects[index] = obj; | 79 | m_objects[index] = obj; |
| 80 | 80 | ||
| 81 | obj->Open(); | 81 | obj->Open(); |
| @@ -116,7 +116,7 @@ void KHandleTable::Unreserve(Handle handle) { | |||
| 116 | } | 116 | } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | void KHandleTable::Register(Handle handle, KAutoObject* obj, u16 type) { | 119 | void KHandleTable::Register(Handle handle, KAutoObject* obj) { |
| 120 | KScopedDisableDispatch dd(kernel); | 120 | KScopedDisableDispatch dd(kernel); |
| 121 | KScopedSpinLock lk(m_lock); | 121 | KScopedSpinLock lk(m_lock); |
| 122 | 122 | ||
| @@ -132,7 +132,7 @@ void KHandleTable::Register(Handle handle, KAutoObject* obj, u16 type) { | |||
| 132 | // Set the entry. | 132 | // Set the entry. |
| 133 | ASSERT(m_objects[index] == nullptr); | 133 | ASSERT(m_objects[index] == nullptr); |
| 134 | 134 | ||
| 135 | m_entry_infos[index].info = {.linear_id = static_cast<u16>(linear_id), .type = type}; | 135 | m_entry_infos[index].linear_id = static_cast<u16>(linear_id); |
| 136 | m_objects[index] = obj; | 136 | m_objects[index] = obj; |
| 137 | 137 | ||
| 138 | obj->Open(); | 138 | obj->Open(); |
diff --git a/src/core/hle/kernel/k_handle_table.h b/src/core/hle/kernel/k_handle_table.h index 87004a0f9..dd27689b6 100644 --- a/src/core/hle/kernel/k_handle_table.h +++ b/src/core/hle/kernel/k_handle_table.h | |||
| @@ -42,7 +42,7 @@ public: | |||
| 42 | m_free_head_index = -1; | 42 | m_free_head_index = -1; |
| 43 | 43 | ||
| 44 | // Free all entries. | 44 | // Free all entries. |
| 45 | for (s32 i = 0; i < static_cast<s32>(m_table_size); ++i) { | 45 | for (s16 i = 0; i < static_cast<s16>(m_table_size); ++i) { |
| 46 | m_objects[i] = nullptr; | 46 | m_objects[i] = nullptr; |
| 47 | m_entry_infos[i].next_free_index = i - 1; | 47 | m_entry_infos[i].next_free_index = i - 1; |
| 48 | m_free_head_index = i; | 48 | m_free_head_index = i; |
| @@ -104,17 +104,8 @@ public: | |||
| 104 | ResultCode Reserve(Handle* out_handle); | 104 | ResultCode Reserve(Handle* out_handle); |
| 105 | void Unreserve(Handle handle); | 105 | void Unreserve(Handle handle); |
| 106 | 106 | ||
| 107 | template <typename T> | 107 | ResultCode Add(Handle* out_handle, KAutoObject* obj); |
| 108 | ResultCode Add(Handle* out_handle, T* obj) { | 108 | void Register(Handle handle, KAutoObject* obj); |
| 109 | static_assert(std::is_base_of_v<KAutoObject, T>); | ||
| 110 | return this->Add(out_handle, obj, obj->GetTypeObj().GetClassToken()); | ||
| 111 | } | ||
| 112 | |||
| 113 | template <typename T> | ||
| 114 | void Register(Handle handle, T* obj) { | ||
| 115 | static_assert(std::is_base_of_v<KAutoObject, T>); | ||
| 116 | return this->Register(handle, obj, obj->GetTypeObj().GetClassToken()); | ||
| 117 | } | ||
| 118 | 109 | ||
| 119 | template <typename T> | 110 | template <typename T> |
| 120 | bool GetMultipleObjects(T** out, const Handle* handles, size_t num_handles) const { | 111 | bool GetMultipleObjects(T** out, const Handle* handles, size_t num_handles) const { |
| @@ -160,9 +151,6 @@ public: | |||
| 160 | } | 151 | } |
| 161 | 152 | ||
| 162 | private: | 153 | private: |
| 163 | ResultCode Add(Handle* out_handle, KAutoObject* obj, u16 type); | ||
| 164 | void Register(Handle handle, KAutoObject* obj, u16 type); | ||
| 165 | |||
| 166 | s32 AllocateEntry() { | 154 | s32 AllocateEntry() { |
| 167 | ASSERT(m_count < m_table_size); | 155 | ASSERT(m_count < m_table_size); |
| 168 | 156 | ||
| @@ -179,7 +167,7 @@ private: | |||
| 179 | ASSERT(m_count > 0); | 167 | ASSERT(m_count > 0); |
| 180 | 168 | ||
| 181 | m_objects[index] = nullptr; | 169 | m_objects[index] = nullptr; |
| 182 | m_entry_infos[index].next_free_index = m_free_head_index; | 170 | m_entry_infos[index].next_free_index = static_cast<s16>(m_free_head_index); |
| 183 | 171 | ||
| 184 | m_free_head_index = index; | 172 | m_free_head_index = index; |
| 185 | 173 | ||
| @@ -278,19 +266,13 @@ private: | |||
| 278 | } | 266 | } |
| 279 | 267 | ||
| 280 | union EntryInfo { | 268 | union EntryInfo { |
| 281 | struct { | 269 | u16 linear_id; |
| 282 | u16 linear_id; | 270 | s16 next_free_index; |
| 283 | u16 type; | ||
| 284 | } info; | ||
| 285 | s32 next_free_index; | ||
| 286 | 271 | ||
| 287 | constexpr u16 GetLinearId() const { | 272 | constexpr u16 GetLinearId() const { |
| 288 | return info.linear_id; | 273 | return linear_id; |
| 289 | } | ||
| 290 | constexpr u16 GetType() const { | ||
| 291 | return info.type; | ||
| 292 | } | 274 | } |
| 293 | constexpr s32 GetNextFreeIndex() const { | 275 | constexpr s16 GetNextFreeIndex() const { |
| 294 | return next_free_index; | 276 | return next_free_index; |
| 295 | } | 277 | } |
| 296 | }; | 278 | }; |