diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp index 38690d34f..be6e0f05b 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp @@ -164,6 +164,6 @@ namespace ams::fs { static_assert(util::is_pod::value); static_assert(sizeof(HashSalt) == HashSalt::Size); - using SaveDataHashSalt = std::optional; + using SaveDataHashSalt = util::optional; } diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/impl/fssrv_impl_program_index_map_info_manager.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/impl/fssrv_impl_program_index_map_info_manager.hpp index 021b6e6aa..a0db001d1 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/impl/fssrv_impl_program_index_map_info_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/impl/fssrv_impl_program_index_map_info_manager.hpp @@ -54,7 +54,7 @@ namespace ams::fssrv::impl { return m_list.size(); } - std::optional Get(const ncm::ProgramId &program_id) const { + util::optional Get(const ncm::ProgramId &program_id) const { /* Acquire exclusive access to the map. */ std::scoped_lock lk(m_mutex); @@ -134,9 +134,9 @@ namespace ams::fssrv::impl { } template - std::optional GetImpl(F f) const { + util::optional GetImpl(F f) const { /* Try to find an entry matching the predicate. */ - std::optional match = std::nullopt; + util::optional match = util::nullopt; for (const auto &entry : m_list) { /* If the predicate matches, we want to return the relevant info. */ diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp index cd20979f3..a84556fa0 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp @@ -92,7 +92,7 @@ namespace ams::fssrv::impl { public: bool IsDeepRetryEnabled() const; bool IsAccessFailureDetectionObserved() const; - std::optional> AcquireCacheInvalidationReadLock(); + util::optional> AcquireCacheInvalidationReadLock(); os::ReadWriteLock &GetReadWriteLockForCacheInvalidation(); public: /* Command API. */ diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp index f3151543c..b2cb7966c 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp @@ -44,7 +44,7 @@ namespace ams::fssrv::impl { ~StorageInterfaceAdapter(); private: - std::optional> AcquireCacheInvalidationReadLock(); + util::optional> AcquireCacheInvalidationReadLock(); public: /* Command API. */ Result Read(s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp index 2a31cbbae..281b4b99b 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp @@ -34,9 +34,9 @@ namespace ams::fssystem { virtual ~DirectoryRedirectionFileSystem(); protected: - inline std::optional> GetAccessorLock() const { + inline util::optional> GetAccessorLock() const { /* No accessor lock is needed. */ - return std::nullopt; + return util::nullopt; } private: Result GetNormalizedDirectoryPath(char **out, size_t *out_size, const char *dir); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp index 4a741efde..026b2d936 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp @@ -33,9 +33,9 @@ namespace ams::fssystem { virtual ~DirectorySaveDataFileSystem(); protected: - inline std::optional> GetAccessorLock() { + inline util::optional> GetAccessorLock() { /* We have a real accessor lock that we want to use. */ - return std::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/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp index a45ad3d02..059f79f97 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp @@ -107,7 +107,7 @@ namespace ams::fssystem { class Sha256PartitionFileSystemMeta : public PartitionFileSystemMetaCore { public: using PartitionFileSystemMetaCore::Initialize; - Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator, const void *hash, size_t hash_size, std::optional suffix = std::nullopt); + Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator, const void *hash, size_t hash_size, util::optional suffix = util::nullopt); }; } diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp index 1e5efa98e..e30e74db1 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp @@ -32,9 +32,9 @@ namespace ams::fssystem { virtual ~SubDirectoryFileSystem(); protected: - inline std::optional> GetAccessorLock() const { + inline util::optional> GetAccessorLock() const { /* No accessor lock is needed. */ - return std::nullopt; + return util::nullopt; } private: Result Initialize(const char *bp); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp index 75991c055..983d657f6 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp @@ -50,7 +50,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->CreateFile(full_path, size, option); } @@ -58,7 +58,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->DeleteFile(full_path); } @@ -66,7 +66,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->CreateDirectory(full_path); } @@ -74,7 +74,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->DeleteDirectory(full_path); } @@ -82,7 +82,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->DeleteDirectoryRecursively(full_path); } @@ -92,7 +92,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(old_full_path, sizeof(old_full_path), old_path)); R_TRY(static_cast(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->RenameFile(old_full_path, new_full_path); } @@ -102,7 +102,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(old_full_path, sizeof(old_full_path), old_path)); R_TRY(static_cast(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->RenameDirectory(old_full_path, new_full_path); } @@ -110,7 +110,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->GetEntryType(out, full_path); } @@ -118,7 +118,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->OpenFile(out_file, full_path, mode); } @@ -126,12 +126,12 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->OpenDirectory(out_dir, full_path, mode); } virtual Result DoCommit() override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->Commit(); } @@ -139,7 +139,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->GetFreeSpaceSize(out, full_path); } @@ -147,7 +147,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->GetTotalSpaceSize(out, full_path); } @@ -155,7 +155,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->CleanDirectoryRecursively(full_path); } @@ -163,7 +163,7 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->GetFileTimeStampRaw(out, full_path); } @@ -171,23 +171,23 @@ namespace ams::fssystem::impl { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->QueryEntry(dst, dst_size, src, src_size, query, full_path); } /* These aren't accessible as commands. */ virtual Result DoCommitProvisionally(s64 counter) override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->CommitProvisionally(counter); } virtual Result DoRollback() override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->Rollback(); } virtual Result DoFlush() override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); + util::optional optional_lock = static_cast(this)->GetAccessorLock(); return this->base_fs->Flush(); } }; diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp index 047562ff1..707968e7e 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp @@ -57,8 +57,8 @@ namespace ams::kvdb { public: Result Initialize(void *buffer, size_t buffer_size, size_t capacity); void Invalidate(); - std::optional TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size); - std::optional TryGetSize(const void *key, size_t key_size); + util::optional TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size); + util::optional TryGetSize(const void *key, size_t key_size); void Set(const void *key, size_t key_size, const void *value, size_t value_size); bool Contains(const void *key, size_t key_size); }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp index 32d2e9bf9..a5c1649f1 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp @@ -37,6 +37,6 @@ namespace ams::ncm { void GetTicketFileStringFromRightsId(char *dst, size_t dst_size, fs::RightsId id); void GetCertificateFileStringFromRightsId(char *dst, size_t dst_size, fs::RightsId id); - std::optional GetContentIdFromString(const char *str, size_t len); + util::optional GetContentIdFromString(const char *str, size_t len); } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp index cc55056bb..4c00e694e 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -94,7 +94,7 @@ namespace ams::ncm { StorageId storage_id; SystemSaveDataInfo info; sf::SharedPointer content_meta_database; - std::optional> kvs; + util::optional> kvs; ContentMetaMemoryResource *memory_resource; u32 max_content_metas; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp index 9810b7658..d185aa93a 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp @@ -303,17 +303,17 @@ namespace ams::ncm { return static_cast(this->GetHeader()->storage_id); } - std::optional GetApplicationId(const ContentMetaKey &key) const { + util::optional GetApplicationId(const ContentMetaKey &key) const { switch (key.type) { case ContentMetaType::Application: return ApplicationId{ key.id }; case ContentMetaType::Patch: return this->GetExtendedHeader()->application_id; case ContentMetaType::AddOnContent: return this->GetExtendedHeader()->application_id; case ContentMetaType::Delta: return this->GetExtendedHeader()->application_id; - default: return std::nullopt; + default: return util::nullopt; } } - std::optional GetApplicationId() const { + util::optional GetApplicationId() const { return this->GetApplicationId(this->GetKey()); } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp index 8243efbb2..3e72ff483 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp @@ -131,7 +131,7 @@ namespace ams::ncm { protected: Result Initialize(StorageId install_storage, InstallTaskDataBase *data, u32 config); - Result PrepareContentMeta(const InstallContentMetaInfo &meta_info, std::optional key, std::optional source_version); + Result PrepareContentMeta(const InstallContentMetaInfo &meta_info, util::optional key, util::optional source_version); Result PrepareContentMeta(ContentId content_id, s64 size, ContentMetaType meta_type, AutoBuffer *buffer); Result WritePlaceHolderBuffer(InstallContentInfo *content_info, const void *data, size_t data_size); void PrepareAgain(); @@ -145,7 +145,7 @@ namespace ams::ncm { Result PrepareSystemUpdateDependency(); virtual Result PrepareContentMetaIfLatest(const ContentMetaKey &key); /* NOTE: This is not virtual in Nintendo's code. We do so to facilitate downgrades. */ u32 GetConfig() const { return this->config; } - Result WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, std::optional is_temporary); + Result WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, util::optional is_temporary); StorageId GetInstallStorage() const { return this->install_storage; } @@ -164,7 +164,7 @@ namespace ams::ncm { Result VerifyAllNotCommitted(const StorageContentMetaKey *keys, s32 num_keys); virtual Result PrepareInstallContentMetaData() = 0; - virtual Result GetLatestVersion(std::optional *out_version, u64 id) { return ncm::ResultContentMetaNotFound(); } + virtual Result GetLatestVersion(util::optional *out_version, u64 id) { return ncm::ResultContentMetaNotFound(); } virtual Result OnExecuteComplete() { return ResultSuccess(); } @@ -187,9 +187,9 @@ namespace ams::ncm { void StartThroughputMeasurement(); void UpdateThroughputMeasurement(s64 throughput); - Result GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, std::optional source_version); + Result GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional source_version); - InstallContentInfo MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, std::optional is_temporary); + InstallContentInfo MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, util::optional is_temporary); Result ReadContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const ContentMetaKey &key); Result ListRightsIdsByInstallContentMeta(s32 *out_count, Span out_span, const InstallContentMeta &content_meta, s32 offset); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp index fdaf68217..8eb8cc088 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp @@ -31,7 +31,7 @@ namespace ams::ncm { void Inactivate(); Result Initialize(const char *package_root, const char *context_path, void *buffer, size_t buffer_size, bool requires_exfat_driver, FirmwareVariationId firmware_variation_id); - std::optional GetSystemUpdateMetaKey(); + util::optional GetSystemUpdateMetaKey(); protected: virtual Result PrepareInstallContentMetaData() override; virtual Result GetInstallContentMetaInfo(InstallContentMetaInfo *out, const ContentMetaKey &key) override; diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp index a20f7d442..e9fbd4e10 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp @@ -38,8 +38,8 @@ namespace ams::capsrv::server { /* Destroy the server. */ os::FinalizeEvent(std::addressof(this->idle_event)); - this->server_manager_holder = std::nullopt; - this->service_holder = std::nullopt; + this->server_manager_holder = util::nullopt; + this->service_holder = util::nullopt; } void DecoderControlServerManager::StartServer() { diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp index 71681e44f..24532a23e 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp @@ -31,8 +31,8 @@ namespace ams::capsrv::server { using ServerOptions = sf::hipc::DefaultServerManagerOptions; using ServerManager = sf::hipc::ServerManager; private: - std::optional service_holder; - std::optional server_manager_holder; + util::optional service_holder; + util::optional server_manager_holder; os::EventType idle_event; public: constexpr DecoderControlServerManager() : service_holder(), server_manager_holder(), idle_event{} { /* ... */ } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp index 2c6daeec7..28c2f8595 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp @@ -26,10 +26,10 @@ namespace ams::erpt::srv { constinit char Reporter::s_serial_number[24] = "Unknown"; constinit char Reporter::s_os_version[24] = "Unknown"; constinit char Reporter::s_private_os_version[96] = "Unknown"; - constinit std::optional Reporter::s_application_launch_time; - constinit std::optional Reporter::s_awake_time; - constinit std::optional Reporter::s_power_on_time; - constinit std::optional Reporter::s_initial_launch_settings_completion_time; + constinit util::optional Reporter::s_application_launch_time; + constinit util::optional Reporter::s_awake_time; + constinit util::optional Reporter::s_power_on_time; + constinit util::optional Reporter::s_initial_launch_settings_completion_time; namespace { @@ -78,13 +78,13 @@ namespace ams::erpt::srv { entry->suspended_duration = suspended_duration; } - std::optional GetActiveDuration(ncm::ProgramId program_id) const { + util::optional GetActiveDuration(ncm::ProgramId program_id) const { /* Try to find a matching entry. */ const auto entry = util::range::find_if(m_list, [&](const AppletActiveTimeInfo &info) { return info.program_id == program_id; }); if (entry != m_list.end()) { return (os::GetSystemTick() - entry->register_tick).ToTimeSpan() - entry->suspended_duration; } else { - return std::nullopt; + return util::nullopt; } } }; diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.hpp index 18460fc0b..14be6c6b4 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.hpp @@ -25,13 +25,13 @@ namespace ams::erpt::srv { static char s_serial_number[24]; static char s_os_version[24]; static char s_private_os_version[96]; - static std::optional s_application_launch_time; - static std::optional s_awake_time; - static std::optional s_power_on_time; - static std::optional s_initial_launch_settings_completion_time; + static util::optional s_application_launch_time; + static util::optional s_awake_time; + static util::optional s_power_on_time; + static util::optional s_initial_launch_settings_completion_time; public: - static void ClearApplicationLaunchTime() { s_application_launch_time = std::nullopt; } - static void ClearInitialLaunchSettingsCompletionTime() { s_initial_launch_settings_completion_time = std::nullopt; } + static void ClearApplicationLaunchTime() { s_application_launch_time = util::nullopt; } + static void ClearInitialLaunchSettingsCompletionTime() { s_initial_launch_settings_completion_time = util::nullopt; } static void SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time) { s_initial_launch_settings_completion_time = time; } diff --git a/libraries/libstratosphere/source/fs/fs_code.cpp b/libraries/libstratosphere/source/fs/fs_code.cpp index eb4fa2956..bce87db93 100644 --- a/libraries/libstratosphere/source/fs/fs_code.cpp +++ b/libraries/libstratosphere/source/fs/fs_code.cpp @@ -238,7 +238,7 @@ namespace ams::fs { class SdCardRedirectionCodeFileSystem : public OpenFileOnlyFileSystem { private: - std::optional sd_content_fs; + util::optional sd_content_fs; ReadOnlyFileSystem code_fs; bool is_redirect; public: @@ -303,8 +303,8 @@ namespace ams::fs { class AtmosphereCodeFileSystem : public OpenFileOnlyFileSystem { private: - std::optional code_fs; - std::optional hbl_fs; + util::optional code_fs; + util::optional hbl_fs; ncm::ProgramId program_id; bool initialized; public: diff --git a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp index 1a05c34e8..dcad08f53 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp @@ -154,8 +154,8 @@ namespace ams::fssrv::impl { AMS_ABORT_UNLESS(false); } - std::optional> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() { - std::optional> lock; + util::optional> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() { + util::optional> lock; if (this->deep_retry_enabled) { lock.emplace(this->invalidation_lock); } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp index 384db7d1b..60c366ee3 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp @@ -34,8 +34,8 @@ namespace ams::fssrv::impl { /* ... */ } - std::optional> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() { - std::optional> lock; + util::optional> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() { + util::optional> lock; if (this->deep_retry_enabled) { lock.emplace(this->invalidation_lock); } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp b/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp index 76be00e1d..db2679834 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp @@ -113,7 +113,7 @@ namespace ams::fssystem { constexpr inline s32 KeySlotCacheEntryCount = 3; KeySlotCache g_key_slot_cache; - std::optional g_key_slot_cache_entry[KeySlotCacheEntryCount]; + util::optional g_key_slot_cache_entry[KeySlotCacheEntryCount]; spl::AccessKey &GetNcaKekAccessKey(s32 key_type) { static spl::AccessKey s_nca_kek_access_key_array[KeyAreaEncryptionKeyCount] = {}; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp index 591c35a9d..2648ad32b 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp @@ -162,7 +162,7 @@ namespace ams::fssystem { template class PartitionFileSystemMetaCore; template class PartitionFileSystemMetaCore; - Result Sha256PartitionFileSystemMeta::Initialize(fs::IStorage *base_storage, MemoryResource *allocator, const void *hash, size_t hash_size, std::optional suffix) { + Result Sha256PartitionFileSystemMeta::Initialize(fs::IStorage *base_storage, MemoryResource *allocator, const void *hash, size_t hash_size, util::optional suffix) { /* Ensure preconditions. */ R_UNLESS(hash_size == crypto::Sha256Generator::HashSize, fs::ResultPreconditionViolation()); diff --git a/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.cpp b/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.cpp index 3e847c16d..e22db25b0 100644 --- a/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.cpp +++ b/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.cpp @@ -59,7 +59,7 @@ namespace ams::htclow::driver { std::scoped_lock lk(m_mutex); /* Clear our driver type. */ - m_driver_type = std::nullopt; + m_driver_type = util::nullopt; /* Close our driver. */ if (m_open_driver != nullptr) { diff --git a/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.hpp b/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.hpp index faa3f046a..ef8b156f4 100644 --- a/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.hpp +++ b/libraries/libstratosphere/source/htclow/driver/htclow_driver_manager.hpp @@ -23,7 +23,7 @@ namespace ams::htclow::driver { class DriverManager { private: - std::optional m_driver_type{}; + util::optional m_driver_type{}; IDriver *m_debug_driver{}; SocketDriver m_socket_driver; UsbDriver m_usb_driver{}; diff --git a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.hpp b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.hpp index 5849b88a5..48f31b9d4 100644 --- a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.hpp +++ b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.hpp @@ -47,7 +47,7 @@ namespace ams::htclow::mux { u64 m_total_send_size; u64 m_cur_max_data; u64 m_prev_max_data; - std::optional m_share; + util::optional m_share; os::Event m_state_change_event; ChannelState m_state; public: diff --git a/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp b/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp index fbcea57ab..8deb2bcf2 100644 --- a/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp +++ b/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp @@ -55,9 +55,9 @@ namespace ams::kvdb { AMS_ABORT_UNLESS(this->entries != nullptr); } - std::optional FileKeyValueStore::Cache::TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size) { + util::optional FileKeyValueStore::Cache::TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size) { if (!this->HasEntries()) { - return std::nullopt; + return util::nullopt; } /* Try to find the entry. */ @@ -66,7 +66,7 @@ namespace ams::kvdb { if (entry.key_size == key_size && std::memcmp(entry.key, key, key_size) == 0) { /* If we don't have enough space, fail to read from cache. */ if (max_out_size < entry.value_size) { - return std::nullopt; + return util::nullopt; } std::memcpy(out_value, entry.value, entry.value_size); @@ -74,12 +74,12 @@ namespace ams::kvdb { } } - return std::nullopt; + return util::nullopt; } - std::optional FileKeyValueStore::Cache::TryGetSize(const void *key, size_t key_size) { + util::optional FileKeyValueStore::Cache::TryGetSize(const void *key, size_t key_size) { if (!this->HasEntries()) { - return std::nullopt; + return util::nullopt; } /* Try to find the entry. */ @@ -90,7 +90,7 @@ namespace ams::kvdb { } } - return std::nullopt; + return util::nullopt; } void FileKeyValueStore::Cache::Set(const void *key, size_t key_size, const void *value, size_t value_size) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp index 389b27b66..a3caf9664 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_id_utils.cpp @@ -78,13 +78,13 @@ namespace ams::ncm { util::SNPrintf(dst, dst_size, "%s.cert", str.data); } - std::optional GetContentIdFromString(const char *str, size_t len) { + util::optional GetContentIdFromString(const char *str, size_t len) { if (len < ContentIdStringLength) { - return std::nullopt; + return util::nullopt; } ContentId content_id; - return GetBytesFromString(std::addressof(content_id), sizeof(content_id), str, ContentIdStringLength) ? std::optional(content_id) : std::nullopt; + return GetBytesFromString(std::addressof(content_id), sizeof(content_id), str, ContentIdStringLength) ? util::optional(content_id) : util::nullopt; } } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index b4fa0bad3..4d72ce91a 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -225,7 +225,7 @@ namespace ams::ncm { out->max_content_metas = max_content_metas; out->memory_resource = memory_resource; out->content_meta_database = nullptr; - out->kvs = std::nullopt; + out->kvs = util::nullopt; /* Create a new mount name and copy it to out. */ std::strcpy(out->mount_name, impl::CreateUniqueMountName().str); @@ -240,7 +240,7 @@ namespace ams::ncm { out->max_content_metas = max_content_metas; out->memory_resource = memory_resource; out->content_meta_database = nullptr; - out->kvs = std::nullopt; + out->kvs = util::nullopt; return ResultSuccess(); } @@ -649,7 +649,7 @@ namespace ams::ncm { /* N doesn't bother checking the result of this */ root->content_meta_database->DisableForcibly(); root->content_meta_database = nullptr; - root->kvs = std::nullopt; + root->kvs = util::nullopt; /* Also unmount, except in the case of game cards. */ if (storage_id != StorageId::GameCard) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp index cc515be1f..72b612d09 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp @@ -18,7 +18,7 @@ namespace ams::ncm { - Result ContentMetaDatabaseImpl::GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, std::optional id_offset) const { + Result ContentMetaDatabaseImpl::GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, util::optional id_offset) const { R_TRY(this->EnsureEnabled()); /* Find the meta key. */ @@ -78,7 +78,7 @@ namespace ams::ncm { } Result ContentMetaDatabaseImpl::GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) { - return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, std::nullopt); + return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::nullopt); } Result ContentMetaDatabaseImpl::ListContentInfo(sf::Out out_count, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) { @@ -149,7 +149,7 @@ namespace ams::ncm { Result ContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out out_key, u64 id) { R_TRY(this->EnsureEnabled()); - std::optional found_key = std::nullopt; + util::optional found_key = util::nullopt; /* Find the last key with the desired program id. */ for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) { @@ -308,15 +308,15 @@ namespace ams::ncm { out_orphaned[i] = true; } - auto IsOrphanedContent = [] ALWAYS_INLINE_LAMBDA (const sf::InArray &list, const ncm::ContentId &id) -> std::optional { + auto IsOrphanedContent = [] ALWAYS_INLINE_LAMBDA (const sf::InArray &list, const ncm::ContentId &id) -> util::optional { /* Check if any input content ids match our found content id. */ for (size_t i = 0; i < list.GetSize(); i++) { if (list[i] == id) { - return std::make_optional(i); + return util::make_optional(i); } } - return std::nullopt; + return util::nullopt; }; /* Iterate over all entries. */ @@ -435,7 +435,7 @@ namespace ams::ncm { } Result ContentMetaDatabaseImpl::GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { - return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, std::make_optional(id_offset)); + return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, util::make_optional(id_offset)); } Result ContentMetaDatabaseImpl::GetCount(sf::Out out_count) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp index fb378fcdc..919d21d9e 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp @@ -25,7 +25,7 @@ namespace ams::ncm { ContentMetaDatabaseImpl(ContentMetaKeyValueStore *kvs) : ContentMetaDatabaseImplBase(kvs) { /* ... */ } private: /* Helpers. */ - Result GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, std::optional id_offset) const; + Result GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, util::optional id_offset) const; public: /* Actual commands. */ virtual Result Set(const ContentMetaKey &key, const sf::InBuffer &value) override; diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp index 59639e1af..fff5bf5cd 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp @@ -116,7 +116,7 @@ namespace ams::ncm { R_UNLESS(reader.GetExtendedDataSize() != 0, ReadMetaInfoListFromBase()); SystemUpdateMetaExtendedDataReader extended_data_reader(reader.GetExtendedData(), reader.GetExtendedDataSize()); - std::optional firmware_variation_index = std::nullopt; + util::optional firmware_variation_index = util::nullopt; /* NOTE: Atmosphere extension to support downgrading. */ /* If all firmware variations refer to base, don't require the current variation be present. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp index 2fb5fef9b..d79b98673 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp @@ -208,7 +208,7 @@ namespace ams::ncm { return this->OpenCurrentDirectory(); } - Result ContentStorageImpl::ContentIterator::GetNext(std::optional *out) { + Result ContentStorageImpl::ContentIterator::GetNext(util::optional *out) { /* Iterate until we get the next entry. */ while (true) { /* Ensure that we have entries loaded. */ @@ -216,7 +216,7 @@ namespace ams::ncm { /* If we failed to load any entries, there's nothing to get. */ if (this->entry_count <= 0) { - *out = std::nullopt; + *out = util::nullopt; return ResultSuccess(); } @@ -353,7 +353,7 @@ namespace ams::ncm { fs::CloseFile(this->cached_file_handle); this->cached_content_id = InvalidContentId; } - this->content_iterator = std::nullopt; + this->content_iterator = util::nullopt; } Result ContentStorageImpl::OpenContentIdFile(ContentId content_id) { @@ -586,7 +586,7 @@ namespace ams::ncm { /* Advance to the desired offset. */ for (auto current_offset = 0; current_offset < offset; /* ... */) { /* Get the next directory entry. */ - std::optional dir_entry; + util::optional dir_entry; R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry))); /* If we run out of entries before reaching the desired offset, we're done. */ @@ -606,7 +606,7 @@ namespace ams::ncm { s32 count = 0; while (count < static_cast(out.GetSize())) { /* Get the next directory entry. */ - std::optional dir_entry; + util::optional dir_entry; R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry))); /* Don't continue if the directory entry is absent. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp index b0879688d..bb823270d 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp @@ -42,7 +42,7 @@ namespace ams::ncm { ~ContentIterator(); Result Initialize(const char *root_path, size_t max_depth); - Result GetNext(std::optional *out); + Result GetNext(util::optional *out); private: Result OpenCurrentDirectory(); Result OpenDirectory(const char *dir); @@ -53,14 +53,14 @@ namespace ams::ncm { ContentId cached_content_id; fs::FileHandle cached_file_handle; RightsIdCache *rights_id_cache; - std::optional content_iterator; - std::optional last_content_offset; + util::optional content_iterator; + util::optional last_content_offset; public: static Result InitializeBase(const char *root_path); static Result CleanupBase(const char *root_path); static Result VerifyBase(const char *root_path); public: - ContentStorageImpl() : placeholder_accessor(), cached_content_id(InvalidContentId), cached_file_handle(), rights_id_cache(nullptr), content_iterator(std::nullopt), last_content_offset(std::nullopt) { /* ... */ } + ContentStorageImpl() : placeholder_accessor(), cached_content_id(InvalidContentId), cached_file_handle(), rights_id_cache(nullptr), content_iterator(util::nullopt), last_content_offset(util::nullopt) { /* ... */ } ~ContentStorageImpl(); Result Initialize(const char *root_path, MakeContentPathFunction content_path_func, MakePlaceHolderPathFunction placeholder_path_func, bool delay_flush, RightsIdCache *rights_id_cache); diff --git a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp index e7e24e4ec..f9a56b6a8 100644 --- a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp @@ -87,8 +87,8 @@ namespace ams::ncm { R_TRY(this->CountInstallContentMetaData(std::addressof(count))); /* Iterate over content meta. */ - std::optional placeholder_id; - std::optional storage_id; + util::optional placeholder_id; + util::optional storage_id; for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; @@ -716,7 +716,7 @@ namespace ams::ncm { return ResultSuccess(); } - Result InstallTaskBase::WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, std::optional is_temporary) { + Result InstallTaskBase::WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, util::optional is_temporary) { /* Generate a placeholder id. */ auto placeholder_id = storage->GeneratePlaceHolderId(); @@ -736,14 +736,14 @@ namespace ams::ncm { return ResultSuccess(); } - Result InstallTaskBase::PrepareContentMeta(const InstallContentMetaInfo &meta_info, std::optional expected_key, std::optional source_version) { + Result InstallTaskBase::PrepareContentMeta(const InstallContentMetaInfo &meta_info, util::optional expected_key, util::optional source_version) { /* Open the BuiltInSystem content storage. */ ContentStorage content_storage; R_TRY(OpenContentStorage(&content_storage, StorageId::BuiltInSystem)); /* Write content meta to a placeholder. */ InstallContentInfo content_info; - R_TRY(this->WriteContentMetaToPlaceHolder(std::addressof(content_info), std::addressof(content_storage), meta_info, std::nullopt)); + R_TRY(this->WriteContentMetaToPlaceHolder(std::addressof(content_info), std::addressof(content_storage), meta_info, util::nullopt)); /* Get the path of the placeholder. */ Path path; @@ -929,7 +929,7 @@ namespace ams::ncm { /* Get and prepare install content meta info. */ InstallContentMetaInfo install_content_meta_info; R_TRY(this->GetInstallContentMetaInfo(std::addressof(install_content_meta_info), key)); - R_TRY(this->PrepareContentMeta(install_content_meta_info, key, std::nullopt)); + R_TRY(this->PrepareContentMeta(install_content_meta_info, key, util::nullopt)); } return ResultSuccess(); @@ -997,7 +997,7 @@ namespace ams::ncm { return this->data->Delete(keys, num_keys); } - Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, std::optional source_version) { + Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional source_version) { AutoBuffer meta; { fs::ScopedAutoAbortDisabler aad; @@ -1027,7 +1027,7 @@ namespace ams::ncm { return ResultSuccess(); } - InstallContentInfo InstallTaskBase::MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, std::optional is_tmp) { + InstallContentInfo InstallTaskBase::MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, util::optional is_tmp) { return { .digest = info.digest, .info = ContentInfo::Make(info.content_id, info.content_size, ContentType::Meta, 0), diff --git a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp index 21af7d6ea..b1e8ca978 100644 --- a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp @@ -67,7 +67,7 @@ namespace ams::ncm { Result OnMemoryContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out out_key, u64 id) { R_TRY(this->EnsureEnabled()); - std::optional found_key = std::nullopt; + util::optional found_key = util::nullopt; /* Find the last key with the desired program id. */ for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) { diff --git a/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp index 688aff3b9..299323cda 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp @@ -50,9 +50,9 @@ namespace ams::ncm { /* Check if this entry is content meta. */ if (this->IsContentMetaContentName(entry.name)) { /* Prepare content meta if id is valid. */ - std::optional id = GetContentIdFromString(entry.name, strnlen(entry.name, fs::EntryNameLengthMax + 1)); + util::optional id = GetContentIdFromString(entry.name, strnlen(entry.name, fs::EntryNameLengthMax + 1)); R_UNLESS(id, ncm::ResultInvalidPackageFormat()); - R_TRY(this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(*id, entry.file_size), std::nullopt, std::nullopt)); + R_TRY(this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(*id, entry.file_size), util::nullopt, util::nullopt)); } } diff --git a/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp index 95b7a518d..d6747642a 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_system_downgrade_task.cpp @@ -70,7 +70,7 @@ namespace ams::ncm { /* Get and prepare install content meta info. We aren't concerned if our key is older. */ InstallContentMetaInfo install_content_meta_info; R_TRY(this->GetInstallContentMetaInfo(std::addressof(install_content_meta_info), key)); - return this->PrepareContentMeta(install_content_meta_info, key, std::nullopt); + return this->PrepareContentMeta(install_content_meta_info, key, util::nullopt); } } diff --git a/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp index 9e428aa42..2f4df247c 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp @@ -70,7 +70,7 @@ namespace ams::ncm { return ResultSuccess(); } - std::optional PackageSystemUpdateTask::GetSystemUpdateMetaKey() { + util::optional PackageSystemUpdateTask::GetSystemUpdateMetaKey() { StorageContentMetaKey storage_keys[0x10]; s32 ofs = 0; @@ -93,7 +93,7 @@ namespace ams::ncm { } } while (count > 0); - return std::nullopt; + return util::nullopt; } Result PackageSystemUpdateTask::GetInstallContentMetaInfo(InstallContentMetaInfo *out, const ContentMetaKey &key) { @@ -117,7 +117,7 @@ namespace ams::ncm { R_TRY(this->GetContentInfoOfContentMeta(std::addressof(info), key)); /* Prepare the content meta. */ - return this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(info.GetId(), info.GetSize(), key), key, std::nullopt); + return this->PrepareContentMeta(InstallContentMetaInfo::MakeUnverifiable(info.GetId(), info.GetSize(), key), key, util::nullopt); } Result PackageSystemUpdateTask::PrepareDependency() { diff --git a/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp b/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp index 2c3a6cd8d..c25f57f75 100644 --- a/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp @@ -21,9 +21,9 @@ namespace ams::ncm { class SubmissionPackageInstallTask::Impl { private: fs::FileHandleStorage storage; - std::optional mount_name; + util::optional mount_name; public: - explicit Impl(fs::FileHandle file) : storage(file), mount_name(std::nullopt) { /* ... */ } + explicit Impl(fs::FileHandle file) : storage(file), mount_name(util::nullopt) { /* ... */ } ~Impl() { if (this->mount_name) { diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp index 045c40fdc..df5192a71 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell.cpp @@ -85,12 +85,12 @@ namespace ams::pgl::srv { } } - std::optional GetRunningApplicationProcessId() { + util::optional GetRunningApplicationProcessId() { os::ProcessId process_id; if (R_SUCCEEDED(pm::shell::GetApplicationProcessIdForShell(std::addressof(process_id)))) { return process_id; } else { - return std::nullopt; + return util::nullopt; } } diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp index 1047d13f1..15d68fe3d 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp @@ -131,7 +131,7 @@ namespace ams::pgl::srv { return ResultSuccess(); } - Result GetContentPath(lr::Path *out, ncm::ContentType type, std::optional index) const { + Result GetContentPath(lr::Path *out, ncm::ContentType type, util::optional index) const { switch (this->extension_type) { case ExtensionType::Nsp: return this->GetContentPathInNsp(out, type, index); case ExtensionType::Nspd: return this->GetContentPathInNspd(out, type, index); @@ -155,7 +155,7 @@ namespace ams::pgl::srv { return this->program_index; } private: - Result GetContentPathInNsp(lr::Path *out, ncm::ContentType type, std::optional index) const { + Result GetContentPathInNsp(lr::Path *out, ncm::ContentType type, util::optional index) const { /* Create a reader. */ auto reader = ncm::PackagedContentMetaReader(this->content_meta_buffer.Get(), this->content_meta_buffer.GetSize()); @@ -185,7 +185,7 @@ namespace ams::pgl::srv { return ResultSuccess(); } - Result GetContentPathInNspd(lr::Path *out, ncm::ContentType type, std::optional index) const { + Result GetContentPathInNspd(lr::Path *out, ncm::ContentType type, util::optional index) const { /* Get the content name. */ const char *content_name = nullptr; switch (type) { diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp index 4671d4114..3e7eb8400 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp @@ -23,7 +23,7 @@ namespace ams::powctl::impl::board::nintendo::nx { namespace { - constinit std::optional g_battery_device; + constinit util::optional g_battery_device; Max17050Driver &GetMax17050Driver() { static Max17050Driver s_max17050_driver; @@ -91,7 +91,7 @@ namespace ams::powctl::impl::board::nintendo::nx { GetMax17050Driver().Finalize(); /* Destroy the charger device. */ - g_battery_device = std::nullopt; + g_battery_device = util::nullopt; /* Finalize gpio library. */ gpio::Finalize(); diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp index a95e3b83f..23cdcfdb7 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp @@ -26,7 +26,7 @@ namespace ams::powctl::impl::board::nintendo::nx { AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::BatteryDevice, ::ams::powctl::impl::IDevice); private: bool use_event_handler; - std::optional event_handler; + util::optional event_handler; os::SystemEventType system_event; public: BatteryDevice(bool ev); diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_board_impl.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_board_impl.cpp index ade5d5ab4..c6db168a4 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_board_impl.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_board_impl.cpp @@ -23,8 +23,8 @@ namespace ams::powctl::impl::board::nintendo::nx { namespace { - constinit std::optional g_charger_driver; - constinit std::optional g_battery_driver; + constinit util::optional g_charger_driver; + constinit util::optional g_battery_driver; void InitializeChargerDriver(bool use_event_handlers) { /* Create the charger driver. */ @@ -47,7 +47,7 @@ namespace ams::powctl::impl::board::nintendo::nx { powctl::impl::UnregisterDriver(std::addressof(*g_charger_driver)); /* Destroy the battery driver. */ - g_charger_driver = std::nullopt; + g_charger_driver = util::nullopt; } void FinalizeBatteryDriver() { @@ -55,7 +55,7 @@ namespace ams::powctl::impl::board::nintendo::nx { powctl::impl::UnregisterDriver(std::addressof(*g_battery_driver)); /* Destroy the battery driver. */ - g_battery_driver = std::nullopt; + g_battery_driver = util::nullopt; } } diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp index de86f6350..38051dafc 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp @@ -23,7 +23,7 @@ namespace ams::powctl::impl::board::nintendo::nx { namespace { - constinit std::optional g_charger_device; + constinit util::optional g_charger_device; Bq24193Driver &GetBq24193Driver() { static Bq24193Driver s_bq24193_driver; @@ -80,7 +80,7 @@ namespace ams::powctl::impl::board::nintendo::nx { gpio::CloseSession(g_charger_device->GetPadSession()); /* Destroy the charger device. */ - g_charger_device = std::nullopt; + g_charger_device = util::nullopt; /* Finalize gpio library. */ gpio::Finalize(); diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp index c9f2c3e1e..15f574c5f 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp @@ -29,7 +29,7 @@ namespace ams::powctl::impl::board::nintendo::nx { bool watchdog_timer_enabled; TimeSpan watchdog_timer_timeout; bool use_event_handler; - std::optional event_handler; + util::optional event_handler; os::SystemEventType system_event; public: ChargerDevice(bool ev); diff --git a/libraries/libvapours/include/vapours/includes.hpp b/libraries/libvapours/include/vapours/includes.hpp index 4a5494402..1006283fb 100644 --- a/libraries/libvapours/include/vapours/includes.hpp +++ b/libraries/libvapours/include/vapours/includes.hpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/libraries/libvapours/include/vapours/util.hpp b/libraries/libvapours/include/vapours/util.hpp index f2fc85e1c..2c69b15d1 100644 --- a/libraries/libvapours/include/vapours/util.hpp +++ b/libraries/libvapours/include/vapours/util.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/libraries/libvapours/include/vapours/util/impl/util_enable_copy_move.hpp b/libraries/libvapours/include/vapours/util/impl/util_enable_copy_move.hpp new file mode 100644 index 000000000..650ef0a6b --- /dev/null +++ b/libraries/libvapours/include/vapours/util/impl/util_enable_copy_move.hpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include + +namespace ams::util::impl { + + template + struct EnableCopyMove{}; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = default; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = default; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = default; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = default; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = default; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = default; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = default; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = default; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = default; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = default; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = default; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = delete; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = delete; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = delete; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = default; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = delete; + }; + + template + struct EnableCopyMove { + constexpr EnableCopyMove() noexcept = default; + + constexpr EnableCopyMove(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove(EnableCopyMove &&) noexcept = delete; + constexpr EnableCopyMove &operator=(const EnableCopyMove &) noexcept = delete; + constexpr EnableCopyMove &operator=(EnableCopyMove &&) noexcept = delete; + }; + + +} diff --git a/libraries/libvapours/include/vapours/util/util_bounded_map.hpp b/libraries/libvapours/include/vapours/util/util_bounded_map.hpp index 0bb290ea0..903f2888a 100644 --- a/libraries/libvapours/include/vapours/util/util_bounded_map.hpp +++ b/libraries/libvapours/include/vapours/util/util_bounded_map.hpp @@ -24,7 +24,7 @@ namespace ams::util { template class BoundedMap { private: - std::array, N> keys; + std::array, N> keys; std::array, N> values; private: ALWAYS_INLINE void FreeEntry(size_t i) { diff --git a/libraries/libvapours/include/vapours/util/util_in_place.hpp b/libraries/libvapours/include/vapours/util/util_in_place.hpp new file mode 100644 index 000000000..d57bb4a72 --- /dev/null +++ b/libraries/libvapours/include/vapours/util/util_in_place.hpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include + +namespace ams::util { + + struct in_place_t{}; + + constexpr inline in_place_t in_place = {}; + +} \ No newline at end of file diff --git a/libraries/libvapours/include/vapours/util/util_optional.hpp b/libraries/libvapours/include/vapours/util/util_optional.hpp new file mode 100644 index 000000000..2eb985219 --- /dev/null +++ b/libraries/libvapours/include/vapours/util/util_optional.hpp @@ -0,0 +1,629 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include +#include +#include + +namespace ams::util { + + namespace impl { + + class NulloptHelper { + public: + template + static consteval T CreateInstance() { + return T(T::ConstructionArgument::Token); + } + }; + + } + + struct nullopt_t { + private: + friend class impl::NulloptHelper; + + enum class ConstructionArgument { + Token, + }; + public: + consteval nullopt_t(ConstructionArgument) { /* ... */ } + }; + + constexpr inline nullopt_t nullopt = impl::NulloptHelper::CreateInstance(); + + namespace impl { + + template + struct OptionalPayloadBase { + using StoredType = typename std::remove_const::type; + + struct EmptyType{}; + + template::value> + union StorageType { + EmptyType m_empty; + U m_value; + + constexpr ALWAYS_INLINE StorageType() : m_empty() { /* ... */ } + + template + constexpr ALWAYS_INLINE StorageType(in_place_t, Args &&... args) : m_value(std::forward(args)...) { /* ... */ } + + template + constexpr ALWAYS_INLINE StorageType(std::initializer_list il, Args &&... args) : m_value(il, std::forward(args)...) { /* ... */ } + }; + + template + union StorageType { + EmptyType m_empty; + U m_value; + + constexpr ALWAYS_INLINE StorageType() : m_empty() { /* ... */ } + + template + constexpr ALWAYS_INLINE StorageType(in_place_t, Args &&... args) : m_value(std::forward(args)...) { /* ... */ } + + template + constexpr ALWAYS_INLINE StorageType(std::initializer_list il, Args &&... args) : m_value(il, std::forward(args)...) { /* ... */ } + + constexpr ALWAYS_INLINE ~StorageType() { /* ... */ } + }; + + StorageType m_payload; + bool m_engaged = false; + + constexpr OptionalPayloadBase() = default; + constexpr ~OptionalPayloadBase() = default; + + template + constexpr OptionalPayloadBase(in_place_t tag, Args &&... args) : m_payload(tag, std::forward(args)...), m_engaged(true) { /* ... */ } + + template + constexpr OptionalPayloadBase(std::initializer_list il, Args &&... args) : m_payload(il, std::forward(args)...), m_engaged(true) { /* ... */ } + + constexpr OptionalPayloadBase(bool engaged, const OptionalPayloadBase &rhs) { if (rhs.m_engaged) { this->Construct(rhs.Get()); } } + constexpr OptionalPayloadBase(bool engaged, OptionalPayloadBase &&rhs) { if (rhs.m_engaged) { this->Construct(std::move(rhs.Get())); } } + + constexpr OptionalPayloadBase(const OptionalPayloadBase &) = default; + constexpr OptionalPayloadBase(OptionalPayloadBase &&) = default; + + constexpr OptionalPayloadBase &operator=(const OptionalPayloadBase &) = default; + constexpr OptionalPayloadBase &operator=(OptionalPayloadBase &&) = default; + + constexpr void CopyAssign(const OptionalPayloadBase &rhs) { + if (m_engaged && rhs.m_engaged) { + this->Get() = rhs.Get(); + } else if (rhs.m_engaged) { + this->Construct(rhs.Get()); + } else { + this->Reset(); + } + } + + constexpr void MoveAssign(OptionalPayloadBase &&rhs) { + if (m_engaged && rhs.m_engaged) { + this->Get() = std::move(rhs.Get()); + } else if (rhs.m_engaged) { + this->Construct(std::move(rhs.Get())); + } else { + this->Reset(); + } + } + + template + constexpr void Construct(Args &&... args) { + std::construct_at(std::addressof(m_payload.m_value), std::forward(args)...); + m_engaged = true; + } + + constexpr void Destroy() { + m_engaged = false; + std::destroy_at(std::addressof(m_payload.m_value)); + } + + constexpr ALWAYS_INLINE T &Get() { return m_payload.m_value; } + constexpr ALWAYS_INLINE const T &Get() const { return m_payload.m_value; } + + constexpr void Reset() { + if (m_engaged) { + this->Destroy(); + } + } + }; + + template::value, bool = std::is_trivially_copy_assignable::value && std::is_trivially_copy_constructible::value, bool = std::is_trivially_move_assignable::value && std::is_trivially_move_constructible::value> + struct OptionalPayload; + + template + struct OptionalPayload : OptionalPayloadBase { + using OptionalPayloadBase::OptionalPayloadBase; + + constexpr OptionalPayload() = default; + }; + + template + struct OptionalPayload : OptionalPayloadBase { + using OptionalPayloadBase::OptionalPayloadBase; + + constexpr OptionalPayload() = default; + constexpr ~OptionalPayload() = default; + constexpr OptionalPayload(const OptionalPayload &) = default; + constexpr OptionalPayload(OptionalPayload &&) = default; + constexpr OptionalPayload& operator=(OptionalPayload &&) = default; + + constexpr OptionalPayload &operator=(const OptionalPayload &rhs) { + this->CopyAssign(rhs); + return *this; + } + }; + + template + struct OptionalPayload : OptionalPayloadBase { + using OptionalPayloadBase::OptionalPayloadBase; + + constexpr OptionalPayload() = default; + constexpr ~OptionalPayload() = default; + constexpr OptionalPayload(const OptionalPayload &) = default; + constexpr OptionalPayload(OptionalPayload &&) = default; + constexpr OptionalPayload& operator=(const OptionalPayload &) = default; + + constexpr OptionalPayload &operator=(OptionalPayload &&rhs) { + this->MoveAssign(std::move(rhs)); + return *this; + } + }; + + template + struct OptionalPayload : OptionalPayloadBase { + using OptionalPayloadBase::OptionalPayloadBase; + + constexpr OptionalPayload() = default; + constexpr ~OptionalPayload() = default; + constexpr OptionalPayload(const OptionalPayload &) = default; + constexpr OptionalPayload(OptionalPayload &&) = default; + + constexpr OptionalPayload &operator=(const OptionalPayload &rhs) { + this->CopyAssign(rhs); + return *this; + } + + constexpr OptionalPayload &operator=(OptionalPayload &&rhs) { + this->MoveAssign(std::move(rhs)); + return *this; + } + }; + + template + struct OptionalPayload : OptionalPayload { + using OptionalPayload::OptionalPayload; + + constexpr OptionalPayload() = default; + constexpr OptionalPayload(const OptionalPayload &) = default; + constexpr OptionalPayload(OptionalPayload &&) = default; + constexpr OptionalPayload& operator=(const OptionalPayload &) = default; + constexpr OptionalPayload& operator=(OptionalPayload &&) = default; + + constexpr ~OptionalPayload() { this->Reset(); } + }; + + template + class OptionalBaseImpl { + protected: + using StoredType = std::remove_const::type; + + template + constexpr void ConstructImpl(Args &&... args) { static_cast(this)->m_payload.Construct(std::forward(args)...); } + + constexpr void DestructImpl() { static_cast(this)->m_payload.Destroy(); } + + constexpr void ResetImpl() { static_cast(this)->m_payload.Reset(); } + + constexpr ALWAYS_INLINE bool IsEngagedImpl() const { return static_cast(this)->m_payload.m_engaged; } + + constexpr ALWAYS_INLINE T &GetImpl() { return static_cast(this)->m_payload.Get(); } + constexpr ALWAYS_INLINE const T &GetImpl() const { return static_cast(this)->m_payload.Get(); } + }; + + template::value, bool = std::is_trivially_move_constructible::value> + struct OptionalBase : OptionalBaseImpl> { + OptionalPayload m_payload; + + constexpr OptionalBase() = default; + + template::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, Args &&... args) : m_payload(in_place, std::forward(args)...) { /* ... */ } + + template &, Args...>::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, std::initializer_list il, Args &&... args) : m_payload(in_place, il, std::forward(args)...) { /* ... */ } + + constexpr OptionalBase(const OptionalBase &rhs) : m_payload(rhs.m_payload.m_engaged, rhs.m_payload) { /* ... */ } + constexpr OptionalBase(OptionalBase &&rhs) : m_payload(rhs.m_payload.m_engaged, std::move(rhs.m_payload)) { /* ... */ } + + constexpr OptionalBase &operator=(const OptionalBase &) = default; + constexpr OptionalBase &operator=(OptionalBase &&) = default; + }; + + template + struct OptionalBase : OptionalBaseImpl> { + OptionalPayload m_payload; + + constexpr OptionalBase() = default; + + template::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, Args &&... args) : m_payload(in_place, std::forward(args)...) { /* ... */ } + + template &, Args...>::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, std::initializer_list il, Args &&... args) : m_payload(in_place, il, std::forward(args)...) { /* ... */ } + + constexpr OptionalBase(const OptionalBase &rhs) : m_payload(rhs.m_payload.m_engaged, rhs.m_payload) { /* ... */ } + constexpr OptionalBase(OptionalBase &&rhs) = default; + + constexpr OptionalBase &operator=(const OptionalBase &) = default; + constexpr OptionalBase &operator=(OptionalBase &&) = default; + }; + + template + struct OptionalBase : OptionalBaseImpl> { + OptionalPayload m_payload; + + constexpr OptionalBase() = default; + + template::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, Args &&... args) : m_payload(in_place, std::forward(args)...) { /* ... */ } + + template &, Args...>::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, std::initializer_list il, Args &&... args) : m_payload(in_place, il, std::forward(args)...) { /* ... */ } + + constexpr OptionalBase(const OptionalBase &rhs) = default; + constexpr OptionalBase(OptionalBase &&rhs) : m_payload(rhs.m_payload.m_engaged, std::move(rhs.m_payload)) { /* ... */ } + + constexpr OptionalBase &operator=(const OptionalBase &) = default; + constexpr OptionalBase &operator=(OptionalBase &&) = default; + }; + + template + struct OptionalBase : OptionalBaseImpl> { + OptionalPayload m_payload; + + constexpr OptionalBase() = default; + + template::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, Args &&... args) : m_payload(in_place, std::forward(args)...) { /* ... */ } + + template &, Args...>::value, bool> = false> + constexpr explicit OptionalBase(in_place_t, std::initializer_list il, Args &&... args) : m_payload(in_place, il, std::forward(args)...) { /* ... */ } + + constexpr OptionalBase(const OptionalBase &rhs) = default; + constexpr OptionalBase(OptionalBase &&rhs) = default; + + constexpr OptionalBase &operator=(const OptionalBase &) = default; + constexpr OptionalBase &operator=(OptionalBase &&) = default; + }; + + } + + template + class optional; + + namespace impl { + + template + constexpr inline bool ConvertsFromOptional = std::is_constructible &>::value || + std::is_constructible &>::value || + std::is_constructible &&>::value || + std::is_constructible &&>::value || + std::is_convertible &, T>::value || + std::is_convertible &, T>::value || + std::is_convertible &&, T>::value || + std::is_convertible &&, T>::value; + + template + constexpr inline bool AssignsFromOptional = std::is_assignable &>::value || + std::is_assignable &>::value || + std::is_assignable &&>::value || + std::is_assignable &&>::value; + + } + + template + class optional : private impl::OptionalBase, private impl::EnableCopyMove::value, std::is_copy_constructible::value && std::is_copy_assignable::value, std::is_move_constructible::value, std::is_move_constructible::value && std::is_move_assignable::value, optional> { + static_assert(!std::is_same, ::ams::util::nullopt_t>::value); + static_assert(!std::is_same, ::ams::util::in_place_t>::value); + static_assert(!std::is_reference::value); + private: + using Base = impl::OptionalBase; + + template static constexpr inline bool IsNotSelf = !std::is_same>::value; + template static constexpr inline bool IsNotTag = !std::is_same<::ams::util::in_place_t, std::remove_cvref_t>::value && !std::is_same<::std::in_place_t, std::remove_cvref_t>::value; + + template + using Requires = std::enable_if_t<(Cond && ...), bool>; + public: + using value_type = T; + public: + constexpr optional() { /* ... */ } + constexpr optional(nullopt_t) { /* ... */ } + + template, IsNotTag, std::is_constructible::value, std::is_convertible::value> = true> + constexpr optional(U &&u) : Base(::ams::util::in_place, std::forward(u)) { /* ... */ } + + template, IsNotTag, std::is_constructible::value, !std::is_convertible::value> = false> + constexpr explicit optional(U &&u) : Base(::ams::util::in_place, std::forward(u)) { /* ... */ } + + template::value, std::is_constructible::value, std::is_convertible::value, !impl::ConvertsFromOptional> = true> + constexpr optional(const optional &u) { + if (u) { + this->emplace(*u); + } + } + + template::value, std::is_constructible::value, !std::is_convertible::value, !impl::ConvertsFromOptional> = false> + constexpr explicit optional(const optional &u) { + if (u) { + this->emplace(*u); + } + } + + template::value, std::is_constructible::value, std::is_convertible::value, !impl::ConvertsFromOptional> = true> + constexpr optional(optional &&u) { + if (u) { + this->emplace(std::move(*u)); + } + } + + template::value, std::is_constructible::value, !std::is_convertible::value, !impl::ConvertsFromOptional> = false> + constexpr explicit optional(optional &&u) { + if (u) { + this->emplace(std::move(*u)); + } + } + + template::value> = false> + constexpr explicit optional(in_place_t, Args &&... args) : Base(::ams::util::in_place, std::forward(args)...) { /* ... */ } + + template &, Args...>::value> = false> + constexpr explicit optional(in_place_t, std::initializer_list il, Args &&... args) : Base(::ams::util::in_place, il, std::forward(args)...) { /* ... */ } + + constexpr optional &operator=(nullopt_t) { this->ResetImpl(); return *this; } + + template + constexpr std::enable_if_t && !(std::is_scalar::value && std::is_same>::value) && std::is_constructible::value && std::is_assignable::value, + optional &> + operator =(U &&u) { + if (this->IsEngagedImpl()) { + this->GetImpl() = std::forward(u); + } else { + this->ConstructImpl(std::forward(u)); + } + + return *this; + } + + template + constexpr std::enable_if_t::value && std::is_constructible::value && std::is_assignable::value && !impl::ConvertsFromOptional && !impl::AssignsFromOptional, + optional &> + operator =(const optional &u) { + if (u) { + if (this->IsEngagedImpl()) { + this->GetImpl() = *u; + } else { + this->ConstructImpl(*u); + } + } else { + this->ResetImpl(); + } + + return *this; + } + + template + constexpr std::enable_if_t::value && std::is_constructible::value && std::is_assignable::value && !impl::ConvertsFromOptional && !impl::AssignsFromOptional, + optional &> + operator =(optional &&u) { + if (u) { + if (this->IsEngagedImpl()) { + this->GetImpl() = std::move(*u); + } else { + this->ConstructImpl(std::move(*u)); + } + } else { + this->ResetImpl(); + } + + return *this; + } + + template + constexpr std::enable_if_t::value, T &> emplace(Args &&... args) { + this->ResetImpl(); + this->ConstructImpl(std::forward(args)...); + return this->GetImpl(); + } + + template + constexpr std::enable_if_t &, Args...>::value, T &> emplace(std::initializer_list il, Args &&... args) { + this->ResetImpl(); + this->ConstructImpl(il, std::forward(args)...); + return this->GetImpl(); + } + + constexpr void swap(optional &rhs) { + if (this->IsEngagedImpl() && rhs.IsEngagedImpl()) { + std::swap(this->GetImpl(), rhs.GetImpl()); + } else if (this->IsEngagedImpl()) { + rhs.ConstructImpl(std::move(this->GetImpl())); + this->DestructImpl(); + } else if (rhs.IsEngagedImpl()) { + this->ConstructImpl(std::move(rhs.GetImpl())); + rhs.DestructImpl(); + } + } + + constexpr ALWAYS_INLINE const T *operator ->() const { return std::addressof(this->GetImpl()); } + constexpr ALWAYS_INLINE T *operator ->() { return std::addressof(this->GetImpl()); } + + constexpr ALWAYS_INLINE const T &operator *() const & { return this->GetImpl(); } + constexpr ALWAYS_INLINE T &operator *() & { return this->GetImpl(); } + + constexpr ALWAYS_INLINE const T &&operator *() const && { return std::move(this->GetImpl()); } + constexpr ALWAYS_INLINE T &&operator *() && { return std::move(this->GetImpl()); } + + constexpr ALWAYS_INLINE explicit operator bool() const { return this->IsEngagedImpl(); } + constexpr ALWAYS_INLINE bool has_value() const { return this->IsEngagedImpl(); } + + constexpr ALWAYS_INLINE const T &value() const & { /* AMS_ASSERT(this->IsEngagedImpl()); */ return this->GetImpl(); } + constexpr ALWAYS_INLINE T &value() & { /* AMS_ASSERT(this->IsEngagedImpl()); */ return this->GetImpl(); } + + constexpr ALWAYS_INLINE const T &&value() const && { /* AMS_ASSERT(this->IsEngagedImpl()); */ return std::move(this->GetImpl()); } + constexpr ALWAYS_INLINE T &&value() && { /* AMS_ASSERT(this->IsEngagedImpl()); */ return std::move(this->GetImpl()); } + + template + constexpr T value_or(U &&u) const & { + static_assert(std::is_copy_constructible::value); + static_assert(std::is_convertible::value); + + return this->IsEngagedImpl() ? this->GetImpl() : static_cast(std::forward(u)); + } + + template + constexpr T value_or(U &&u) && { + static_assert(std::is_move_constructible::value); + static_assert(std::is_convertible::value); + + return this->IsEngagedImpl() ? std::move(this->GetImpl()) : static_cast(std::forward(u)); + } + + constexpr void reset() { this->ResetImpl(); } + }; + + namespace impl { + + template using optional_relop_t = std::enable_if_t::value, bool>; + + template using optional_eq_t = optional_relop_t() == std::declval())>; + template using optional_ne_t = optional_relop_t() != std::declval())>; + template using optional_le_t = optional_relop_t() <= std::declval())>; + template using optional_ge_t = optional_relop_t() >= std::declval())>; + template using optional_lt_t = optional_relop_t() < std::declval())>; + template using optional_gt_t = optional_relop_t() > std::declval())>; + + } + + template + constexpr inline impl::optional_eq_t operator==(const optional &lhs, const optional &rhs) { return static_cast(lhs) == static_cast(rhs) && (!lhs || *lhs == *rhs); } + + template + constexpr inline impl::optional_ne_t operator!=(const optional &lhs, const optional &rhs) { return static_cast(lhs) != static_cast(rhs) || (static_cast(lhs) && *lhs != *rhs); } + + template + constexpr inline impl::optional_lt_t operator< (const optional &lhs, const optional &rhs) { return static_cast(rhs) && (!lhs || *lhs < *rhs); } + + template + constexpr inline impl::optional_gt_t operator> (const optional &lhs, const optional &rhs) { return static_cast(lhs) && (!rhs || *lhs > *rhs); } + + template + constexpr inline impl::optional_le_t operator<=(const optional &lhs, const optional &rhs) { return !lhs || (static_cast(rhs) && *lhs <= *rhs); } + + template + constexpr inline impl::optional_ge_t operator>=(const optional &lhs, const optional &rhs) { return !rhs || (static_cast(lhs) && *lhs >= *rhs); } + + template U> + constexpr inline std::compare_three_way_result_t operator <=>(const optional &lhs, const optional &rhs) { + return (lhs && rhs) ? *lhs <=> *rhs : static_cast(lhs) <=> static_cast(rhs); + } + + template constexpr inline bool operator==(const optional &lhs, nullopt_t) { return !lhs; } + + template constexpr inline std::strong_ordering operator<=>(const optional &lhs, nullopt_t) { return static_cast(lhs) <=> false; } + + template + constexpr inline impl::optional_eq_t operator==(const optional &lhs, const U &rhs) { return lhs && *lhs == rhs; } + + template + constexpr inline impl::optional_eq_t operator==(const U &lhs, const optional &rhs) { return rhs && lhs == *rhs; } + + template + constexpr inline impl::optional_ne_t operator!=(const optional &lhs, const U &rhs) { return !lhs || *lhs != rhs; } + + template + constexpr inline impl::optional_ne_t operator!=(const U &lhs, const optional &rhs) { return !rhs || lhs != *rhs; } + + template + constexpr inline impl::optional_lt_t operator< (const optional &lhs, const U &rhs) { return !lhs || *lhs < rhs; } + + template + constexpr inline impl::optional_lt_t operator< (const U &lhs, const optional &rhs) { return rhs && lhs < *rhs; } + + template + constexpr inline impl::optional_gt_t operator> (const optional &lhs, const U &rhs) { return lhs && *lhs > rhs; } + + template + constexpr inline impl::optional_gt_t operator> (const U &lhs, const optional &rhs) { return !rhs || lhs > *rhs; } + + template + constexpr inline impl::optional_le_t operator<=(const optional &lhs, const U &rhs) { return !lhs || *lhs <= rhs; } + + template + constexpr inline impl::optional_le_t operator<=(const U &lhs, const optional &rhs) { return rhs && lhs <= *rhs; } + + template + constexpr inline impl::optional_ge_t operator>=(const optional &lhs, const U &rhs) { return lhs && *lhs >= rhs; } + + template + constexpr inline impl::optional_ge_t operator>=(const U &lhs, const optional &rhs) { return !rhs || lhs >= *rhs; } + + namespace impl { + + template + constexpr inline bool IsOptional = false; + + template + constexpr inline bool IsOptional> = true; + + } + + template requires (!impl::IsOptional) && std::three_way_comparable_with + constexpr inline std::compare_three_way_result_t operator<=>(const optional &lhs, const U &rhs) { + return static_cast(lhs) ? *lhs <=> rhs : std::strong_ordering::less; + } + + template + constexpr inline std::enable_if_t, T>::value, optional>> make_optional(T && t) { return optional>{ std::forward(t) }; } + + template + constexpr inline std::enable_if_t::value, optional> make_optional(Args &&... args) { return optional{ ::ams::util::in_place, std::forward(args)... }; } + + template + constexpr inline std::enable_if_t &, Args...>::value, optional> make_optional(std::initializer_list il, Args &&... args) { return optional{ ::ams::util::in_place, il, std::forward(args)... }; } + + template optional(T) -> optional; + +} + +namespace std { + + template + constexpr inline enable_if_t && is_swappable_v> swap(::ams::util::optional &lhs, ::ams::util::optional &rhs) noexcept { + lhs.swap(rhs); + } + + template + constexpr inline enable_if_t && is_swappable_v)> swap(::ams::util::optional &lhs, ::ams::util::optional &rhs) = delete; + +} diff --git a/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp b/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp index 87f57d5a6..9d7710664 100644 --- a/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_prodinfo_utils.cpp @@ -431,7 +431,7 @@ namespace ams::mitm { alignas(os::MemoryPageSize) CalibrationInfo g_temp_calibration_info = {}; - void SaveProdInfoBackup(std::optional *dst, const CalibrationInfo &info) { + void SaveProdInfoBackup(util::optional *dst, const CalibrationInfo &info) { char backup_fn[0x100]; GetBackupFileName(backup_fn, sizeof(backup_fn), info); @@ -505,9 +505,9 @@ namespace ams::mitm { alignas(os::MemoryPageSize) CalibrationInfo g_blank_calibration_info = {}; alignas(os::MemoryPageSize) SecureCalibrationInfoBackup g_secure_calibration_info_backup = {}; - std::optional g_prodinfo_backup_file; - std::optional g_blank_prodinfo_storage; - std::optional g_fake_secure_backup_storage; + util::optional g_prodinfo_backup_file; + util::optional g_blank_prodinfo_storage; + util::optional g_fake_secure_backup_storage; bool g_allow_writes = false; bool g_has_secure_backup = false; diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp index ff062c3ed..ed2c8d626 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp @@ -95,7 +95,7 @@ namespace ams::mitm::sysupdater { private: Result result; os::SystemEvent event; - std::optional thread_info; + util::optional thread_info; ncm::InstallTaskBase *task; public: AsyncPrepareSdCardUpdateImpl(ncm::InstallTaskBase *task) : result(ResultSuccess()), event(os::EventClearMode_ManualClear, true), thread_info(), task(task) { /* ... */ } diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp index 03282d749..f47fb78f1 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp @@ -497,7 +497,7 @@ namespace ams::mitm::sysupdater { R_TRY(this->update_transfer_memory->Map(std::addressof(tmem_buffer), os::MemoryPermission_None)); auto tmem_guard = SCOPE_GUARD { this->update_transfer_memory->Unmap(); - this->update_transfer_memory = std::nullopt; + this->update_transfer_memory = util::nullopt; }; /* Now that the memory is mapped, the input handle is managed and can be released. */ diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp index cce63e1d6..6f103bd20 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp @@ -57,8 +57,8 @@ namespace ams::mitm::sysupdater { class SystemUpdateService { private: SystemUpdateApplyManager apply_manager; - std::optional update_task; - std::optional update_transfer_memory; + util::optional update_task; + util::optional update_transfer_memory; bool setup_update; bool requested_update; public: diff --git a/stratosphere/spl/source/spl_api_impl.cpp b/stratosphere/spl/source/spl_api_impl.cpp index 2a5550d12..0d3426ba5 100644 --- a/stratosphere/spl/source/spl_api_impl.cpp +++ b/stratosphere/spl/source/spl_api_impl.cpp @@ -42,7 +42,7 @@ namespace ams::spl::impl { /* KeySlot management. */ KeySlotCache g_keyslot_cache; - std::optional g_keyslot_cache_entry[MaxPhysicalAesKeySlots]; + util::optional g_keyslot_cache_entry[MaxPhysicalAesKeySlots]; inline s32 GetMaxPhysicalKeySlots() { return (hos::GetVersion() >= hos::Version_6_0_0) ? MaxPhysicalAesKeySlots : MaxPhysicalAesKeySlotsDeprecated;