From 0767d9f8daa0673cb8f77aa82f82865311307212 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 27 Apr 2021 23:16:31 -0700 Subject: [PATCH] ams: assume gcc 11 --- .../include/stratosphere/dd/dd_types.hpp | 11 ++------ .../stratosphere/tipc/tipc_server_manager.hpp | 26 ++++++++++++------- .../ncm/ncm_content_meta_database_impl.cpp | 6 ++--- .../include/vapours/util/util_bitutil.hpp | 2 -- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/dd/dd_types.hpp b/libraries/libstratosphere/include/stratosphere/dd/dd_types.hpp index 467708841..2c921903c 100644 --- a/libraries/libstratosphere/include/stratosphere/dd/dd_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/dd/dd_types.hpp @@ -20,14 +20,7 @@ namespace ams::dd { using ProcessHandle = ::Handle; - /* TODO gcc-11: using MemoryPermission = os::MemoryPermission; using enum os::MemoryPermission; */ - - enum MemoryPermission { - MemoryPermission_None = 0, - MemoryPermission_ReadOnly = (1u << 0), - MemoryPermission_WriteOnly = (1u << 1), - - MemoryPermission_ReadWrite = MemoryPermission_ReadOnly | MemoryPermission_WriteOnly, - }; + using MemoryPermission = os::MemoryPermission; + using enum os::MemoryPermission; } diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp index 9fa366571..05c9b4183 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp @@ -54,24 +54,30 @@ namespace ams::tipc { static constexpr inline bool IsDeferralSupported = !std::same_as; using ResumeKey = typename DeferralManagerType::Key; - static ALWAYS_INLINE uintptr_t ConvertKeyToMessage(ResumeKey key) { + static constexpr ALWAYS_INLINE uintptr_t ConvertKeyToMessage(ResumeKey key) { static_assert(sizeof(key) <= sizeof(uintptr_t)); static_assert(std::is_trivial::value); - /* TODO: std::bit_cast */ - uintptr_t converted = 0; - std::memcpy(std::addressof(converted), std::addressof(key), sizeof(key)); - return converted; + if constexpr (sizeof(key) == sizeof(uintptr_t)) { + return std::bit_cast(key); + } else { + uintptr_t converted = 0; + std::memcpy(std::addressof(converted), std::addressof(key), sizeof(key)); + return converted; + } } - static ALWAYS_INLINE ResumeKey ConvertMessageToKey(uintptr_t message) { + static constexpr ALWAYS_INLINE ResumeKey ConvertMessageToKey(uintptr_t message) { static_assert(sizeof(ResumeKey) <= sizeof(uintptr_t)); static_assert(std::is_trivial::value); - /* TODO: std::bit_cast */ - ResumeKey converted = {}; - std::memcpy(std::addressof(converted), std::addressof(message), sizeof(converted)); - return converted; + if constexpr (sizeof(ResumeKey) == sizeof(uintptr_t)) { + return std::bit_cast(message); + } else { + ResumeKey converted = {}; + std::memcpy(std::addressof(converted), std::addressof(message), sizeof(converted)); + return converted; + } } template requires (Ix < NumPorts) 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 c2a58baaf..cc515be1f 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp @@ -308,7 +308,7 @@ namespace ams::ncm { out_orphaned[i] = true; } - auto IsOrphanedContent = [](const sf::InArray &list, const ncm::ContentId &id) ALWAYS_INLINE_LAMBDA { + auto IsOrphanedContent = [] ALWAYS_INLINE_LAMBDA (const sf::InArray &list, const ncm::ContentId &id) -> std::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) { @@ -316,9 +316,7 @@ namespace ams::ncm { } } - /* TODO: C++20 (gcc 10) fixes ALWAYS_INLINE_LAMBDA in conjunction with trailing return types. */ - /* This should be changed to std::nullopt once possible. */ - return std::optional(std::nullopt); + return std::nullopt; }; /* Iterate over all entries. */ diff --git a/libraries/libvapours/include/vapours/util/util_bitutil.hpp b/libraries/libvapours/include/vapours/util/util_bitutil.hpp index bc52b45f4..7b7b2ddde 100644 --- a/libraries/libvapours/include/vapours/util/util_bitutil.hpp +++ b/libraries/libvapours/include/vapours/util/util_bitutil.hpp @@ -133,7 +133,6 @@ namespace ams::util { template requires std::integral constexpr ALWAYS_INLINE int PopCount(T x) { - /* TODO: C++20 std::bit_cast */ using U = typename std::make_unsigned::type; U u = static_cast(x); @@ -174,7 +173,6 @@ namespace ams::util { } return PopCount(static_cast(~x)); } else { - /* TODO: C++20 std::bit_cast */ using U = typename std::make_unsigned::type; const U u = static_cast(x); if constexpr (std::is_same::value) {