ams: remove TYPED_STORAGE() macro in favor of template

This commit is contained in:
Michael Scire
2021-03-21 18:47:30 -07:00
parent 8d9174b227
commit aff0da9427
31 changed files with 55 additions and 57 deletions

View File

@@ -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<FileHandleStorage> g_stratosphere_romfs_storage = {};
constinit util::TypedStorage<RomFsFileSystem> g_stratosphere_romfs_fs = {};
Result EnsureStratosphereRomfsMounted() {
std::scoped_lock lk(g_mount_stratosphere_romfs_lock);

View File

@@ -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<mem::StandardAllocator> g_buffer_allocator;
util::TypedStorage<fssrv::MemoryResourceFromStandardAllocator> 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<fssystem::FileSystemBufferManager> 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<fssrv::fscreator::RomFileSystemCreator> g_rom_fs_creator;
util::TypedStorage<fssrv::fscreator::PartitionFileSystemCreator> g_partition_fs_creator;
util::TypedStorage<fssrv::fscreator::StorageOnNcaCreator> g_storage_on_nca_creator;
fssrv::fscreator::FileSystemCreatorInterfaces g_fs_creator_interfaces = {};

View File

@@ -28,7 +28,7 @@ namespace ams::htc::server {
using ServerOptions = sf::hipc::DefaultServerManagerOptions;
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;
constinit TYPED_STORAGE(ServerManager) g_server_manager_storage;
constinit util::TypedStorage<ServerManager> g_server_manager_storage;
constinit ServerManager *g_server_manager = nullptr;
constinit HtcmiscImpl *g_misc_impl = nullptr;

View File

@@ -20,7 +20,7 @@ namespace ams::htcfs {
namespace {
constinit TYPED_STORAGE(Client) g_client_storage;
constinit util::TypedStorage<Client> g_client_storage;
constinit bool g_initialized;
}

View File

@@ -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<ChannelImpl> m_channel_storage[MaxChannelCount];
bool m_storage_valid[MaxChannelCount];
public:
ChannelImplMap(PacketFactory *pf, ctrl::HtcctrlStateMachine *sm, TaskManager *tm, os::Event *ev);

View File

@@ -18,6 +18,6 @@
namespace ams::os::impl {
constinit TYPED_STORAGE(OsResourceManager) ResourceManagerHolder::s_resource_manager_storage = {};
constinit util::TypedStorage<OsResourceManager> ResourceManagerHolder::s_resource_manager_storage = {};
}

View File

@@ -42,7 +42,7 @@ namespace ams::os::impl {
class ResourceManagerHolder {
private:
static TYPED_STORAGE(OsResourceManager) s_resource_manager_storage;
static util::TypedStorage<OsResourceManager> s_resource_manager_storage;
private:
constexpr ResourceManagerHolder() { /* ... */ }
public:

View File

@@ -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<WaitableHolderOfHandle> holder_of_handle_storage;
util::TypedStorage<WaitableHolderOfEvent> holder_of_event_storage;
util::TypedStorage<WaitableHolderOfInterProcessEvent> holder_of_inter_process_event_storage;
util::TypedStorage<WaitableHolderOfInterruptEvent> holder_of_interrupt_event_storage;
util::TypedStorage<WaitableHolderOfTimerEvent> holder_of_timer_event_storage;
util::TypedStorage<WaitableHolderOfThread> holder_of_thread_storage;
util::TypedStorage<WaitableHolderOfSemaphore> holder_of_semaphore_storage;
util::TypedStorage<WaitableHolderOfMessageQueueForNotFull> holder_of_mq_for_not_full_storage;
util::TypedStorage<WaitableHolderOfMessageQueueForNotEmpty> holder_of_mq_for_not_empty_storage;
};
};

View File

@@ -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<lmem::HeapCommonHead> heap_head;
lmem::HeapHandle heap_handle;
pm::ProcessEventInfo event_info_data[QueueCapacity];
TYPED_STORAGE(ShellEventObserverHolder) holder;
util::TypedStorage<ShellEventObserverHolder> holder;
public:
ShellEventObserver();
~ShellEventObserver();

View File

@@ -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<MaxServers>) g_query_server_storage;
util::TypedStorage<sf::hipc::ServerManager<MaxServers>> g_query_server_storage;
}