From aff0da942765a8cb98245fb614f3f88dcef6072f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 21 Mar 2021 18:47:30 -0700 Subject: [PATCH] ams: remove TYPED_STORAGE() macro in favor of template --- .../include/mesosphere/kern_k_code_memory.hpp | 2 +- .../mesosphere/kern_k_transfer_memory.hpp | 2 +- .../ddsf/ddsf_device_code_entry.hpp | 2 +- .../stratosphere/ncm/ncm_install_progress.hpp | 2 +- .../os/impl/os_internal_condition_variable.hpp | 2 +- .../os/impl/os_internal_critical_section.hpp | 2 +- .../stratosphere/os/os_thread_types.hpp | 2 +- .../stratosphere/os/os_timer_event_types.hpp | 2 +- .../stratosphere/powctl/powctl_session_api.hpp | 2 +- .../sf/cmif/sf_cmif_domain_manager.hpp | 4 ++-- .../sf/hipc/sf_hipc_server_manager.hpp | 4 ++-- .../sf/impl/sf_impl_command_serialization.hpp | 2 +- .../libstratosphere/source/fs/fs_code.cpp | 4 ++-- .../fssystem_file_system_proxy_api.cpp | 12 ++++++------ .../htc/server/htc_htcmisc_hipc_server.cpp | 2 +- .../source/htcfs/htcfs_client.cpp | 2 +- .../htclow/mux/htclow_mux_channel_impl_map.hpp | 2 +- .../source/os/impl/os_resource_manager.cpp | 2 +- .../source/os/impl/os_resource_manager.hpp | 2 +- .../source/os/impl/os_waitable_holder_impl.hpp | 18 +++++++++--------- .../pgl/srv/pgl_srv_shell_event_observer.hpp | 4 ++-- .../source/sf/hipc/sf_hipc_mitm_query_api.cpp | 2 +- .../include/vapours/util/util_bounded_map.hpp | 2 +- .../vapours/util/util_intrusive_list.hpp | 4 ++-- .../util/util_intrusive_red_black_tree.hpp | 4 ++-- .../vapours/util/util_parent_of_member.hpp | 4 ++-- .../vapours/util/util_typed_storage.hpp | 12 +++++------- ...dmmc_sdmmc_controller.board.nintendo_nx.hpp | 2 +- .../dmnt/source/cheat/impl/dmnt_cheat_api.cpp | 2 +- .../impl/dmnt_cheat_debug_events_manager.cpp | 2 +- .../pm/source/impl/pm_process_manager.cpp | 2 +- 31 files changed, 55 insertions(+), 57 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_code_memory.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_code_memory.hpp index 6f94c8f2f..0875216ac 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_code_memory.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_code_memory.hpp @@ -23,7 +23,7 @@ namespace ams::kern { class KCodeMemory final : public KAutoObjectWithSlabHeapAndContainer { MESOSPHERE_AUTOOBJECT_TRAITS(KCodeMemory, KAutoObject); private: - TYPED_STORAGE(KPageGroup) m_page_group; + util::TypedStorage m_page_group; KProcess *m_owner; KProcessAddress m_address; KLightLock m_lock; diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_transfer_memory.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_transfer_memory.hpp index 831b35824..0abb0dbce 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_transfer_memory.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_transfer_memory.hpp @@ -23,7 +23,7 @@ namespace ams::kern { class KTransferMemory final : public KAutoObjectWithSlabHeapAndContainer { MESOSPHERE_AUTOOBJECT_TRAITS(KTransferMemory, KAutoObject); private: - TYPED_STORAGE(KPageGroup) m_page_group; + util::TypedStorage m_page_group; KProcess *m_owner; KProcessAddress m_address; KLightLock m_lock; diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp index 376601bbb..2459e394b 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp @@ -49,7 +49,7 @@ namespace ams::ddsf { NON_MOVEABLE(DeviceCodeEntryHolder); private: util::IntrusiveListNode list_node; - TYPED_STORAGE(DeviceCodeEntry) entry_storage; + util::TypedStorage entry_storage; bool is_constructed; public: using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_progress.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_progress.hpp index ba70fe1fc..e91309d24 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_progress.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_progress.hpp @@ -29,7 +29,7 @@ namespace ams::ncm { struct InstallProgress { InstallProgressState state; u8 pad[3]; - TYPED_STORAGE(Result) last_result; + util::TypedStorage last_result; s64 installed_size; s64 total_size; diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp index 33a34a706..2a48e06bf 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp @@ -53,6 +53,6 @@ namespace ams::os::impl { } }; - using InternalConditionVariableStorage = TYPED_STORAGE(InternalConditionVariable); + using InternalConditionVariableStorage = util::TypedStorage; } diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp index d1b0871f6..ed49fbac5 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp @@ -57,6 +57,6 @@ namespace ams::os::impl { } }; - using InternalCriticalSectionStorage = TYPED_STORAGE(InternalCriticalSection); + using InternalCriticalSectionStorage = util::TypedStorage; } diff --git a/libraries/libstratosphere/include/stratosphere/os/os_thread_types.hpp b/libraries/libstratosphere/include/stratosphere/os/os_thread_types.hpp index 08f1f6329..b0ddb9648 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_thread_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_thread_types.hpp @@ -44,7 +44,7 @@ namespace ams::os { State_Terminated = 4, }; - TYPED_STORAGE(util::IntrusiveListNode) all_threads_node; + util::TypedStorage all_threads_node; util::TypedStorage waitlist; uintptr_t reserved[4]; u8 state; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_timer_event_types.hpp b/libraries/libstratosphere/include/stratosphere/os/os_timer_event_types.hpp index 44e465429..975445d78 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_timer_event_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_timer_event_types.hpp @@ -29,7 +29,7 @@ namespace ams::os { } struct TimerEventType { - using TimeSpanStorage = TYPED_STORAGE(TimeSpan); + using TimeSpanStorage = util::TypedStorage; enum State { State_NotInitialized = 0, diff --git a/libraries/libstratosphere/include/stratosphere/powctl/powctl_session_api.hpp b/libraries/libstratosphere/include/stratosphere/powctl/powctl_session_api.hpp index 7c0e3fbd6..495ad9f05 100644 --- a/libraries/libstratosphere/include/stratosphere/powctl/powctl_session_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/powctl/powctl_session_api.hpp @@ -35,7 +35,7 @@ namespace ams::powctl { struct Session { bool has_session; - TYPED_STORAGE(impl::SessionImpl) impl_storage; + util::TypedStorage impl_storage; Session() : has_session(false) { /* ... */ } }; diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp index 99b8e201c..6f3aea555 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp @@ -77,8 +77,8 @@ namespace ams::sf::cmif { virtual ServiceObjectHolder GetObject(DomainObjectId id) override final; }; public: - using DomainEntryStorage = TYPED_STORAGE(Entry); - using DomainStorage = TYPED_STORAGE(Domain); + using DomainEntryStorage = util::TypedStorage; + using DomainStorage = util::TypedStorage; private: class EntryManager { private: diff --git a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp index 19986c90a..d611f5d1b 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp @@ -260,9 +260,9 @@ namespace ams::sf::hipc { private: /* Resource storage. */ os::Mutex resource_mutex; - TYPED_STORAGE(Server) server_storages[MaxServers]; + util::TypedStorage server_storages[MaxServers]; bool server_allocated[MaxServers]; - TYPED_STORAGE(ServerSession) session_storages[MaxSessions]; + util::TypedStorage session_storages[MaxSessions]; bool session_allocated[MaxSessions]; u8 pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)]; u8 saved_message_storage[0x10 + (MaxSessions * hipc::TlsMessageBufferSize)]; diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index 9a0a83e41..f293d15ce 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -684,7 +684,7 @@ namespace ams::sf::impl { private: std::array in_object_holders; std::array out_object_holders; - std::array), NumOutObjects> out_shared_pointers; + std::array>, NumOutObjects> out_shared_pointers; std::array out_object_ids; public: constexpr InOutObjectHolder() : in_object_holders(), out_object_holders() { diff --git a/libraries/libstratosphere/source/fs/fs_code.cpp b/libraries/libstratosphere/source/fs/fs_code.cpp index 0fe32294d..e58acb3e3 100644 --- a/libraries/libstratosphere/source/fs/fs_code.cpp +++ b/libraries/libstratosphere/source/fs/fs_code.cpp @@ -23,8 +23,8 @@ namespace ams::fs { constinit os::SdkMutex g_mount_stratosphere_romfs_lock; constinit bool g_mounted_stratosphere_romfs = false; - constinit TYPED_STORAGE(FileHandleStorage) g_stratosphere_romfs_storage = {}; - constinit TYPED_STORAGE(RomFsFileSystem) g_stratosphere_romfs_fs = {}; + constinit util::TypedStorage g_stratosphere_romfs_storage = {}; + constinit util::TypedStorage g_stratosphere_romfs_fs = {}; Result EnsureStratosphereRomfsMounted() { std::scoped_lock lk(g_mount_stratosphere_romfs_lock); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp b/libraries/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp index 8bc1dd43d..fdb76c479 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_file_system_proxy_api.cpp @@ -68,19 +68,19 @@ namespace ams::fssystem { alignas(os::MemoryPageSize) u8 g_device_buffer[DeviceBufferSize]; alignas(os::MemoryPageSize) u8 g_buffer_pool[BufferPoolSize]; - TYPED_STORAGE(mem::StandardAllocator) g_buffer_allocator; - TYPED_STORAGE(fssrv::MemoryResourceFromStandardAllocator) g_allocator; + util::TypedStorage g_buffer_allocator; + util::TypedStorage g_allocator; /* TODO: Nintendo uses os::SetMemoryHeapSize (svc::SetHeapSize) and os::AllocateMemoryBlock for the BufferManager heap. */ /* It's unclear how we should handle this in ams.mitm (especially hoping to reuse some logic for fs reimpl). */ /* Should we be doing the same(?) */ - TYPED_STORAGE(fssystem::FileSystemBufferManager) g_buffer_manager; + util::TypedStorage g_buffer_manager; alignas(os::MemoryPageSize) u8 g_buffer_manager_heap[BufferManagerHeapSize]; /* FileSystem creators. */ - TYPED_STORAGE(fssrv::fscreator::RomFileSystemCreator) g_rom_fs_creator; - TYPED_STORAGE(fssrv::fscreator::PartitionFileSystemCreator) g_partition_fs_creator; - TYPED_STORAGE(fssrv::fscreator::StorageOnNcaCreator) g_storage_on_nca_creator; + util::TypedStorage g_rom_fs_creator; + util::TypedStorage g_partition_fs_creator; + util::TypedStorage g_storage_on_nca_creator; fssrv::fscreator::FileSystemCreatorInterfaces g_fs_creator_interfaces = {}; diff --git a/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp b/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp index f9ebb2b86..6ee4fda59 100644 --- a/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp +++ b/libraries/libstratosphere/source/htc/server/htc_htcmisc_hipc_server.cpp @@ -28,7 +28,7 @@ namespace ams::htc::server { using ServerOptions = sf::hipc::DefaultServerManagerOptions; using ServerManager = sf::hipc::ServerManager; - constinit TYPED_STORAGE(ServerManager) g_server_manager_storage; + constinit util::TypedStorage g_server_manager_storage; constinit ServerManager *g_server_manager = nullptr; constinit HtcmiscImpl *g_misc_impl = nullptr; diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client.cpp b/libraries/libstratosphere/source/htcfs/htcfs_client.cpp index 27972f265..37a4dc93f 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client.cpp @@ -20,7 +20,7 @@ namespace ams::htcfs { namespace { - constinit TYPED_STORAGE(Client) g_client_storage; + constinit util::TypedStorage g_client_storage; constinit bool g_initialized; } diff --git a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.hpp b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.hpp index dee89de16..a5ac0f30a 100644 --- a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.hpp +++ b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl_map.hpp @@ -35,7 +35,7 @@ namespace ams::htclow::mux { os::Event *m_event; u8 m_map_buffer[MapRequiredMemorySize]; MapType m_map; - TYPED_STORAGE(ChannelImpl) m_channel_storage[MaxChannelCount]; + util::TypedStorage m_channel_storage[MaxChannelCount]; bool m_storage_valid[MaxChannelCount]; public: ChannelImplMap(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm, TaskManager *tm, os::Event *ev); diff --git a/libraries/libstratosphere/source/os/impl/os_resource_manager.cpp b/libraries/libstratosphere/source/os/impl/os_resource_manager.cpp index 6ff528a31..4252a7cb5 100644 --- a/libraries/libstratosphere/source/os/impl/os_resource_manager.cpp +++ b/libraries/libstratosphere/source/os/impl/os_resource_manager.cpp @@ -18,6 +18,6 @@ namespace ams::os::impl { - constinit TYPED_STORAGE(OsResourceManager) ResourceManagerHolder::s_resource_manager_storage = {}; + constinit util::TypedStorage ResourceManagerHolder::s_resource_manager_storage = {}; } diff --git a/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp b/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp index b79babfbf..0845ff3f8 100644 --- a/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp +++ b/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp @@ -42,7 +42,7 @@ namespace ams::os::impl { class ResourceManagerHolder { private: - static TYPED_STORAGE(OsResourceManager) s_resource_manager_storage; + static util::TypedStorage s_resource_manager_storage; private: constexpr ResourceManagerHolder() { /* ... */ } public: diff --git a/libraries/libstratosphere/source/os/impl/os_waitable_holder_impl.hpp b/libraries/libstratosphere/source/os/impl/os_waitable_holder_impl.hpp index 90a3e4631..c47983027 100644 --- a/libraries/libstratosphere/source/os/impl/os_waitable_holder_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_waitable_holder_impl.hpp @@ -27,15 +27,15 @@ namespace ams::os::impl { struct WaitableHolderImpl { union { - TYPED_STORAGE(WaitableHolderOfHandle) holder_of_handle_storage; - TYPED_STORAGE(WaitableHolderOfEvent) holder_of_event_storage; - TYPED_STORAGE(WaitableHolderOfInterProcessEvent) holder_of_inter_process_event_storage; - TYPED_STORAGE(WaitableHolderOfInterruptEvent) holder_of_interrupt_event_storage; - TYPED_STORAGE(WaitableHolderOfTimerEvent) holder_of_timer_event_storage; - TYPED_STORAGE(WaitableHolderOfThread) holder_of_thread_storage; - TYPED_STORAGE(WaitableHolderOfSemaphore) holder_of_semaphore_storage; - TYPED_STORAGE(WaitableHolderOfMessageQueueForNotFull) holder_of_mq_for_not_full_storage; - TYPED_STORAGE(WaitableHolderOfMessageQueueForNotEmpty) holder_of_mq_for_not_empty_storage; + util::TypedStorage holder_of_handle_storage; + util::TypedStorage holder_of_event_storage; + util::TypedStorage holder_of_inter_process_event_storage; + util::TypedStorage holder_of_interrupt_event_storage; + util::TypedStorage holder_of_timer_event_storage; + util::TypedStorage holder_of_thread_storage; + util::TypedStorage holder_of_semaphore_storage; + util::TypedStorage holder_of_mq_for_not_full_storage; + util::TypedStorage holder_of_mq_for_not_empty_storage; }; }; diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp index 7b730589c..71e7e653f 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp @@ -41,10 +41,10 @@ namespace ams::pgl::srv { os::MessageQueue message_queue; uintptr_t queue_buffer[QueueCapacity]; os::SystemEvent event; - TYPED_STORAGE(lmem::HeapCommonHead) heap_head; + util::TypedStorage heap_head; lmem::HeapHandle heap_handle; pm::ProcessEventInfo event_info_data[QueueCapacity]; - TYPED_STORAGE(ShellEventObserverHolder) holder; + util::TypedStorage holder; public: ShellEventObserver(); ~ShellEventObserver(); diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp index e5d3f8a60..c641c6b5c 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp @@ -50,7 +50,7 @@ namespace ams::sf::hipc::impl { constinit os::ThreadType g_query_server_process_thread; constexpr size_t MaxServers = 0; - TYPED_STORAGE(sf::hipc::ServerManager) g_query_server_storage; + util::TypedStorage> g_query_server_storage; } diff --git a/libraries/libvapours/include/vapours/util/util_bounded_map.hpp b/libraries/libvapours/include/vapours/util/util_bounded_map.hpp index 41f7593c0..5d0ab6ee5 100644 --- a/libraries/libvapours/include/vapours/util/util_bounded_map.hpp +++ b/libraries/libvapours/include/vapours/util/util_bounded_map.hpp @@ -25,7 +25,7 @@ namespace ams::util { class BoundedMap { private: std::array, N> keys; - std::array values; + std::array, N> values; private: ALWAYS_INLINE void FreeEntry(size_t i) { this->keys[i].reset(); diff --git a/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp b/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp index 737c9586b..eefe1b7ff 100644 --- a/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp +++ b/libraries/libvapours/include/vapours/util/util_intrusive_list.hpp @@ -569,7 +569,7 @@ namespace ams::util { return util::GetParentReference(&node); } private: - static constexpr TYPED_STORAGE(Derived) DerivedStorage = {}; + static constexpr TypedStorage DerivedStorage = {}; static_assert(std::addressof(GetParent(GetNode(GetReference(DerivedStorage)))) == GetPointer(DerivedStorage)); }; @@ -582,7 +582,7 @@ namespace ams::util { using ListType = IntrusiveList; static constexpr bool IsValid() { - TYPED_STORAGE(Derived) DerivedStorage = {}; + TypedStorage DerivedStorage = {}; return std::addressof(GetParent(GetNode(GetReference(DerivedStorage)))) == GetPointer(DerivedStorage); } private: diff --git a/libraries/libvapours/include/vapours/util/util_intrusive_red_black_tree.hpp b/libraries/libvapours/include/vapours/util/util_intrusive_red_black_tree.hpp index 192c8bd79..f43b2fc0b 100644 --- a/libraries/libvapours/include/vapours/util/util_intrusive_red_black_tree.hpp +++ b/libraries/libvapours/include/vapours/util/util_intrusive_red_black_tree.hpp @@ -498,7 +498,7 @@ namespace ams::util { return util::GetParentPointer(node); } private: - static constexpr TYPED_STORAGE(Derived) DerivedStorage = {}; + static constexpr TypedStorage DerivedStorage = {}; static_assert(GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage)); }; @@ -513,7 +513,7 @@ namespace ams::util { using TreeTypeImpl = impl::IntrusiveRedBlackTreeImpl; static constexpr bool IsValid() { - TYPED_STORAGE(Derived) DerivedStorage = {}; + TypedStorage DerivedStorage = {}; return GetParent(GetNode(GetPointer(DerivedStorage))) == GetPointer(DerivedStorage); } private: diff --git a/libraries/libvapours/include/vapours/util/util_parent_of_member.hpp b/libraries/libvapours/include/vapours/util/util_parent_of_member.hpp index a1600680d..19b364785 100644 --- a/libraries/libvapours/include/vapours/util/util_parent_of_member.hpp +++ b/libraries/libvapours/include/vapours/util/util_parent_of_member.hpp @@ -63,7 +63,7 @@ namespace ams::util { union Union { char c; UnionHolder first_union; - TYPED_STORAGE(ParentType) parent; + TypedStorage parent; /* This coerces the active member to be c. */ constexpr Union() : c() { /* ... */ } @@ -110,7 +110,7 @@ namespace ams::util { template struct OffsetOfCalculator { static constexpr std::ptrdiff_t OffsetOf(MemberType ParentType::*member) { - constexpr TYPED_STORAGE(ParentType) Holder = {}; + constexpr TypedStorage Holder = {}; const auto *parent = GetPointer(Holder); const auto *target = std::addressof(parent->*member); return static_cast(static_cast(target)) - static_cast(static_cast(parent)); diff --git a/libraries/libvapours/include/vapours/util/util_typed_storage.hpp b/libraries/libvapours/include/vapours/util/util_typed_storage.hpp index de1db3f80..cfbb9505d 100644 --- a/libraries/libvapours/include/vapours/util/util_typed_storage.hpp +++ b/libraries/libvapours/include/vapours/util/util_typed_storage.hpp @@ -20,30 +20,28 @@ namespace ams::util { - template + template struct TypedStorage { typename std::aligned_storage::type _storage; }; - #define TYPED_STORAGE(...) ::ams::util::TypedStorage<__VA_ARGS__, sizeof(__VA_ARGS__), alignof(__VA_ARGS__)> - template - static constexpr ALWAYS_INLINE T *GetPointer(TYPED_STORAGE(T) &ts) { + static constexpr ALWAYS_INLINE T *GetPointer(TypedStorage &ts) { return static_cast(static_cast(std::addressof(ts._storage))); } template - static constexpr ALWAYS_INLINE const T *GetPointer(const TYPED_STORAGE(T) &ts) { + static constexpr ALWAYS_INLINE const T *GetPointer(const TypedStorage &ts) { return static_cast(static_cast(std::addressof(ts._storage))); } template - static constexpr ALWAYS_INLINE T &GetReference(TYPED_STORAGE(T) &ts) { + static constexpr ALWAYS_INLINE T &GetReference(TypedStorage &ts) { return *GetPointer(ts); } template - static constexpr ALWAYS_INLINE const T &GetReference(const TYPED_STORAGE(T) &ts) { + static constexpr ALWAYS_INLINE const T &GetReference(const TypedStorage &ts) { return *GetPointer(ts); } diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.hpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.hpp index d007d9dd0..d731842fc 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.hpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_sdmmc_controller.board.nintendo_nx.hpp @@ -237,7 +237,7 @@ namespace ams::sdmmc::impl { #if defined(AMS_SDMMC_USE_PCV_CLOCK_RESET_CONTROL) bool is_pcv_control; #endif - TYPED_STORAGE(PowerController) power_controller_storage; + util::TypedStorage power_controller_storage; PowerController *power_controller; private: Result PowerOnForRegisterControl(BusPower bus_power); diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp index 79f3a8b84..5fda294ae 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp @@ -1148,7 +1148,7 @@ namespace ams::dmnt::cheat::impl { /* Manager global. */ - TYPED_STORAGE(CheatProcessManager) g_cheat_process_manager; + util::TypedStorage g_cheat_process_manager; } diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp index 5da5d609d..07df7f143 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp @@ -143,7 +143,7 @@ namespace ams::dmnt::cheat::impl { }; /* Manager global. */ - TYPED_STORAGE(DebugEventsManager) g_events_manager; + util::TypedStorage g_events_manager; } diff --git a/stratosphere/pm/source/impl/pm_process_manager.cpp b/stratosphere/pm/source/impl/pm_process_manager.cpp index 200dfd4bf..5cc2c09c4 100644 --- a/stratosphere/pm/source/impl/pm_process_manager.cpp +++ b/stratosphere/pm/source/impl/pm_process_manager.cpp @@ -78,7 +78,7 @@ namespace ams::pm::impl { NON_MOVEABLE(ProcessInfoAllocator); static_assert(MaxProcessInfos >= 0x40, "MaxProcessInfos is too small."); private: - TYPED_STORAGE(ProcessInfo) process_info_storages[MaxProcessInfos]; + util::TypedStorage process_info_storages[MaxProcessInfos]; bool process_info_allocated[MaxProcessInfos]; os::Mutex lock; private: