From 672204c993406ad8d3b66c5f0c3f5fbd186e4c1d Mon Sep 17 00:00:00 2001 From: TuxSH Date: Fri, 2 Nov 2018 23:57:00 +0100 Subject: [PATCH] Put handle in its own file & fix it --- mesosphere/include/mesosphere/core/Handle.hpp | 29 +++++++++++++++++++ mesosphere/include/mesosphere/core/Result.hpp | 6 ++-- mesosphere/include/mesosphere/core/types.hpp | 15 ---------- .../mesosphere/processes/KHandleTable.hpp | 1 + .../include/mesosphere/threading/KThread.hpp | 1 + 5 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 mesosphere/include/mesosphere/core/Handle.hpp diff --git a/mesosphere/include/mesosphere/core/Handle.hpp b/mesosphere/include/mesosphere/core/Handle.hpp new file mode 100644 index 000000000..2ac5b4f71 --- /dev/null +++ b/mesosphere/include/mesosphere/core/Handle.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include + +namespace mesosphere +{ + +class Handle final { + public: + constexpr bool IsAliasOrFree() const { return isAlias || id < 0; } + + constexpr bool operator==(const Handle &other) const + { + return index == other.index && id == other.id && isAlias == other.isAlias; + } + + constexpr bool operator!=(const Handle &other) const { return !(*this == other); } + + constexpr Handle() : index{0}, id{0}, isAlias{false} {} + + private: + friend class KHandleTable; + constexpr Handle(u16 index, s16 id, bool isAlias = false) : index{index}, id{id}, isAlias{isAlias} {} + u32 index : 15; + s32 id : 16; + u32 isAlias : 1; +}; + +} diff --git a/mesosphere/include/mesosphere/core/Result.hpp b/mesosphere/include/mesosphere/core/Result.hpp index b351a9afe..3dd7cf1f9 100644 --- a/mesosphere/include/mesosphere/core/Result.hpp +++ b/mesosphere/include/mesosphere/core/Result.hpp @@ -5,7 +5,7 @@ namespace mesosphere { -class Result { +class Result final { public: enum class Module : uint { None = 0, @@ -59,8 +59,8 @@ class Result { NotDebugged = 520, }; - Result() : module{(uint)Module::None}, description{(uint)Description::None} {} - Result(Description description, Module module = Module::Kernel) : module{(uint)module}, description{(uint)description} {} + constexpr Result() : module{(uint)Module::None}, description{(uint)Description::None} {} + constexpr Result(Description description, Module module = Module::Kernel) : module{(uint)module}, description{(uint)description} {} constexpr bool IsSuccess() const { return module == (uint)Module::None && description == (uint)Description::None; } constexpr bool operator==(const Result &other) const { return module == other.module && description == other.description; } diff --git a/mesosphere/include/mesosphere/core/types.hpp b/mesosphere/include/mesosphere/core/types.hpp index d5cda6945..adb4a0dbe 100644 --- a/mesosphere/include/mesosphere/core/types.hpp +++ b/mesosphere/include/mesosphere/core/types.hpp @@ -42,19 +42,4 @@ using vs64 = volatile int64_t; template using SharedPtr = boost::intrusive_ptr; -struct Handle { - u16 index : 15; - s16 id : 16; - bool isAlias : 1; - - constexpr bool IsAliasOrFree() const { return isAlias || id < 0; } - - constexpr bool operator==(const Handle &other) const - { - return index == other.index && id == other.id && isAlias == other.isAlias; - } - - constexpr bool operator!=(const Handle &other) const { return !(*this == other); } -}; - } diff --git a/mesosphere/include/mesosphere/processes/KHandleTable.hpp b/mesosphere/include/mesosphere/processes/KHandleTable.hpp index 52cbde617..ddc52cc01 100644 --- a/mesosphere/include/mesosphere/processes/KHandleTable.hpp +++ b/mesosphere/include/mesosphere/processes/KHandleTable.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include diff --git a/mesosphere/include/mesosphere/threading/KThread.hpp b/mesosphere/include/mesosphere/threading/KThread.hpp index 7233b1333..1cfbfe030 100644 --- a/mesosphere/include/mesosphere/threading/KThread.hpp +++ b/mesosphere/include/mesosphere/threading/KThread.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include