1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-18 00:12:03 +00:00

strat: compat with gcc 11

This commit is contained in:
Michael Scire 2021-04-26 20:05:56 -07:00
parent 4f16106702
commit 21f3d29df7
11 changed files with 26 additions and 21 deletions

View file

@ -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);
}

View file

@ -26,7 +26,7 @@ namespace ams::tipc {
constexpr inline u16 MethodId_CloseSession = 0xF;
class ObjectManagerBase {
private:
protected:
struct Entry {
util::TypedStorage<WaitableObject> object;
os::WaitableHolderType waitable_holder;

View file

@ -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<void *>(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<size_t>(mem_info.addr + mem_info.size - ams_ctx.sp));
ams_ctx.stack_dump_size = copy_size;
std::memcpy(ams_ctx.stack_dump, reinterpret_cast<void *>(ams_ctx.sp), copy_size);

View file

@ -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. */

View file

@ -219,10 +219,11 @@ namespace ams::htcs::client {
sf::SharedPointer<tma::ISocket> 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;

View file

@ -21,7 +21,8 @@
namespace ams::i2c::driver::board::nintendo::nx::impl {
class I2cBusAccessorManager : public IAllocator<I2cBusAccessor::BusAccessorList> {
/* ... */
public:
using IAllocator<I2cBusAccessor::BusAccessorList>::IAllocator;
};
}

View file

@ -20,7 +20,8 @@
namespace ams::i2c::driver::board::nintendo::nx::impl {
class I2cDevicePropertyManager : public IAllocator<I2cDeviceProperty::DevicePropertyList> {
/* ... */
public:
using IAllocator<I2cDeviceProperty::DevicePropertyList>::IAllocator;
};
}

View file

@ -20,6 +20,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl {
template<typename ListType>
class IAllocator {
NON_COPYABLE(IAllocator);
NON_MOVEABLE(IAllocator);
private:
using T = typename ListType::value_type;
private:

View file

@ -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<int>(Prot_read) == static_cast<int>(os::MemoryPermission_ReadOnly));
static_assert(static_cast<int>(Prot_write) == static_cast<int>(os::MemoryPermission_WriteOnly));
return static_cast<os::MemoryPermission>(prot & os::MemoryPermission_ReadWrite);
static_assert((util::ToUnderlying(Prot_read) | util::ToUnderlying(Prot_write)) == util::ToUnderlying(os::MemoryPermission_ReadWrite));
return static_cast<os::MemoryPermission>(prot & (Prot_read | Prot_write));
}
}

View file

@ -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 {

View file

@ -28,7 +28,7 @@ namespace ams::dmnt::cheat::impl {
class FrozenAddressMapEntry : public util::IntrusiveRedBlackTreeBaseNode<FrozenAddressMapEntry> {
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);