mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-01 07:18:22 -04:00
kern/util: update structure layouts to match Nintendo (saves 0x10 per KThread/KSession)
This commit is contained in:
parent
7805a3624e
commit
26c02e2019
6 changed files with 15 additions and 12 deletions
|
@ -53,6 +53,7 @@ namespace ams::freebsd {
|
|||
RB_RED = 1,
|
||||
};
|
||||
|
||||
#pragma pack(push, 4)
|
||||
template<typename T>
|
||||
class RBEntry {
|
||||
private:
|
||||
|
@ -82,6 +83,7 @@ namespace ams::freebsd {
|
|||
|
||||
constexpr ALWAYS_INLINE void SetColor(RBColor c) { m_rbe_color = c; }
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
template<typename T> struct CheckRBEntry { static constexpr bool value = false; };
|
||||
template<typename T> struct CheckRBEntry<RBEntry<T>> { static constexpr bool value = true; };
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace ams::util {
|
|||
|
||||
}
|
||||
|
||||
#pragma pack(push, 4)
|
||||
struct IntrusiveRedBlackTreeNode {
|
||||
NON_COPYABLE(IntrusiveRedBlackTreeNode);
|
||||
public:
|
||||
|
@ -45,6 +46,8 @@ namespace ams::util {
|
|||
|
||||
constexpr ALWAYS_INLINE void SetRBEntry(const RBEntry &entry) { m_entry = entry; }
|
||||
};
|
||||
static_assert(sizeof(IntrusiveRedBlackTreeNode) == 3 * sizeof(void *) + std::max<size_t>(sizeof(freebsd::RBColor), 4));
|
||||
#pragma pack(pop)
|
||||
|
||||
template<class T, class Traits, class Comparator>
|
||||
class IntrusiveRedBlackTree;
|
||||
|
@ -501,6 +504,7 @@ namespace ams::util {
|
|||
private:
|
||||
static constexpr TypedStorage<Derived> DerivedStorage = {};
|
||||
static_assert(GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage));
|
||||
static_assert(util::IsAligned(util::impl::OffsetOf<Member, Derived>, alignof(void *)));
|
||||
};
|
||||
|
||||
template<auto T, class Derived = util::impl::GetParentType<T>>
|
||||
|
@ -515,7 +519,7 @@ namespace ams::util {
|
|||
|
||||
static constexpr bool IsValid() {
|
||||
TypedStorage<Derived> DerivedStorage = {};
|
||||
return GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage);
|
||||
return GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage) && util::IsAligned(util::impl::OffsetOf<Member, Derived>, alignof(void *));
|
||||
}
|
||||
private:
|
||||
template<class, class, class>
|
||||
|
@ -541,7 +545,7 @@ namespace ams::util {
|
|||
};
|
||||
|
||||
template<class Derived>
|
||||
class IntrusiveRedBlackTreeBaseNode : public IntrusiveRedBlackTreeNode {
|
||||
class alignas(void *) IntrusiveRedBlackTreeBaseNode : public IntrusiveRedBlackTreeNode {
|
||||
public:
|
||||
constexpr ALWAYS_INLINE Derived *GetPrev() { return static_cast< Derived *>(impl::IntrusiveRedBlackTreeImpl::GetPrev(this)); }
|
||||
constexpr ALWAYS_INLINE const Derived *GetPrev() const { return static_cast<const Derived *>(impl::IntrusiveRedBlackTreeImpl::GetPrev(this)); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue