From 21f3d29df755a93ee8ac4d381fdb473abd815fc6 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 26 Apr 2021 20:05:56 -0700 Subject: [PATCH] strat: compat with gcc 11 --- .../include/stratosphere/kvdb/kvdb_bounded_string.hpp | 8 ++++---- .../include/stratosphere/tipc/tipc_object_manager.hpp | 2 +- .../libstratosphere/source/ams/ams_environment.cpp | 4 ++-- libraries/libstratosphere/source/fs/fs_bis.cpp | 2 +- .../htcs/client/htcs_virtual_socket_collection.cpp | 3 ++- .../driver/board/nintendo/nx/impl/i2c_bus_manager.hpp | 3 ++- .../nintendo/nx/impl/i2c_device_property_manager.hpp | 3 ++- .../driver/board/nintendo/nx/impl/i2c_i_allocator.hpp | 2 ++ .../source/mem/impl/mem_impl_platform.os.horizon.cpp | 9 +++++---- .../driver/board/nintendo/nx/pinmux_platform_pads.cpp | 1 - stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp | 10 +++++----- 11 files changed, 26 insertions(+), 21 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp index 322a3641b..9332449d7 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp @@ -58,7 +58,7 @@ namespace ams::kvdb { /* Getters. */ size_t GetLength() const { - return strnlen(this->buffer, N); + return util::Strnlen(this->buffer, N); } const char *Get() const { @@ -72,7 +72,7 @@ namespace ams::kvdb { /* Setters. */ void Set(const char *s) { /* Ensure string can fit in our buffer. */ - CheckLength(strnlen(s, N)); + CheckLength(util::Strnlen(s, N)); std::strncpy(this->buffer, s, N); this->buffer[N - 1] = 0; } @@ -88,7 +88,7 @@ namespace ams::kvdb { /* Append to existing. */ void Append(const char *s) { const size_t length = GetLength(); - CheckLength(length + strnlen(s, N)); + CheckLength(length + util::Strnlen(s, N)); std::strncat(this->buffer, s, N - length - 1); } @@ -137,7 +137,7 @@ namespace ams::kvdb { } bool EndsWith(const char *s) const { - const size_t suffix_length = strnlen(s, N); + const size_t suffix_length = util::Strnlen(s, N); const size_t length = GetLength(); return suffix_length <= length && EndsWith(s, length - suffix_length); } diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp index c395fa7bd..a0b8f9942 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_object_manager.hpp @@ -26,7 +26,7 @@ namespace ams::tipc { constexpr inline u16 MethodId_CloseSession = 0xF; class ObjectManagerBase { - private: + protected: struct Entry { util::TypedStorage object; os::WaitableHolderType waitable_holder; diff --git a/libraries/libstratosphere/source/ams/ams_environment.cpp b/libraries/libstratosphere/source/ams/ams_environment.cpp index a42776b23..597a46277 100644 --- a/libraries/libstratosphere/source/ams/ams_environment.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment.cpp @@ -117,7 +117,7 @@ namespace ams { StackFrame cur_frame; svc::lp64::MemoryInfo mem_info; svc::PageInfo page_info; - if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), cur_fp)) && (mem_info.perm & Perm_R) == Perm_R) { + if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), cur_fp)) && (mem_info.perm & svc::MemoryPermission_Read) == svc::MemoryPermission_Read) { std::memcpy(&cur_frame, reinterpret_cast(cur_fp), sizeof(cur_frame)); } else { break; @@ -136,7 +136,7 @@ namespace ams { { svc::lp64::MemoryInfo mem_info; svc::PageInfo page_info; - if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), ams_ctx.sp)) && (mem_info.perm & Perm_R) == Perm_R) { + if (R_SUCCEEDED(svc::QueryMemory(std::addressof(mem_info), std::addressof(page_info), ams_ctx.sp)) && (mem_info.perm & svc::MemoryPermission_Read) == svc::MemoryPermission_Read) { size_t copy_size = std::min(FatalErrorContext::MaxStackDumpSize, static_cast(mem_info.addr + mem_info.size - ams_ctx.sp)); ams_ctx.stack_dump_size = copy_size; std::memcpy(ams_ctx.stack_dump, reinterpret_cast(ams_ctx.sp), copy_size); diff --git a/libraries/libstratosphere/source/fs/fs_bis.cpp b/libraries/libstratosphere/source/fs/fs_bis.cpp index 021913d71..da396e6a0 100644 --- a/libraries/libstratosphere/source/fs/fs_bis.cpp +++ b/libraries/libstratosphere/source/fs/fs_bis.cpp @@ -29,7 +29,7 @@ namespace ams::fs { virtual Result GenerateCommonMountName(char *dst, size_t dst_size) override { /* Determine how much space we need. */ const char *bis_mount_name = GetBisMountName(this->id); - const size_t needed_size = strnlen(bis_mount_name, MountNameLengthMax) + 2; + const size_t needed_size = util::Strnlen(bis_mount_name, MountNameLengthMax) + 2; AMS_ABORT_UNLESS(dst_size >= needed_size); /* Generate the name. */ diff --git a/libraries/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp b/libraries/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp index 1ef63f254..cb7dc3e9c 100644 --- a/libraries/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp +++ b/libraries/libstratosphere/source/htcs/client/htcs_virtual_socket_collection.cpp @@ -219,10 +219,11 @@ namespace ams::htcs::client { sf::SharedPointer socket = nullptr; /* Find the socket. */ + s32 index; { std::scoped_lock lk(m_mutex); - if (auto index = this->Find(id, std::addressof(error_code)); index >= 0) { + if (index = this->Find(id, std::addressof(error_code)); index >= 0) { /* Get the socket's object. */ VirtualSocket *virt_socket = m_socket_list + index; socket = virt_socket->m_socket; diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp index 358badce0..86e598af0 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_manager.hpp @@ -21,7 +21,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { class I2cBusAccessorManager : public IAllocator { - /* ... */ + public: + using IAllocator::IAllocator; }; } diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp index e0a1e22d9..ac6a2b546 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_device_property_manager.hpp @@ -20,7 +20,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { class I2cDevicePropertyManager : public IAllocator { - /* ... */ + public: + using IAllocator::IAllocator; }; } diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp index 13cb57d08..41e51dfd7 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp @@ -20,6 +20,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { template class IAllocator { + NON_COPYABLE(IAllocator); + NON_MOVEABLE(IAllocator); private: using T = typename ListType::value_type; private: diff --git a/libraries/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp b/libraries/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp index 11370ec54..db487e31a 100644 --- a/libraries/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp +++ b/libraries/libstratosphere/source/mem/impl/mem_impl_platform.os.horizon.cpp @@ -20,9 +20,9 @@ namespace ams::mem::impl { namespace { - os::Mutex g_virt_mem_enabled_lock(false); - bool g_virt_mem_enabled_detected; - bool g_virt_mem_enabled; + constinit os::SdkMutex g_virt_mem_enabled_lock; + constinit bool g_virt_mem_enabled_detected = false; + constinit bool g_virt_mem_enabled = false; void EnsureVirtualAddressMemoryDetected() { std::scoped_lock lk(g_virt_mem_enabled_lock); @@ -48,7 +48,8 @@ namespace ams::mem::impl { ALWAYS_INLINE os::MemoryPermission ConvertToOsPermission(Prot prot) { static_assert(static_cast(Prot_read) == static_cast(os::MemoryPermission_ReadOnly)); static_assert(static_cast(Prot_write) == static_cast(os::MemoryPermission_WriteOnly)); - return static_cast(prot & os::MemoryPermission_ReadWrite); + static_assert((util::ToUnderlying(Prot_read) | util::ToUnderlying(Prot_write)) == util::ToUnderlying(os::MemoryPermission_ReadWrite)); + return static_cast(prot & (Prot_read | Prot_write)); } } diff --git a/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp b/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp index eb30b7e9e..2ab338563 100644 --- a/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp +++ b/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp @@ -477,7 +477,6 @@ namespace ams::pinmux::driver::board::nintendo::nx { u32 reg_address; u32 reg_mask; u32 reg_value; - u8 safe_func; const char *pad_name; private: bool IsValidRegisterAddress() const { diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp index 21f027328..aca817b8c 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp @@ -28,7 +28,7 @@ namespace ams::dmnt::cheat::impl { class FrozenAddressMapEntry : public util::IntrusiveRedBlackTreeBaseNode { public: - using LightCompareType = u64; + using RedBlackKeyType = u64; private: u64 m_address; FrozenAddressValue m_value; @@ -40,7 +40,7 @@ namespace ams::dmnt::cheat::impl { constexpr const FrozenAddressValue &GetValue() const { return m_value; } constexpr FrozenAddressValue &GetValue() { return m_value; } - static constexpr ALWAYS_INLINE int Compare(const LightCompareType &lval, const FrozenAddressMapEntry &rhs) { + static constexpr ALWAYS_INLINE int Compare(const RedBlackKeyType &lval, const FrozenAddressMapEntry &rhs) { const auto rval = rhs.GetAddress(); if (lval < rval) { @@ -603,7 +603,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - const auto it = this->frozen_addresses_map.find_light(address); + const auto it = this->frozen_addresses_map.find_key(address); R_UNLESS(it != this->frozen_addresses_map.end(), ResultFrozenAddressNotFound()); frz_addr->address = it->GetAddress(); @@ -616,7 +616,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - const auto it = this->frozen_addresses_map.find_light(address); + const auto it = this->frozen_addresses_map.find_key(address); R_UNLESS(it == this->frozen_addresses_map.end(), ResultFrozenAddressAlreadyExists()); FrozenAddressValue value = {}; @@ -636,7 +636,7 @@ namespace ams::dmnt::cheat::impl { R_TRY(this->EnsureCheatProcess()); - const auto it = this->frozen_addresses_map.find_light(address); + const auto it = this->frozen_addresses_map.find_key(address); R_UNLESS(it != this->frozen_addresses_map.end(), ResultFrozenAddressNotFound()); FrozenAddressMapEntry *entry = std::addressof(*it);