summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2021-01-11 17:59:02 -0500
committerGravatar Lioncash2021-01-11 18:26:04 -0500
commit703c57a119d5ae48eb0d463b0f6d3f607931b300 (patch)
tree00a028d13aa7cdbe60c9c7145b7fdadb2a8765d2 /src
parentMerge pull request #5266 from bunnei/kernel-synch (diff)
downloadyuzu-703c57a119d5ae48eb0d463b0f6d3f607931b300.tar.gz
yuzu-703c57a119d5ae48eb0d463b0f6d3f607931b300.tar.xz
yuzu-703c57a119d5ae48eb0d463b0f6d3f607931b300.zip
common/parent_of_member: Replace TYPED_STORAGE define with template alias
Provides the same construct, but makes it obey namespacing.
Diffstat (limited to 'src')
-rw-r--r--src/common/intrusive_red_black_tree.h4
-rw-r--r--src/common/parent_of_member.h14
2 files changed, 10 insertions, 8 deletions
diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h
index 929b5497e..fb55de94e 100644
--- a/src/common/intrusive_red_black_tree.h
+++ b/src/common/intrusive_red_black_tree.h
@@ -533,7 +533,7 @@ private:
533 } 533 }
534 534
535private: 535private:
536 static constexpr TYPED_STORAGE(Derived) DerivedStorage = {}; 536 static constexpr TypedStorage<Derived> DerivedStorage = {};
537 static_assert(GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage)); 537 static_assert(GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage));
538}; 538};
539 539
@@ -549,7 +549,7 @@ public:
549 using TreeTypeImpl = impl::IntrusiveRedBlackTreeImpl; 549 using TreeTypeImpl = impl::IntrusiveRedBlackTreeImpl;
550 550
551 static constexpr bool IsValid() { 551 static constexpr bool IsValid() {
552 TYPED_STORAGE(Derived) DerivedStorage = {}; 552 TypedStorage<Derived> DerivedStorage = {};
553 return GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage); 553 return GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage);
554 } 554 }
555 555
diff --git a/src/common/parent_of_member.h b/src/common/parent_of_member.h
index 1af31ee44..d9a14529d 100644
--- a/src/common/parent_of_member.h
+++ b/src/common/parent_of_member.h
@@ -10,21 +10,23 @@
10#include "common/common_types.h" 10#include "common/common_types.h"
11 11
12namespace Common { 12namespace Common {
13 13namespace detail {
14template <typename T, size_t Size, size_t Align> 14template <typename T, size_t Size, size_t Align>
15struct TypedStorage { 15struct TypedStorageImpl {
16 std::aligned_storage_t<Size, Align> storage_; 16 std::aligned_storage_t<Size, Align> storage_;
17}; 17};
18} // namespace detail
18 19
19#define TYPED_STORAGE(...) TypedStorage<__VA_ARGS__, sizeof(__VA_ARGS__), alignof(__VA_ARGS__)> 20template <typename T>
21using TypedStorage = detail::TypedStorageImpl<T, sizeof(T), alignof(T)>;
20 22
21template <typename T> 23template <typename T>
22static constexpr T* GetPointer(TYPED_STORAGE(T) & ts) { 24static constexpr T* GetPointer(TypedStorage<T>& ts) {
23 return static_cast<T*>(static_cast<void*>(std::addressof(ts.storage_))); 25 return static_cast<T*>(static_cast<void*>(std::addressof(ts.storage_)));
24} 26}
25 27
26template <typename T> 28template <typename T>
27static constexpr const T* GetPointer(const TYPED_STORAGE(T) & ts) { 29static constexpr const T* GetPointer(const TypedStorage<T>& ts) {
28 return static_cast<const T*>(static_cast<const void*>(std::addressof(ts.storage_))); 30 return static_cast<const T*>(static_cast<const void*>(std::addressof(ts.storage_)));
29} 31}
30 32
@@ -72,7 +74,7 @@ struct OffsetOfCalculator {
72 union Union { 74 union Union {
73 char c{}; 75 char c{};
74 UnionHolder first_union; 76 UnionHolder first_union;
75 TYPED_STORAGE(ParentType) parent; 77 TypedStorage<ParentType> parent;
76 78
77 constexpr Union() : c() {} 79 constexpr Union() : c() {}
78 }; 80 };