diff --git a/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp b/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp index 3d8f44ec..732c9299 100644 --- a/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp +++ b/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp @@ -92,9 +92,9 @@ namespace ams::fs { FileHandle handle; bool close_file; s64 size; - os::Mutex mutex; + os::SdkMutex mutex; public: - constexpr explicit FileHandleStorage(FileHandle handle, bool close_file) : handle(handle), close_file(close_file), size(InvalidSize), mutex(false) { /* ... */ } + constexpr explicit FileHandleStorage(FileHandle handle, bool close_file) : handle(handle), close_file(close_file), size(InvalidSize), mutex() { /* ... */ } constexpr explicit FileHandleStorage(FileHandle handle) : FileHandleStorage(handle, false) { /* ... */ } virtual ~FileHandleStorage() override { diff --git a/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp b/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp index 08540f29..99fdda7f 100644 --- a/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp +++ b/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp @@ -42,11 +42,11 @@ namespace ams::fssrv { class PeakCheckableMemoryResourceFromExpHeap : public ams::MemoryResource { private: lmem::HeapHandle heap_handle; - os::Mutex mutex; + os::SdkMutex mutex; size_t peak_free_size; size_t current_free_size; public: - constexpr explicit PeakCheckableMemoryResourceFromExpHeap(size_t heap_size) : heap_handle(nullptr), mutex(false), peak_free_size(heap_size), current_free_size(heap_size) { /* ... */ } + constexpr explicit PeakCheckableMemoryResourceFromExpHeap(size_t heap_size) : heap_handle(nullptr), mutex(), peak_free_size(heap_size), current_free_size(heap_size) { /* ... */ } void SetHeapHandle(lmem::HeapHandle handle) { this->heap_handle = handle; @@ -57,7 +57,7 @@ namespace ams::fssrv { void ClearPeak() { this->peak_free_size = this->current_free_size; } - std::scoped_lock GetScopedLock() { + std::scoped_lock GetScopedLock() { return std::scoped_lock(this->mutex); } diff --git a/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp b/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp index e6c37b66..fcd84abe 100644 --- a/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp +++ b/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp @@ -192,7 +192,7 @@ namespace ams::fssystem { size_t peak_free_size; size_t peak_total_allocatable_size; size_t retried_count; - mutable os::Mutex mutex; + mutable os::SdkRecursiveMutex mutex; public: static constexpr size_t QueryWorkBufferSize(s32 max_cache_count, s32 max_order) { const auto buddy_size = FileSystemBuddyHeap::QueryWorkBufferSize(max_order); @@ -200,7 +200,7 @@ namespace ams::fssystem { return buddy_size + table_size; } public: - FileSystemBufferManager() : total_size(), peak_free_size(), peak_total_allocatable_size(), retried_count(), mutex(true) { /* ... */ } + FileSystemBufferManager() : total_size(), peak_free_size(), peak_total_allocatable_size(), retried_count(), mutex() { /* ... */ } virtual ~FileSystemBufferManager() { /* ... */ } diff --git a/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp b/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp index f0780a2a..9292339e 100644 --- a/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp +++ b/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp @@ -33,7 +33,7 @@ namespace ams::fssystem { char key[2][KeySize]; char iv[IvSize]; const size_t block_size; - os::Mutex mutex; + os::SdkMutex mutex; public: AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size); diff --git a/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp b/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp index 281b4b99..0bc6645d 100644 --- a/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp +++ b/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp @@ -34,7 +34,7 @@ namespace ams::fssystem { virtual ~DirectoryRedirectionFileSystem(); protected: - inline util::optional> GetAccessorLock() const { + inline util::optional> GetAccessorLock() const { /* No accessor lock is needed. */ return util::nullopt; } diff --git a/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp b/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp index 026b2d93..54ccfba3 100644 --- a/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp +++ b/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp @@ -24,7 +24,7 @@ namespace ams::fssystem { using PathResolutionFileSystem = impl::IPathResolutionFileSystem; friend class impl::IPathResolutionFileSystem; private: - os::Mutex accessor_mutex; + os::SdkMutex accessor_mutex; s32 open_writable_files; public: DirectorySaveDataFileSystem(std::shared_ptr fs); @@ -33,9 +33,9 @@ namespace ams::fssystem { virtual ~DirectorySaveDataFileSystem(); protected: - inline util::optional> GetAccessorLock() { + inline util::optional> GetAccessorLock() { /* We have a real accessor lock that we want to use. */ - return util::make_optional>(this->accessor_mutex); + return util::make_optional>(this->accessor_mutex); } private: Result AllocateWorkBuffer(std::unique_ptr *out, size_t *out_size, size_t ideal_size); diff --git a/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp b/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp index fdc9d15b..8c0414a2 100644 --- a/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp +++ b/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp @@ -30,11 +30,11 @@ namespace ams::fssystem { private: save::HierarchicalIntegrityVerificationStorage integrity_storage; save::FileSystemBufferManagerSet buffers; - os::Mutex mutex; + os::SdkRecursiveMutex mutex; Hash master_hash; std::unique_ptr master_hash_storage; public: - IntegrityRomFsStorage() : mutex(true) { /* ... */ } + IntegrityRomFsStorage() : mutex() { /* ... */ } virtual ~IntegrityRomFsStorage() override { this->Finalize(); } Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, IBufferManager *bm); diff --git a/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp b/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp index e30e74db..61ac5dd3 100644 --- a/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp +++ b/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp @@ -32,7 +32,7 @@ namespace ams::fssystem { virtual ~SubDirectoryFileSystem(); protected: - inline util::optional> GetAccessorLock() const { + inline util::optional> GetAccessorLock() const { /* No accessor lock is needed. */ return util::nullopt; } diff --git a/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp b/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp index b93ca024..38728042 100644 --- a/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp +++ b/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp @@ -62,7 +62,7 @@ namespace ams::fssystem::save { }; private: IBufferManager *buffer_manager; - os::Mutex *mutex; + os::SdkRecursiveMutex *mutex; std::unique_ptr entries; IStorage *data_storage; Result last_result; @@ -78,7 +78,7 @@ namespace ams::fssystem::save { BlockCacheBufferedStorage(); virtual ~BlockCacheBufferedStorage() override; - Result Initialize(IBufferManager *bm, os::Mutex *mtx, IStorage *data, s64 data_size, size_t verif_block_size, s32 max_cache_entries, bool is_real_data, s8 buffer_level, bool is_keep_burst_mode, fs::StorageType storage_type); + Result Initialize(IBufferManager *bm, os::SdkRecursiveMutex *mtx, IStorage *data, s64 data_size, size_t verif_block_size, s32 max_cache_entries, bool is_real_data, s8 buffer_level, bool is_keep_burst_mode, fs::StorageType storage_type); void Finalize(); virtual Result Read(s64 offset, void *buffer, size_t size) override; diff --git a/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp b/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp index eb30a8a7..8c5ca9db 100644 --- a/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp +++ b/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp @@ -38,7 +38,7 @@ namespace ams::fssystem::save { s32 cache_count; Cache *next_acquire_cache; Cache *next_fetch_cache; - os::Mutex mutex; + os::SdkMutex mutex; bool bulk_read_enabled; public: BufferedStorage(); diff --git a/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp b/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp index 1283a2ac..23b34901 100644 --- a/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp +++ b/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp @@ -147,7 +147,7 @@ namespace ams::fssystem::save { } private: FileSystemBufferManagerSet *buffers; - os::Mutex *mutex; + os::SdkRecursiveMutex *mutex; IntegrityVerificationStorage verify_storages[MaxLayers - 1]; BlockCacheBufferedStorage buffer_storages[MaxLayers - 1]; s64 data_size; @@ -157,7 +157,7 @@ namespace ams::fssystem::save { HierarchicalIntegrityVerificationStorage() : buffers(nullptr), mutex(nullptr), data_size(-1), is_written_for_rollback(false) { /* ... */ } virtual ~HierarchicalIntegrityVerificationStorage() override { this->Finalize(); } - Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::Mutex *mtx, fs::StorageType storage_type); + Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::SdkRecursiveMutex *mtx, fs::StorageType storage_type); void Finalize(); virtual Result Read(s64 offset, void *buffer, size_t size) override; diff --git a/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp index 707968e7..537a1fc9 100644 --- a/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ b/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp @@ -63,14 +63,14 @@ namespace ams::kvdb { bool Contains(const void *key, size_t key_size); }; private: - os::Mutex lock; + os::SdkMutex lock; Path dir_path; Cache cache; private: Path GetPath(const void *key, size_t key_size); Result GetKey(size_t *out_size, void *out_key, size_t max_out_size, const FileName &file_name); public: - FileKeyValueStore() : lock(false) { /* ... */ } + FileKeyValueStore() : lock() { /* ... */ } /* Basic accessors. */ Result Initialize(const char *dir); diff --git a/libstratosphere/include/stratosphere/lmem/impl/lmem_impl_common.hpp b/libstratosphere/include/stratosphere/lmem/impl/lmem_impl_common.hpp index 4cc2240a..3009fa42 100644 --- a/libstratosphere/include/stratosphere/lmem/impl/lmem_impl_common.hpp +++ b/libstratosphere/include/stratosphere/lmem/impl/lmem_impl_common.hpp @@ -85,7 +85,7 @@ namespace ams::lmem::impl { void *heap_start; void *heap_end; - os::MutexType mutex; + os::SdkMutexType mutex; u8 option; ImplementationHeapHead impl_head; }; diff --git a/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp b/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp index 0d9f57ac..0405114f 100644 --- a/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp +++ b/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp @@ -28,7 +28,7 @@ namespace ams::lr { sf::SharedPointer registered_location_resolver = nullptr; sf::SharedPointer add_on_content_location_resolver = nullptr; - os::Mutex mutex{false}; + os::SdkMutex mutex{}; public: /* Actual commands. */ Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id); diff --git a/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp b/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp index a0e25cf9..b52f9b86 100644 --- a/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -102,7 +102,7 @@ namespace ams::ncm { ContentMetaDatabaseRoot() { /* ... */ } }; private: - os::Mutex mutex; + os::SdkRecursiveMutex mutex; bool initialized; ContentStorageRoot content_storage_roots[MaxContentStorageRoots]; ContentMetaDatabaseRoot content_meta_database_roots[MaxContentMetaDatabaseRoots]; @@ -111,8 +111,8 @@ namespace ams::ncm { RightsIdCache rights_id_cache; RegisteredHostContent registered_host_content; public: - ContentManagerImpl() : mutex(true), initialized(false), num_content_storage_entries(0), num_content_meta_entries(0), rights_id_cache(), registered_host_content() { - /* ... */ + ContentManagerImpl() : mutex(), initialized(false), num_content_storage_entries(0), num_content_meta_entries(0), rights_id_cache(), registered_host_content() { + /* ... */ }; ~ContentManagerImpl(); public: diff --git a/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp b/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp index 3e72ff48..936d28ac 100644 --- a/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp +++ b/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp @@ -86,13 +86,13 @@ namespace ams::ncm { StorageId install_storage; InstallTaskDataBase *data; InstallProgress progress; - os::Mutex progress_mutex; + os::SdkMutex progress_mutex; u32 config; - os::Mutex cancel_mutex; + os::SdkMutex cancel_mutex; bool cancel_requested; InstallThroughput throughput; TimeSpan throughput_start_time; - os::Mutex throughput_mutex; + os::SdkMutex throughput_mutex; FirmwareVariationId firmware_variation_id; private: ALWAYS_INLINE Result SetLastResultOnFailure(Result result) { @@ -102,7 +102,7 @@ namespace ams::ncm { return result; } public: - InstallTaskBase() : data(), progress(), progress_mutex(false), cancel_mutex(false), cancel_requested(), throughput_mutex(false) { /* ... */ } + InstallTaskBase() : data(), progress(), progress_mutex(), cancel_mutex(), cancel_requested(), throughput_mutex() { /* ... */ } virtual ~InstallTaskBase() { /* ... */ }; public: virtual void Cancel(); diff --git a/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp b/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp index a825fb17..9a1f1a98 100644 --- a/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp +++ b/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp @@ -40,13 +40,13 @@ namespace ams::ncm { class HeapState { private: - os::Mutex mutex; + os::SdkMutex mutex; lmem::HeapHandle heap_handle; size_t total_alloc_size; size_t peak_total_alloc_size; size_t peak_alloc_size; public: - constexpr HeapState() : mutex(false), heap_handle(nullptr), total_alloc_size(0), peak_total_alloc_size(0), peak_alloc_size(0) { /* ... */ } + constexpr HeapState() : mutex(), heap_handle(nullptr), total_alloc_size(0), peak_total_alloc_size(0), peak_alloc_size(0) { /* ... */ } void Initialize(lmem::HeapHandle heap_handle); void Allocate(size_t size); diff --git a/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp b/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp index e59d54ca..e2b8e624 100644 --- a/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp +++ b/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp @@ -84,7 +84,7 @@ namespace ams::sf::cmif { private: using EntryList = typename util::IntrusiveListMemberTraits<&Entry::free_list_node>::ListType; private: - os::Mutex lock; + os::SdkMutex lock; EntryList free_list; Entry *entries; size_t num_entries; @@ -114,13 +114,13 @@ namespace ams::sf::cmif { } }; private: - os::Mutex entry_owner_lock; + os::SdkMutex entry_owner_lock; EntryManager entry_manager; private: virtual void *AllocateDomain() = 0; virtual void FreeDomain(void *) = 0; protected: - ServerDomainManager(DomainEntryStorage *entry_storage, size_t entry_count) : entry_owner_lock(false), entry_manager(entry_storage, entry_count) { /* ... */ } + ServerDomainManager(DomainEntryStorage *entry_storage, size_t entry_count) : entry_owner_lock(), entry_manager(entry_storage, entry_count) { /* ... */ } inline DomainServiceObject *AllocateDomainServiceObject() { void *storage = this->AllocateDomain(); diff --git a/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp b/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp index d611f5d1..0f1b2e4a 100644 --- a/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp +++ b/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp @@ -80,9 +80,9 @@ namespace ams::sf::hipc { os::Event notify_event; os::WaitableHolderType notify_event_holder; - os::Mutex waitable_selection_mutex; + os::SdkMutex waitable_selection_mutex; - os::Mutex waitlist_mutex; + os::SdkMutex waitlist_mutex; os::WaitableManagerType waitlist; private: virtual void RegisterSessionToWaitList(ServerSession *session) override final; @@ -192,7 +192,7 @@ namespace ams::sf::hipc { ServerManagerBase(DomainEntryStorage *entry_storage, size_t entry_count) : ServerDomainSessionManager(entry_storage, entry_count), request_stop_event(os::EventClearMode_ManualClear), notify_event(os::EventClearMode_ManualClear), - waitable_selection_mutex(false), waitlist_mutex(false) + waitable_selection_mutex(), waitlist_mutex() { /* Link waitables. */ os::InitializeWaitableManager(std::addressof(this->waitable_manager)); @@ -259,7 +259,7 @@ namespace ams::sf::hipc { using ServerManagerBase::DomainStorage; private: /* Resource storage. */ - os::Mutex resource_mutex; + os::SdkMutex resource_mutex; util::TypedStorage server_storages[MaxServers]; bool server_allocated[MaxServers]; util::TypedStorage session_storages[MaxSessions]; @@ -370,7 +370,7 @@ namespace ams::sf::hipc { return this->GetObjectBySessionIndex(session, this->saved_messages_start, hipc::TlsMessageBufferSize); } public: - ServerManager() : ServerManagerBase(this->domain_entry_storages, ManagerOptions::MaxDomainObjects), resource_mutex(false) { + ServerManager() : ServerManagerBase(this->domain_entry_storages, ManagerOptions::MaxDomainObjects), resource_mutex() { /* Clear storages. */ #define SF_SM_MEMCLEAR(obj) if constexpr (sizeof(obj) > 0) { std::memset(obj, 0, sizeof(obj)); } SF_SM_MEMCLEAR(this->server_storages); diff --git a/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp b/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp index 05c9b418..33df54dc 100644 --- a/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp +++ b/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp @@ -355,7 +355,7 @@ namespace ams::tipc { using PortAllocatorTuple = std::tuple; private: - os::Mutex m_mutex; + os::SdkRecursiveMutex m_mutex; os::TlsSlot m_tls_slot; PortManagerTuple m_port_managers; PortAllocatorTuple m_port_allocators; @@ -390,11 +390,11 @@ namespace ams::tipc { os::StartThread(m_port_threads + Ix); } public: - ServerManagerImpl() : m_mutex(true), m_tls_slot(), m_port_managers(), m_port_allocators() { /* ... */ } + ServerManagerImpl() : m_mutex(), m_tls_slot(), m_port_managers(), m_port_allocators() { /* ... */ } os::TlsSlot GetTlsSlot() const { return m_tls_slot; } - os::Mutex &GetMutex() { return m_mutex; } + os::SdkRecursiveMutex &GetMutex() { return m_mutex; } void Initialize() { /* Initialize our tls slot. */ diff --git a/libstratosphere/source/cfg/cfg_privileged_process.cpp b/libstratosphere/source/cfg/cfg_privileged_process.cpp index 0fe262a8..a517b24f 100644 --- a/libstratosphere/source/cfg/cfg_privileged_process.cpp +++ b/libstratosphere/source/cfg/cfg_privileged_process.cpp @@ -24,10 +24,10 @@ namespace ams::cfg { constexpr os::ProcessId InitialProcessIdMaxDeprecated = {0x50}; /* Privileged process globals. */ - os::Mutex g_lock(false); - bool g_got_privileged_process_status = false; - os::ProcessId g_min_initial_process_id = os::InvalidProcessId, g_max_initial_process_id = os::InvalidProcessId; - os::ProcessId g_cur_process_id = os::InvalidProcessId; + constinit os::SdkMutex g_lock; + constinit bool g_got_privileged_process_status = false; + constinit os::ProcessId g_min_initial_process_id = os::InvalidProcessId, g_max_initial_process_id = os::InvalidProcessId; + constinit os::ProcessId g_cur_process_id = os::InvalidProcessId; /* SD card helpers. */ void GetPrivilegedProcessIdRange(os::ProcessId *out_min, os::ProcessId *out_max) { diff --git a/libstratosphere/source/cfg/cfg_sd_card.cpp b/libstratosphere/source/cfg/cfg_sd_card.cpp index cbf60a72..84a96c77 100644 --- a/libstratosphere/source/cfg/cfg_sd_card.cpp +++ b/libstratosphere/source/cfg/cfg_sd_card.cpp @@ -29,9 +29,9 @@ namespace ams::cfg { constexpr size_t NumRequiredServicesForSdCardAccess = util::size(RequiredServicesForSdCardAccess); /* SD card globals. */ - os::Mutex g_sd_card_lock(false); - bool g_sd_card_initialized = false; - FsFileSystem g_sd_card_filesystem = {}; + constinit os::SdkMutex g_sd_card_lock; + constinit bool g_sd_card_initialized = false; + constinit FsFileSystem g_sd_card_filesystem = {}; /* SD card helpers. */ Result CheckSdCardServicesReady() { diff --git a/libstratosphere/source/diag/diag_assertion_impl.cpp b/libstratosphere/source/diag/diag_assertion_impl.cpp index 77e41c0b..d075194a 100644 --- a/libstratosphere/source/diag/diag_assertion_impl.cpp +++ b/libstratosphere/source/diag/diag_assertion_impl.cpp @@ -44,8 +44,8 @@ namespace ams::diag { inline void DebugLog(const char *format, ...) __attribute__((format(printf, 1, 2))); #ifdef AMS_ENABLE_DETAILED_ASSERTIONS - os::Mutex g_debug_log_lock(true); - char g_debug_buffer[0x400]; + constinit os::SdkRecursiveMutex g_debug_log_lock; + constinit char g_debug_buffer[0x400]; void DebugLogImpl(const char *format, ::std::va_list vl) { std::scoped_lock lk(g_debug_log_lock); diff --git a/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp b/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp index 10b2e3ec..28fd3cea 100644 --- a/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp +++ b/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp @@ -60,7 +60,7 @@ namespace ams::fs::impl { } FileSystemAccessor::FileSystemAccessor(const char *n, std::unique_ptr &&fs, std::unique_ptr &&generator) - : impl(std::move(fs)), open_list_lock(false), mount_name_generator(std::move(generator)), + : impl(std::move(fs)), open_list_lock(), mount_name_generator(std::move(generator)), access_log_enabled(false), data_cache_attachable(false), path_cache_attachable(false), path_cache_attached(false), multi_commit_supported(false) { R_ABORT_UNLESS(ValidateMountName(n)); diff --git a/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp b/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp index 856059c1..4e20419b 100644 --- a/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp +++ b/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp @@ -35,7 +35,7 @@ namespace ams::fs::impl { std::unique_ptr impl; FileList open_file_list; DirList open_dir_list; - os::Mutex open_list_lock; + os::SdkMutex open_list_lock; std::unique_ptr mount_name_generator; bool access_log_enabled; bool data_cache_attachable; diff --git a/libstratosphere/source/fs/fsa/fs_mount_table.hpp b/libstratosphere/source/fs/fsa/fs_mount_table.hpp index e0034588..59fe63b2 100644 --- a/libstratosphere/source/fs/fsa/fs_mount_table.hpp +++ b/libstratosphere/source/fs/fsa/fs_mount_table.hpp @@ -26,9 +26,9 @@ namespace ams::fs::impl { using FileSystemList = util::IntrusiveListBaseTraits::ListType; private: FileSystemList fs_list; - os::Mutex mutex; + os::SdkMutex mutex; public: - constexpr MountTable() : fs_list(), mutex(false) { /* ... */ } + constexpr MountTable() : fs_list(), mutex() { /* ... */ } private: bool CanAcceptMountName(const char *name); public: diff --git a/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp b/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp index 959725bd..db19eceb 100644 --- a/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp +++ b/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp @@ -17,7 +17,7 @@ namespace ams::fssystem { - AesXtsStorage::AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size) : base_storage(base), block_size(block_size), mutex(false) { + AesXtsStorage::AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size) : base_storage(base), block_size(block_size), mutex() { AMS_ASSERT(base != nullptr); AMS_ASSERT(key1 != nullptr); AMS_ASSERT(key2 != nullptr); diff --git a/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index 8f60adee..5f00412b 100644 --- a/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp @@ -74,13 +74,13 @@ namespace ams::fssystem { } DirectorySaveDataFileSystem::DirectorySaveDataFileSystem(std::shared_ptr fs) - : PathResolutionFileSystem(fs), accessor_mutex(false), open_writable_files(0) + : PathResolutionFileSystem(fs), accessor_mutex(), open_writable_files(0) { /* ... */ } DirectorySaveDataFileSystem::DirectorySaveDataFileSystem(std::unique_ptr fs) - : PathResolutionFileSystem(std::move(fs)), accessor_mutex(false), open_writable_files(0) + : PathResolutionFileSystem(std::move(fs)), accessor_mutex(), open_writable_files(0) { /* ... */ } diff --git a/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp b/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp index 5ef4a008..16b461c6 100644 --- a/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp +++ b/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp @@ -25,7 +25,7 @@ namespace ams::fssystem { static constexpr s32 LayerCount = 3; static constexpr size_t HashSize = crypto::Sha256Generator::HashSize; private: - os::Mutex mutex; + os::SdkMutex mutex; IStorage *base_storage; s64 base_storage_size; char *hash_buffer; @@ -33,7 +33,7 @@ namespace ams::fssystem { s32 hash_target_block_size; s32 log_size_ratio; public: - HierarchicalSha256Storage() : mutex(false) { /* ... */ } + HierarchicalSha256Storage() : mutex() { /* ... */ } Result Initialize(IStorage **base_storages, s32 layer_count, size_t htbs, void *hash_buf, size_t hash_buf_size); diff --git a/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp b/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp index 6b4f9234..0cf1f5e2 100644 --- a/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp +++ b/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp @@ -22,10 +22,10 @@ namespace ams::fssystem { NON_COPYABLE(KeySlotCacheAccessor); NON_MOVEABLE(KeySlotCacheAccessor); private: - util::unique_lock lk; + util::unique_lock lk; const s32 slot_index; public: - KeySlotCacheAccessor(s32 idx, util::unique_lock &&l) : lk(std::move(l)), slot_index(idx) { /* ... */ } + KeySlotCacheAccessor(s32 idx, util::unique_lock &&l) : lk(std::move(l)), slot_index(idx) { /* ... */ } s32 GetKeySlotIndex() const { return this->slot_index; } }; @@ -64,11 +64,11 @@ namespace ams::fssystem { private: using KeySlotCacheEntryList = util::IntrusiveListBaseTraits::ListType; private: - os::Mutex mutex; + os::SdkMutex mutex; KeySlotCacheEntryList high_priority_mru_list; KeySlotCacheEntryList low_priority_mru_list; public: - constexpr KeySlotCache() : mutex(false), high_priority_mru_list(), low_priority_mru_list() { /* ... */ } + constexpr KeySlotCache() : mutex(), high_priority_mru_list(), low_priority_mru_list() { /* ... */ } Result AllocateHighPriority(std::unique_ptr *out, const void *key, size_t key_size, s32 key2) { return this->AllocateFromLru(out, this->high_priority_mru_list, key, key_size, key2); diff --git a/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp b/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp index 7d36e991..0ec3e1e4 100644 --- a/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp +++ b/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp @@ -21,13 +21,12 @@ namespace ams::fssystem { class AdditionalDeviceAddressEntry { private: - /* TODO: SdkMutex */ - os::Mutex mutex; + os::SdkMutex mutex; bool is_registered; uintptr_t address; size_t size; public: - constexpr AdditionalDeviceAddressEntry() : mutex(false), is_registered(), address(), size() { /* ... */ } + constexpr AdditionalDeviceAddressEntry() : mutex(), is_registered(), address(), size() { /* ... */ } void Register(uintptr_t addr, size_t sz) { std::scoped_lock lk(this->mutex); @@ -77,18 +76,17 @@ namespace ams::fssystem { constexpr size_t HeapAllocatableSizeMax = HeapBlockSize * (static_cast(1) << HeapOrderMax); constexpr size_t HeapAllocatableSizeMaxForLarge = HeapBlockSize * (static_cast(1) << HeapOrderMaxForLarge); - /* TODO: SdkMutex */ - os::Mutex g_heap_mutex(false); - FileSystemBuddyHeap g_heap; + constinit os::SdkMutex g_heap_mutex; + constinit FileSystemBuddyHeap g_heap; - std::atomic g_retry_count; - std::atomic g_reduce_allocation_count; + constinit std::atomic g_retry_count; + constinit std::atomic g_reduce_allocation_count; - void *g_heap_buffer; - size_t g_heap_size; - size_t g_heap_free_size_peak; + constinit void *g_heap_buffer; + constinit size_t g_heap_size; + constinit size_t g_heap_free_size_peak; - AdditionalDeviceAddressEntry g_additional_device_address_entry; + constinit AdditionalDeviceAddressEntry g_additional_device_address_entry; } diff --git a/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp b/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp index f46ee156..61a73d88 100644 --- a/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp +++ b/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp @@ -25,12 +25,12 @@ namespace ams::fssystem { private: using BlockCache = LruListCache; private: - os::Mutex mutex; + os::SdkMutex mutex; BlockCache block_cache; fs::IStorage * const base_storage; s32 block_size; public: - ReadOnlyBlockCacheStorage(IStorage *bs, s32 bsz, char *buf, size_t buf_size, s32 cache_block_count) : mutex(false), base_storage(bs), block_size(bsz) { + ReadOnlyBlockCacheStorage(IStorage *bs, s32 bsz, char *buf, size_t buf_size, s32 cache_block_count) : mutex(), base_storage(bs), block_size(bsz) { /* Validate preconditions. */ AMS_ASSERT(buf_size >= static_cast(this->block_size)); AMS_ASSERT(util::IsPowerOfTwo(this->block_size)); diff --git a/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp b/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp index 2379ab20..773840aa 100644 --- a/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp +++ b/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp @@ -27,7 +27,7 @@ namespace ams::fssystem::save { this->Finalize(); } - Result BlockCacheBufferedStorage::Initialize(IBufferManager *bm, os::Mutex *mtx, IStorage *data, s64 data_size, size_t verif_block_size, s32 max_cache_entries, bool is_real_data, s8 buffer_level, bool is_keep_burst_mode, fs::StorageType storage_type) { + Result BlockCacheBufferedStorage::Initialize(IBufferManager *bm, os::SdkRecursiveMutex *mtx, IStorage *data, s64 data_size, size_t verif_block_size, s32 max_cache_entries, bool is_real_data, s8 buffer_level, bool is_keep_burst_mode, fs::StorageType storage_type) { /* Validate preconditions. */ AMS_ASSERT(data != nullptr); AMS_ASSERT(bm != nullptr); diff --git a/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp b/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp index d8de70fc..bdd064bd 100644 --- a/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp +++ b/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp @@ -582,7 +582,7 @@ namespace ams::fssystem::save { } }; - BufferedStorage::BufferedStorage() : base_storage(), buffer_manager(), block_size(), base_storage_size(), caches(), cache_count(), next_acquire_cache(), next_fetch_cache(), mutex(false), bulk_read_enabled() { + BufferedStorage::BufferedStorage() : base_storage(), buffer_manager(), block_size(), base_storage_size(), caches(), cache_count(), next_acquire_cache(), next_fetch_cache(), mutex(), bulk_read_enabled() { /* ... */ } diff --git a/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp b/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp index 24967553..67d9e47e 100644 --- a/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp +++ b/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp @@ -150,7 +150,7 @@ namespace ams::fssystem::save { this->storage = fs::SubStorage(); } - Result HierarchicalIntegrityVerificationStorage::Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::Mutex *mtx, fs::StorageType storage_type) { + Result HierarchicalIntegrityVerificationStorage::Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::SdkRecursiveMutex *mtx, fs::StorageType storage_type) { /* Validate preconditions. */ AMS_ASSERT(bufs != nullptr); AMS_ASSERT(IntegrityMinLayerCount <= info.max_layers && info.max_layers <= IntegrityMaxLayerCount); diff --git a/libstratosphere/source/hid/hid_api.cpp b/libstratosphere/source/hid/hid_api.cpp index 7196618b..2257d091 100644 --- a/libstratosphere/source/hid/hid_api.cpp +++ b/libstratosphere/source/hid/hid_api.cpp @@ -20,8 +20,8 @@ namespace ams::hid { namespace { /* Global lock. */ - os::Mutex g_hid_lock(false); - bool g_initialized_hid = false; + constinit os::SdkMutex g_hid_lock; + constinit bool g_initialized_hid = false; /* Set of supported NpadIds (we want to read from any connected controllers). */ constexpr const HidNpadIdType NpadIdTypes[] = { diff --git a/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp b/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp index 6c2c5fa9..e39d077d 100644 --- a/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp +++ b/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp @@ -30,13 +30,13 @@ namespace ams::lmem::impl { public: explicit ScopedHeapLock(HeapHandle h) : handle(h) { if (this->handle->option & CreateOption_ThreadSafe) { - os::LockMutex(std::addressof(this->handle->mutex)); + os::LockSdkMutex(std::addressof(this->handle->mutex)); } } ~ScopedHeapLock() { if (this->handle->option & CreateOption_ThreadSafe) { - os::UnlockMutex(std::addressof(this->handle->mutex)); + os::UnlockSdkMutex(std::addressof(this->handle->mutex)); } } }; diff --git a/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp b/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp index 213fbd5f..3119a303 100644 --- a/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp +++ b/libstratosphere/source/lmem/impl/lmem_impl_exp_heap.cpp @@ -427,6 +427,7 @@ namespace ams::lmem::impl { const s32 abs_alignment = std::abs(alignment); AMS_ASSERT((abs_alignment & (abs_alignment - 1)) == 0); AMS_ASSERT(MinimumAlignment <= static_cast(abs_alignment)); + AMS_UNUSED(abs_alignment); /* Fix size to be correctly aligned. */ if (size == 0) { diff --git a/libstratosphere/source/lmem/lmem_exp_heap.cpp b/libstratosphere/source/lmem/lmem_exp_heap.cpp index 60604043..489ec955 100644 --- a/libstratosphere/source/lmem/lmem_exp_heap.cpp +++ b/libstratosphere/source/lmem/lmem_exp_heap.cpp @@ -21,15 +21,12 @@ namespace ams::lmem { HeapHandle CreateExpHeap(void *address, size_t size, u32 option) { HeapHandle handle = impl::CreateExpHeap(address, size, option); if (option & CreateOption_ThreadSafe) { - os::InitializeMutex(std::addressof(handle->mutex), false, 0); + os::InitializeSdkMutex(std::addressof(handle->mutex)); } return handle; } void DestroyExpHeap(HeapHandle handle) { - if (handle->option & CreateOption_ThreadSafe) { - os::FinalizeMutex(std::addressof(handle->mutex)); - } impl::DestroyExpHeap(handle); } diff --git a/libstratosphere/source/lmem/lmem_unit_heap.cpp b/libstratosphere/source/lmem/lmem_unit_heap.cpp index edc7c8cd..5a9b2a58 100644 --- a/libstratosphere/source/lmem/lmem_unit_heap.cpp +++ b/libstratosphere/source/lmem/lmem_unit_heap.cpp @@ -21,7 +21,7 @@ namespace ams::lmem { HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option) { HeapHandle handle = impl::CreateUnitHeap(address, size, unit_size, DefaultAlignment, static_cast(option), InfoPlacement_Head, nullptr); if (option & CreateOption_ThreadSafe) { - os::InitializeMutex(std::addressof(handle->mutex), false, 0); + os::InitializeSdkMutex(std::addressof(handle->mutex)); } return handle; } @@ -29,7 +29,7 @@ namespace ams::lmem { HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option, s32 alignment, InfoPlacement info_placement) { HeapHandle handle = impl::CreateUnitHeap(address, size, unit_size, alignment, static_cast(option), info_placement, nullptr); if (option & CreateOption_ThreadSafe) { - os::InitializeMutex(std::addressof(handle->mutex), false, 0); + os::InitializeSdkMutex(std::addressof(handle->mutex)); } return handle; } @@ -37,15 +37,12 @@ namespace ams::lmem { HeapHandle CreateUnitHeap(void *address, size_t size, size_t unit_size, u32 option, s32 alignment, HeapCommonHead *heap_head) { HeapHandle handle = impl::CreateUnitHeap(address, size, unit_size, alignment, static_cast(option), InfoPlacement_Head, heap_head); if (option & CreateOption_ThreadSafe) { - os::InitializeMutex(std::addressof(handle->mutex), false, 0); + os::InitializeSdkMutex(std::addressof(handle->mutex)); } return handle; } void DestroyUnitHeap(HeapHandle handle) { - if (handle->option & CreateOption_ThreadSafe) { - os::FinalizeMutex(std::addressof(handle->mutex)); - } impl::DestroyUnitHeap(handle); } diff --git a/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp b/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp index 327e029b..656b942d 100644 --- a/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp +++ b/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp @@ -201,14 +201,14 @@ namespace ams::mem::impl::heap { s32 static_thread_quota; s32 dynamic_thread_quota; bool use_virtual_memory; - os::Mutex lock; + os::SdkRecursiveMutex lock; ListHeader spanpage_list; ListHeader full_spanpage_list; ListHeader freelists[FreeListCount]; FreeListAvailableWord freelists_bitmap[NumFreeListBitmaps]; ListHeader smallmem_lists[TlsHeapStatic::NumClassInfo]; public: - TlsHeapCentral() : lock(true) { + TlsHeapCentral() : lock() { this->span_table.total_pages = 0; } diff --git a/libstratosphere/source/ncm/ncm_install_task_base.cpp b/libstratosphere/source/ncm/ncm_install_task_base.cpp index f9a56b6a..8f23ff1f 100644 --- a/libstratosphere/source/ncm/ncm_install_task_base.cpp +++ b/libstratosphere/source/ncm/ncm_install_task_base.cpp @@ -635,7 +635,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { R_UNLESS(!this->IsCancelRequested(), ncm::ResultCreatePlaceHolderCancelled()); - static os::Mutex s_placeholder_mutex(false); + static constinit os::SdkMutex s_placeholder_mutex; std::scoped_lock lk(s_placeholder_mutex); InstallContentMeta content_meta; diff --git a/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp b/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp index 1d808445..72368649 100644 --- a/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp +++ b/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp @@ -32,7 +32,7 @@ namespace ams::ncm { std::array caches; PathString *root_path; u64 cur_counter; - os::Mutex cache_mutex; + os::SdkMutex cache_mutex; MakePlaceHolderPathFunction make_placeholder_path_func; bool delay_flush; private: @@ -43,7 +43,7 @@ namespace ams::ncm { CacheEntry *FindInCache(PlaceHolderId placeholder_id); CacheEntry *GetFreeEntry();; public: - PlaceHolderAccessor() : cur_counter(0), cache_mutex(false), delay_flush(false) { + PlaceHolderAccessor() : cur_counter(0), cache_mutex(), delay_flush(false) { for (size_t i = 0; i < MaxCacheEntries; i++) { caches[i].id = InvalidPlaceHolderId; } diff --git a/libstratosphere/source/patcher/patcher_api.cpp b/libstratosphere/source/patcher/patcher_api.cpp index 177b80d9..bc827086 100644 --- a/libstratosphere/source/patcher/patcher_api.cpp +++ b/libstratosphere/source/patcher/patcher_api.cpp @@ -31,8 +31,8 @@ namespace ams::patcher { constexpr size_t ModuleIpsPatchLength = 2 * sizeof(ro::ModuleId) + IpsFileExtensionLength; /* Global data. */ - os::Mutex apply_patch_lock(false); - u8 g_patch_read_buffer[os::MemoryPageSize]; + constinit os::SdkMutex g_apply_patch_lock; + constinit u8 g_patch_read_buffer[os::MemoryPageSize]; /* Helpers. */ inline u8 ConvertHexNybble(const char nybble) { @@ -213,7 +213,7 @@ namespace ams::patcher { void LocateAndApplyIpsPatchesToModule(const char *mount_name, const char *patch_dir_name, size_t protected_size, size_t offset, const ro::ModuleId *module_id, u8 *mapped_module, size_t mapped_size) { /* Ensure only one thread tries to apply patches at a time. */ - std::scoped_lock lk(apply_patch_lock); + std::scoped_lock lk(g_apply_patch_lock); /* Inspect all patches from /atmosphere//<*>/<*>.ips */ char path[fs::EntryNameLengthMax + 1]; diff --git a/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp b/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp index 7c16a962..ec310bab 100644 --- a/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp +++ b/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp @@ -106,7 +106,7 @@ namespace ams::sf::cmif { return entry->object.Clone(); } - ServerDomainManager::EntryManager::EntryManager(DomainEntryStorage *entry_storage, size_t entry_count) : lock(false) { + ServerDomainManager::EntryManager::EntryManager(DomainEntryStorage *entry_storage, size_t entry_count) : lock() { this->entries = reinterpret_cast(entry_storage); this->num_entries = entry_count; for (size_t i = 0; i < this->num_entries; i++) { diff --git a/libstratosphere/source/sm/sm_utils.cpp b/libstratosphere/source/sm/sm_utils.cpp index f241e79e..57dc2383 100644 --- a/libstratosphere/source/sm/sm_utils.cpp +++ b/libstratosphere/source/sm/sm_utils.cpp @@ -21,17 +21,17 @@ namespace ams::sm::impl { namespace { /* Globals. */ - constinit os::Mutex g_mitm_ack_session_mutex(true); - constinit os::Mutex g_per_thread_session_mutex(true); + constinit os::SdkRecursiveMutex g_mitm_ack_session_mutex; + constinit os::SdkRecursiveMutex g_per_thread_session_mutex; } /* Utilities. */ - os::Mutex &GetMitmAcknowledgementSessionMutex() { + os::SdkRecursiveMutex &GetMitmAcknowledgementSessionMutex() { return g_mitm_ack_session_mutex; } - os::Mutex &GetPerThreadSessionMutex() { + os::SdkRecursiveMutex &GetPerThreadSessionMutex() { return g_per_thread_session_mutex; } diff --git a/libstratosphere/source/sm/sm_utils.hpp b/libstratosphere/source/sm/sm_utils.hpp index f8926c61..ed1cd132 100644 --- a/libstratosphere/source/sm/sm_utils.hpp +++ b/libstratosphere/source/sm/sm_utils.hpp @@ -21,8 +21,8 @@ namespace ams::sm::impl { /* Utilities. */ - os::Mutex &GetMitmAcknowledgementSessionMutex(); - os::Mutex &GetPerThreadSessionMutex(); + os::SdkRecursiveMutex &GetMitmAcknowledgementSessionMutex(); + os::SdkRecursiveMutex &GetPerThreadSessionMutex(); template Result DoWithMitmAcknowledgementSession(F f) { diff --git a/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp b/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp index 8cb0490e..5e888674 100644 --- a/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp +++ b/libvapours/source/sdmmc/impl/sdmmc_base_device_accessor.hpp @@ -214,9 +214,9 @@ namespace ams::sdmmc::impl { bool is_awake; public: #if defined(AMS_SDMMC_THREAD_SAFE) - mutable os::Mutex device_mutex; + mutable os::SdkRecursiveMutex device_mutex; public: - BaseDevice() : device_mutex(true) + BaseDevice() : device_mutex() #else BaseDevice() #endif