ams: improve offsetof style consistency
This commit is contained in:
@@ -267,9 +267,9 @@ namespace ams::fssystem {
|
||||
};
|
||||
static_assert(sizeof(NcaFsHeader) == NcaFsHeader::Size);
|
||||
static_assert(util::is_pod<NcaFsHeader>::value);
|
||||
static_assert(offsetof(NcaFsHeader, patch_info) == NcaPatchInfo::Offset);
|
||||
static_assert(AMS_OFFSETOF(NcaFsHeader, patch_info) == NcaPatchInfo::Offset);
|
||||
|
||||
inline constexpr const size_t NcaFsHeader::HashData::HierarchicalSha256Data::MasterHashOffset = offsetof(NcaFsHeader, hash_data.hierarchical_sha256_data.fs_data_master_hash);
|
||||
inline constexpr const size_t NcaFsHeader::HashData::IntegrityMetaInfo::MasterHashOffset = offsetof(NcaFsHeader, hash_data.integrity_meta_info.master_hash);
|
||||
inline constexpr const size_t NcaFsHeader::HashData::HierarchicalSha256Data::MasterHashOffset = AMS_OFFSETOF(NcaFsHeader, hash_data.hierarchical_sha256_data.fs_data_master_hash);
|
||||
inline constexpr const size_t NcaFsHeader::HashData::IntegrityMetaInfo::MasterHashOffset = AMS_OFFSETOF(NcaFsHeader, hash_data.integrity_meta_info.master_hash);
|
||||
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ namespace ams::ncm {
|
||||
u8 reserved_1C[4];
|
||||
};
|
||||
static_assert(sizeof(PackagedContentMetaHeader) == 0x20);
|
||||
static_assert(OFFSETOF(PackagedContentMetaHeader, reserved_0D) == 0x0D);
|
||||
static_assert(OFFSETOF(PackagedContentMetaHeader, reserved_1C) == 0x1C);
|
||||
static_assert(AMS_OFFSETOF(PackagedContentMetaHeader, reserved_0D) == 0x0D);
|
||||
static_assert(AMS_OFFSETOF(PackagedContentMetaHeader, reserved_1C) == 0x1C);
|
||||
|
||||
using InstallContentMetaHeader = PackagedContentMetaHeader;
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace ams::ro {
|
||||
static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader definition!");
|
||||
|
||||
constexpr size_t NrrHeader::GetSignedAreaOffset() {
|
||||
return OFFSETOF(NrrHeader, m_program_id);
|
||||
return AMS_OFFSETOF(NrrHeader, m_program_id);
|
||||
}
|
||||
|
||||
class NroHeader {
|
||||
|
||||
@@ -35,13 +35,13 @@ namespace ams::sf {
|
||||
void *Allocate(size_t size) {
|
||||
AMS_ASSERT(size == sizeof(T));
|
||||
AMS_UNUSED(size);
|
||||
return DefaultAllocateImpl(sizeof(Holder), alignof(Holder), offsetof(Holder, storage));
|
||||
return DefaultAllocateImpl(sizeof(Holder), alignof(Holder), AMS_OFFSETOF(Holder, storage));
|
||||
}
|
||||
|
||||
void Deallocate(void *ptr, size_t size) {
|
||||
AMS_ASSERT(size == sizeof(T));
|
||||
AMS_UNUSED(size);
|
||||
return DefaultDeallocateImpl(ptr, sizeof(Holder), alignof(Holder), offsetof(Holder, storage));
|
||||
return DefaultDeallocateImpl(ptr, sizeof(Holder), alignof(Holder), AMS_OFFSETOF(Holder, storage));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -164,12 +164,12 @@ namespace ams::tipc {
|
||||
};
|
||||
|
||||
consteval size_t DeferralManagerBase::GetObjectPointersOffsetBase() {
|
||||
return OFFSETOF(DeferralManagerBase, m_objects_base);
|
||||
return AMS_OFFSETOF(DeferralManagerBase, m_objects_base);
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
consteval size_t DeferralManager<N>::GetObjectPointersOffset() {
|
||||
return OFFSETOF(DeferralManager<N>, m_objects);
|
||||
return AMS_OFFSETOF(DeferralManager<N>, m_objects);
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user