ams: improve offsetof style consistency

This commit is contained in:
Michael Scire 2021-10-18 00:17:13 -07:00
parent ec6d1a92ef
commit 889d843718
29 changed files with 140 additions and 142 deletions

View file

@ -50,7 +50,7 @@ namespace ams::crypto::impl {
public:
HmacImpl() : m_state(State_None) { /* ... */ }
~HmacImpl() {
static_assert(offsetof(HmacImpl, m_hash_function) == 0);
static_assert(AMS_OFFSETOF(HmacImpl, m_hash_function) == 0);
/* Clear everything except for the hash function. */
ClearMemory(reinterpret_cast<u8 *>(this) + sizeof(m_hash_function), sizeof(*this) - sizeof(m_hash_function));

View file

@ -563,7 +563,7 @@ namespace ams::svc {
u64 padding[6];
};
static_assert(sizeof(ProcessLocalRegion) == 0x200);
static_assert(OFFSETOF(ProcessLocalRegion, dying_message_region_address) == 0x1C0);
static_assert(AMS_OFFSETOF(ProcessLocalRegion, dying_message_region_address) == 0x1C0);
}
@ -607,7 +607,7 @@ namespace ams::svc {
u64 padding[6];
};
static_assert(sizeof(ProcessLocalRegion) == 0x200);
static_assert(OFFSETOF(ProcessLocalRegion, dying_message_region_address) == 0x1C0);
static_assert(AMS_OFFSETOF(ProcessLocalRegion, dying_message_region_address) == 0x1C0);
}

View file

@ -170,11 +170,8 @@ namespace ams::util {
/* Defines, for use by other code. */
#define OFFSETOF(parent, member) (::ams::util::impl::OffsetOf<&parent::member, parent>::value)
#define GET_PARENT_PTR(parent, member, _arg) (::ams::util::GetParentPointer<&parent::member, parent>(_arg))
#define GET_PARENT_REF(parent, member, _arg) (::ams::util::GetParentReference<&parent::member, parent>(_arg))
#define AMS_OFFSETOF(parent, member) (__builtin_offsetof(parent, member))
#define AMS_GET_PARENT_PTR(parent, member, _arg) (::ams::util::GetParentPointer<&parent::member, parent>(_arg))
#define AMS_GET_PARENT_REF(parent, member, _arg) (::ams::util::GetParentReference<&parent::member, parent>(_arg))
}

View file

@ -272,7 +272,7 @@ namespace ams::crypto::impl {
Block last_block = Block{ .block_128 = { m_msg_size, m_aad_size } };
/* Multiply the last block by 8 to account for bit vs byte sizes. */
static_assert(offsetof(Block128, hi) == 0);
static_assert(AMS_OFFSETOF(Block128, hi) == 0);
GaloisShiftLeft(std::addressof(last_block.block_128.hi));
GaloisShiftLeft(std::addressof(last_block.block_128.hi));
GaloisShiftLeft(std::addressof(last_block.block_128.hi));

View file

@ -123,7 +123,7 @@ namespace ams::sdmmc::impl {
public:
explicit SdmmcController(dd::PhysicalAddress registers_phys_addr) : SdHostStandardController(registers_phys_addr, SdmmcRegistersSize) {
/* Set sdmmc registers. */
static_assert(offsetof(SdmmcRegisters, sd_host_standard_registers) == 0);
static_assert(AMS_OFFSETOF(SdmmcRegisters, sd_host_standard_registers) == 0);
m_sdmmc_registers = reinterpret_cast<SdmmcRegisters *>(m_registers);
m_is_shutdown = true;