mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-30 06:52:39 +02:00
strat: refactor address taking of form &var[...]
This commit is contained in:
parent
e2df2f98a3
commit
5c32ec11ea
@ -186,7 +186,7 @@ namespace ams::kern::board::nintendo::nx::smc {
|
||||
MESOSPHERE_INIT_ABORT_UNLESS((static_cast<SmcResult>(args.x[0]) == SmcResult::Success));
|
||||
|
||||
/* Copy output. */
|
||||
std::memcpy(dst, &args.x[1], size);
|
||||
std::memcpy(dst, std::addressof(args.x[1]), size);
|
||||
}
|
||||
|
||||
bool ReadWriteRegister(u32 *out, u64 address, u32 mask, u32 value) {
|
||||
@ -255,7 +255,7 @@ namespace ams::kern::board::nintendo::nx::smc {
|
||||
MESOSPHERE_ABORT_UNLESS((static_cast<SmcResult>(args.x[0]) == SmcResult::Success));
|
||||
|
||||
/* Copy output. */
|
||||
std::memcpy(dst, &args.x[1], size);
|
||||
std::memcpy(dst, std::addressof(args.x[1]), size);
|
||||
}
|
||||
|
||||
void NORETURN Panic(u32 color) {
|
||||
|
@ -617,7 +617,7 @@ namespace ams::sf::impl {
|
||||
static_assert(Offset <= Size, "Offset <= Size");
|
||||
static_assert(TypeSize <= Size, "TypeSize <= Size");
|
||||
static_assert(Offset + TypeSize <= Size, "Offset + TypeSize <= Size");
|
||||
return reinterpret_cast<uintptr_t>(&data[Offset]);
|
||||
return reinterpret_cast<uintptr_t>(std::addressof(data[Offset]));
|
||||
}
|
||||
|
||||
constexpr inline void CopyTo(void *dst) const {
|
||||
@ -760,7 +760,7 @@ namespace ams::sf::impl {
|
||||
template<size_t Index, typename Interface>
|
||||
Out<SharedPointer<Interface>> GetOutObject() {
|
||||
auto sp = std::construct_at(GetOutObjectSharedPointer<Index, Interface>());
|
||||
return Out<SharedPointer<Interface>>(sp, &this->out_object_ids[Index]);
|
||||
return Out<SharedPointer<Interface>>(sp, this->out_object_ids + Index);
|
||||
}
|
||||
|
||||
template<size_t Index, typename Interface>
|
||||
@ -907,11 +907,11 @@ namespace ams::sf::impl {
|
||||
if constexpr (Attributes & SfBufferAttr_HipcMapAlias) {
|
||||
is_buffer_map_alias = true;
|
||||
if constexpr (Attributes & SfBufferAttr_In) {
|
||||
const HipcBufferDescriptor *desc = &ctx.request.data.send_buffers[Info.send_map_alias_index];
|
||||
const HipcBufferDescriptor *desc = std::addressof(ctx.request.data.send_buffers[Info.send_map_alias_index]);
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(desc), hipcGetBufferSize(desc));
|
||||
if (!IsMapTransferModeValid<Attributes>(static_cast<u32>(desc->mode))) { map_alias_buffers_valid = false; }
|
||||
} else if constexpr (Attributes & SfBufferAttr_Out) {
|
||||
const HipcBufferDescriptor *desc = &ctx.request.data.recv_buffers[Info.recv_map_alias_index];
|
||||
const HipcBufferDescriptor *desc = std::addressof(ctx.request.data.recv_buffers[Info.recv_map_alias_index]);
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(desc), hipcGetBufferSize(desc));
|
||||
if (!IsMapTransferModeValid<Attributes>(static_cast<u32>(desc->mode))) { map_alias_buffers_valid = false; }
|
||||
} else {
|
||||
@ -920,7 +920,7 @@ namespace ams::sf::impl {
|
||||
} else if constexpr (Attributes & SfBufferAttr_HipcPointer) {
|
||||
is_buffer_map_alias = false;
|
||||
if constexpr (Attributes & SfBufferAttr_In) {
|
||||
const HipcStaticDescriptor *desc = &ctx.request.data.send_statics[Info.send_pointer_index];
|
||||
const HipcStaticDescriptor *desc = std::addressof(ctx.request.data.send_statics[Info.send_pointer_index]);
|
||||
buffer = cmif::PointerAndSize(hipcGetStaticAddress(desc), hipcGetStaticSize(desc));
|
||||
const size_t size = buffer.GetSize();
|
||||
if (size) {
|
||||
@ -943,8 +943,8 @@ namespace ams::sf::impl {
|
||||
}
|
||||
} else if constexpr (Attributes & SfBufferAttr_HipcAutoSelect) {
|
||||
if constexpr (Attributes & SfBufferAttr_In) {
|
||||
const HipcBufferDescriptor *map_desc = &ctx.request.data.send_buffers[Info.send_map_alias_index];
|
||||
const HipcStaticDescriptor *ptr_desc = &ctx.request.data.send_statics[Info.send_pointer_index];
|
||||
const HipcBufferDescriptor *map_desc = std::addressof(ctx.request.data.send_buffers[Info.send_map_alias_index]);
|
||||
const HipcStaticDescriptor *ptr_desc = std::addressof(ctx.request.data.send_statics[Info.send_pointer_index]);
|
||||
is_buffer_map_alias = hipcGetBufferAddress(map_desc) != 0;
|
||||
if (is_buffer_map_alias) {
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(map_desc), hipcGetBufferSize(map_desc));
|
||||
@ -957,7 +957,7 @@ namespace ams::sf::impl {
|
||||
}
|
||||
}
|
||||
} else if constexpr (Attributes & SfBufferAttr_Out) {
|
||||
const HipcBufferDescriptor *map_desc = &ctx.request.data.recv_buffers[Info.recv_map_alias_index];
|
||||
const HipcBufferDescriptor *map_desc = std::addressof(ctx.request.data.recv_buffers[Info.recv_map_alias_index]);
|
||||
is_buffer_map_alias = hipcGetBufferAddress(map_desc) != 0;
|
||||
if (is_buffer_map_alias) {
|
||||
buffer = cmif::PointerAndSize(hipcGetBufferAddress(map_desc), hipcGetBufferSize(map_desc));
|
||||
|
@ -123,7 +123,7 @@ namespace ams::fssystem {
|
||||
R_UNLESS(len >= 2, fs::ResultInvalidPathFormat());
|
||||
|
||||
/* Find previous separator, add null terminator */
|
||||
char *cur = &dst_path_buf[len - 2];
|
||||
char *cur = dst_path_buf + len - 2;
|
||||
while (!fs::PathNormalizer::IsSeparator(*cur) && cur > dst_path_buf) {
|
||||
cur--;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ namespace ams::spl::smc {
|
||||
svc::CallSecureMonitor(std::addressof(args));
|
||||
|
||||
if (args.r[0] == static_cast<u64>(Result::Success) && (size <= sizeof(args) - sizeof(args.r[0]))) {
|
||||
std::memcpy(out, &args.r[1], size);
|
||||
std::memcpy(out, std::addressof(args.r[1]), size);
|
||||
}
|
||||
return static_cast<Result>(args.r[0]);
|
||||
}
|
||||
@ -220,8 +220,8 @@ namespace ams::spl::smc {
|
||||
args.r[0] = static_cast<u64>(FunctionId::PrepareEsDeviceUniqueKey);
|
||||
args.r[1] = reinterpret_cast<u64>(base);
|
||||
args.r[2] = reinterpret_cast<u64>(mod);
|
||||
std::memset(&args.r[3], 0, 4 * sizeof(args.r[3]));
|
||||
std::memcpy(&args.r[3], label_digest, std::min(size_t(4 * sizeof(args.r[3])), label_digest_size));
|
||||
std::memset(std::addressof(args.r[3]), 0, 4 * sizeof(args.r[3]));
|
||||
std::memcpy(std::addressof(args.r[3]), label_digest, std::min(size_t(4 * sizeof(args.r[3])), label_digest_size));
|
||||
args.r[7] = option;
|
||||
svc::CallSecureMonitor(std::addressof(args));
|
||||
|
||||
@ -358,7 +358,7 @@ namespace ams::spl::smc {
|
||||
args.r[2] = paths;
|
||||
svc::CallSecureMonitor(std::addressof(args));
|
||||
|
||||
std::memcpy(out_config, &args.r[1], sizeof(args) - sizeof(args.r[0]));
|
||||
std::memcpy(out_config, std::addressof(args.r[1]), sizeof(args) - sizeof(args.r[0]));
|
||||
return static_cast<Result>(args.r[0]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user