1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-08 21:21:48 +00:00

Put handle in its own file & fix it

This commit is contained in:
TuxSH 2018-11-02 23:57:00 +01:00 committed by Michael Scire
parent 6166262b5c
commit 672204c993
5 changed files with 34 additions and 18 deletions

View file

@ -0,0 +1,29 @@
#pragma once
#include <mesosphere/core/types.hpp>
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;
};
}

View file

@ -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; }

View file

@ -42,19 +42,4 @@ using vs64 = volatile int64_t;
template <typename T>
using SharedPtr = boost::intrusive_ptr<T>;
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); }
};
}

View file

@ -1,6 +1,7 @@
#pragma once
#include <mesosphere/core/util.hpp>
#include <mesosphere/core/Handle.hpp>
#include <mesosphere/kresources/KAutoObject.hpp>
#include <mesosphere/arch/KSpinLock.hpp>
#include <array>

View file

@ -3,6 +3,7 @@
#include <atomic>
#include <boost/intrusive/list.hpp>
#include <mesosphere/core/util.hpp>
#include <mesosphere/core/Handle.hpp>
#include <mesosphere/core/Result.hpp>
#include <mesosphere/processes/KProcess.hpp>
#include <mesosphere/interfaces/IAlarmable.hpp>