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

@@ -26,19 +26,19 @@ namespace ams::fssrv::fscreator {
size_t size;
/* Read the Acid signature key generation. */
constexpr s64 AcidSignatureKeyGenerationOffset = offsetof(ldr::Npdm, signature_key_generation);
constexpr s64 AcidSignatureKeyGenerationOffset = AMS_OFFSETOF(ldr::Npdm, signature_key_generation);
u32 acid_signature_key_generation;
R_TRY(file->Read(std::addressof(size), AcidSignatureKeyGenerationOffset, std::addressof(acid_signature_key_generation), sizeof(acid_signature_key_generation), fs::ReadOption()));
R_UNLESS(size == sizeof(acid_signature_key_generation), fs::ResultInvalidAcidFileSize());
/* Read the Acid offset. */
constexpr s64 AcidOffsetOffset = offsetof(ldr::Npdm, acid_offset);
constexpr s64 AcidOffsetOffset = AMS_OFFSETOF(ldr::Npdm, acid_offset);
s32 acid_offset;
R_TRY(file->Read(std::addressof(size), AcidOffsetOffset, std::addressof(acid_offset), sizeof(acid_offset), fs::ReadOption()));
R_UNLESS(size == sizeof(acid_offset), fs::ResultInvalidAcidFileSize());
/* Read the Acid size. */
constexpr s64 AcidSizeOffset = offsetof(ldr::Npdm, acid_size);
constexpr s64 AcidSizeOffset = AMS_OFFSETOF(ldr::Npdm, acid_size);
s32 acid_size;
R_TRY(file->Read(std::addressof(size), AcidSizeOffset, std::addressof(acid_size), sizeof(acid_size), fs::ReadOption()));
R_UNLESS(size == sizeof(acid_size), fs::ResultInvalidAcidFileSize());

View File

@@ -42,7 +42,7 @@ namespace ams::os::impl {
return GetReference(parent.all_threads_node);
}
static constexpr size_t Offset = OFFSETOF(ThreadType, all_threads_node);
static constexpr size_t Offset = AMS_OFFSETOF(ThreadType, all_threads_node);
static ThreadType &GetParent(util::IntrusiveListNode &node) {
return *reinterpret_cast<ThreadType *>(reinterpret_cast<char *>(std::addressof(node)) - Offset);

View File

@@ -34,7 +34,7 @@ namespace ams::osdbg::impl {
u64 p_thread_type;
};
static_assert(sizeof(ThreadLocalRegionLp64) == sizeof(svc::ThreadLocalRegion));
static_assert(__builtin_offsetof(ThreadLocalRegionLp64, tls) == 0x180);
static_assert(AMS_OFFSETOF(ThreadLocalRegionLp64, tls) == 0x180);
struct ThreadLocalRegionIlp32 {
@@ -51,7 +51,7 @@ namespace ams::osdbg::impl {
u32 p_thread_type;
};
static_assert(sizeof(ThreadLocalRegionIlp32) == sizeof(svc::ThreadLocalRegion));
static_assert(__builtin_offsetof(ThreadLocalRegionIlp32, tls) == 0x1C0);
static_assert(AMS_OFFSETOF(ThreadLocalRegionIlp32, tls) == 0x1C0);
struct LibnxThreadVars {
static constexpr u32 Magic = util::FourCC<'!','T','V','$'>::Code;
@@ -73,7 +73,7 @@ namespace ams::osdbg::impl {
LibnxThreadVars thread_vars;
};
static_assert(sizeof(ThreadLocalRegionLibnx) == sizeof(svc::ThreadLocalRegion));
static_assert(__builtin_offsetof(ThreadLocalRegionLibnx, thread_vars) == 0x1E0);
static_assert(AMS_OFFSETOF(ThreadLocalRegionLibnx, thread_vars) == 0x1E0);
struct LibnxThreadEntryArgs {
u64 t;

View File

@@ -297,10 +297,10 @@ namespace ams::spl::impl {
auto &layout = *reinterpret_cast<DecryptAesLayout *>(g_work_buffer);
layout.crypt_ctx.in.num_entries = 0;
layout.crypt_ctx.in.address = g_work_buffer_mapped_address + offsetof(DecryptAesLayout, in_buffer);
layout.crypt_ctx.in.address = g_work_buffer_mapped_address + AMS_OFFSETOF(DecryptAesLayout, in_buffer);
layout.crypt_ctx.in.size = sizeof(layout.in_buffer);
layout.crypt_ctx.out.num_entries = 0;
layout.crypt_ctx.out.address = g_work_buffer_mapped_address + offsetof(DecryptAesLayout, out_buffer);
layout.crypt_ctx.out.address = g_work_buffer_mapped_address + AMS_OFFSETOF(DecryptAesLayout, out_buffer);
layout.crypt_ctx.out.size = sizeof(layout.out_buffer);
std::memcpy(layout.in_buffer, src, sizeof(layout.in_buffer));
@@ -312,8 +312,8 @@ namespace ams::spl::impl {
smc::AsyncOperationKey op_key;
const IvCtr iv_ctr = {};
const u32 mode = smc::GetComputeAesMode(smc::CipherMode::CbcDecrypt, GetPhysicalAesKeySlot(keyslot, true));
const u32 dst_ll_addr = g_work_buffer_mapped_address + offsetof(DecryptAesLayout, crypt_ctx.out);
const u32 src_ll_addr = g_work_buffer_mapped_address + offsetof(DecryptAesLayout, crypt_ctx.in);
const u32 dst_ll_addr = g_work_buffer_mapped_address + AMS_OFFSETOF(DecryptAesLayout, crypt_ctx.out);
const u32 src_ll_addr = g_work_buffer_mapped_address + AMS_OFFSETOF(DecryptAesLayout, crypt_ctx.in);
smc::Result res = smc::ComputeAes(std::addressof(op_key), dst_ll_addr, mode, iv_ctr, src_ll_addr, sizeof(layout.out_buffer));
if (res != smc::Result::Success) {
@@ -666,8 +666,8 @@ namespace ams::spl::impl {
std::scoped_lock lk(g_operation_lock);
const u32 mode = smc::GetComputeAesMode(smc::CipherMode::Ctr, GetPhysicalAesKeySlot(keyslot, true));
const u32 dst_ll_addr = g_work_buffer_mapped_address + offsetof(SeCryptContext, out);
const u32 src_ll_addr = g_work_buffer_mapped_address + offsetof(SeCryptContext, in);
const u32 dst_ll_addr = g_work_buffer_mapped_address + AMS_OFFSETOF(SeCryptContext, out);
const u32 src_ll_addr = g_work_buffer_mapped_address + AMS_OFFSETOF(SeCryptContext, in);
smc::AsyncOperationKey op_key;
smc::Result res = smc::ComputeAes(std::addressof(op_key), dst_ll_addr, mode, iv_ctr, src_ll_addr, src_size);