mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-03 11:11:14 +00:00
util::IntrusiveList: assert member referencing is correct
This commit is contained in:
parent
0751db5d12
commit
769a57526c
4 changed files with 11 additions and 5 deletions
|
@ -22,11 +22,11 @@ namespace ams::os::impl {
|
||||||
class WaitableManagerImpl;
|
class WaitableManagerImpl;
|
||||||
|
|
||||||
class WaitableHolderBase {
|
class WaitableHolderBase {
|
||||||
|
private:
|
||||||
|
WaitableManagerImpl *manager = nullptr;
|
||||||
public:
|
public:
|
||||||
util::IntrusiveListNode manager_node;
|
util::IntrusiveListNode manager_node;
|
||||||
util::IntrusiveListNode object_list_node;
|
util::IntrusiveListNode object_list_node;
|
||||||
private:
|
|
||||||
WaitableManagerImpl *manager = nullptr;
|
|
||||||
public:
|
public:
|
||||||
/* Gets whether the held waitable is currently signaled. */
|
/* Gets whether the held waitable is currently signaled. */
|
||||||
virtual TriBool IsSignaled() const = 0;
|
virtual TriBool IsSignaled() const = 0;
|
||||||
|
|
|
@ -561,6 +561,9 @@ namespace ams::util {
|
||||||
static constexpr Derived const &GetParent(IntrusiveListNode const &node) {
|
static constexpr Derived const &GetParent(IntrusiveListNode const &node) {
|
||||||
return util::GetParentReference<Member, Derived>(&node);
|
return util::GetParentReference<Member, Derived>(&node);
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
static constexpr TYPED_STORAGE(Derived) DerivedStorage = {};
|
||||||
|
static_assert(std::addressof(GetParent(GetNode(GetReference(DerivedStorage)))) == GetPointer(DerivedStorage));
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Derived>
|
template<class Derived>
|
||||||
|
|
|
@ -250,11 +250,11 @@ namespace ams::util {
|
||||||
friend class IntrusiveRedBlackTree;
|
friend class IntrusiveRedBlackTree;
|
||||||
|
|
||||||
static constexpr IntrusiveRedBlackTreeNode *GetNode(Derived *parent) {
|
static constexpr IntrusiveRedBlackTreeNode *GetNode(Derived *parent) {
|
||||||
return &(parent->*Member);
|
return std::addressof(parent->*Member);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr IntrusiveRedBlackTreeNode const *GetNode(Derived const *parent) {
|
static constexpr IntrusiveRedBlackTreeNode const *GetNode(Derived const *parent) {
|
||||||
return &(parent->*Member);
|
return std::addressof(parent->*Member);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr Derived *GetParent(IntrusiveRedBlackTreeNode *node) {
|
static constexpr Derived *GetParent(IntrusiveRedBlackTreeNode *node) {
|
||||||
|
@ -264,6 +264,9 @@ namespace ams::util {
|
||||||
static constexpr Derived const *GetParent(IntrusiveRedBlackTreeNode const *node) {
|
static constexpr Derived const *GetParent(IntrusiveRedBlackTreeNode const *node) {
|
||||||
return util::GetParentPointer<Member, Derived>(node);
|
return util::GetParentPointer<Member, Derived>(node);
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
static constexpr TYPED_STORAGE(Derived) DerivedStorage = {};
|
||||||
|
static_assert(std::addressof(GetParent(GetNode(GetPointer(DerivedStorage)))) == GetPointer(DerivedStorage));
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Derived>
|
template<class Derived>
|
||||||
|
|
|
@ -169,7 +169,7 @@ namespace ams::util {
|
||||||
|
|
||||||
/* Defines, for use by other code. */
|
/* Defines, for use by other code. */
|
||||||
|
|
||||||
#define OFFSETOF(parent, member) (::ams::util::OffsetOf<&parent::member, parent>)
|
#define OFFSETOF(parent, member) (::ams::util::impl::OffsetOf<&parent::member, parent>)
|
||||||
|
|
||||||
#define GET_PARENT_PTR(parent, member, _arg) (::ams::util::GetParentPointer<&parent::member, parent>(_arg))
|
#define GET_PARENT_PTR(parent, member, _arg) (::ams::util::GetParentPointer<&parent::member, parent>(_arg))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue