diff options
| -rw-r--r-- | src/core/hle/kernel/handle_table.cpp | 11 | ||||
| -rw-r--r-- | src/core/hle/kernel/handle_table.h | 15 |
2 files changed, 14 insertions, 12 deletions
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 5ee5c05e3..1bf79b692 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -12,12 +12,23 @@ | |||
| 12 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
| 13 | 13 | ||
| 14 | namespace Kernel { | 14 | namespace Kernel { |
| 15 | namespace { | ||
| 16 | constexpr u16 GetSlot(Handle handle) { | ||
| 17 | return handle >> 15; | ||
| 18 | } | ||
| 19 | |||
| 20 | constexpr u16 GetGeneration(Handle handle) { | ||
| 21 | return handle & 0x7FFF; | ||
| 22 | } | ||
| 23 | } // Anonymous namespace | ||
| 15 | 24 | ||
| 16 | HandleTable::HandleTable() { | 25 | HandleTable::HandleTable() { |
| 17 | next_generation = 1; | 26 | next_generation = 1; |
| 18 | Clear(); | 27 | Clear(); |
| 19 | } | 28 | } |
| 20 | 29 | ||
| 30 | HandleTable::~HandleTable() = default; | ||
| 31 | |||
| 21 | ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { | 32 | ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { |
| 22 | DEBUG_ASSERT(obj != nullptr); | 33 | DEBUG_ASSERT(obj != nullptr); |
| 23 | 34 | ||
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index 9e2f33e8a..e3f3e3fb8 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h | |||
| @@ -43,6 +43,7 @@ enum KernelHandle : Handle { | |||
| 43 | class HandleTable final : NonCopyable { | 43 | class HandleTable final : NonCopyable { |
| 44 | public: | 44 | public: |
| 45 | HandleTable(); | 45 | HandleTable(); |
| 46 | ~HandleTable(); | ||
| 46 | 47 | ||
| 47 | /** | 48 | /** |
| 48 | * Allocates a handle for the given object. | 49 | * Allocates a handle for the given object. |
| @@ -89,18 +90,8 @@ public: | |||
| 89 | void Clear(); | 90 | void Clear(); |
| 90 | 91 | ||
| 91 | private: | 92 | private: |
| 92 | /** | 93 | /// This is the maximum limit of handles allowed per process in Horizon |
| 93 | * This is the maximum limit of handles allowed per process in CTR-OS. It can be further | 94 | static constexpr std::size_t MAX_COUNT = 1024; |
| 94 | * reduced by ExHeader values, but this is not emulated here. | ||
| 95 | */ | ||
| 96 | static const std::size_t MAX_COUNT = 4096; | ||
| 97 | |||
| 98 | static u16 GetSlot(Handle handle) { | ||
| 99 | return handle >> 15; | ||
| 100 | } | ||
| 101 | static u16 GetGeneration(Handle handle) { | ||
| 102 | return handle & 0x7FFF; | ||
| 103 | } | ||
| 104 | 95 | ||
| 105 | /// Stores the Object referenced by the handle or null if the slot is empty. | 96 | /// Stores the Object referenced by the handle or null if the slot is empty. |
| 106 | std::array<SharedPtr<Object>, MAX_COUNT> objects; | 97 | std::array<SharedPtr<Object>, MAX_COUNT> objects; |