unicorn: Be explicit about casting away const to const-incorrect APIs

Uses C++ casts which silence relevant warnings in Xcode 9.3

Also migrates relevant Read function equivalents over for consistency.
This commit is contained in:
Lioncash 2018-04-15 01:18:50 -04:00 committed by MerryMage
parent 6bcfdba1ad
commit ab58bbddc8

View file

@ -72,7 +72,8 @@ std::array<u64, 31> Unicorn::GetRegisters() const {
for (size_t i = 0; i < num_gprs; ++i)
ptrs[i] = &regs[i];
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(gpr_ids.data()), (void**)ptrs.data(), num_gprs));
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(gpr_ids.data()),
reinterpret_cast<void**>(ptrs.data()), num_gprs));
return regs;
}
@ -81,7 +82,8 @@ void Unicorn::SetRegisters(const std::array<u64, 31>& value) {
for (size_t i = 0; i < num_gprs; ++i)
ptrs[i] = &value[i];
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(gpr_ids.data()), (void**)ptrs.data(), num_gprs));
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(gpr_ids.data()),
reinterpret_cast<void**>(const_cast<u64**>(ptrs.data())), num_gprs));
}
using Vector = Unicorn::Vector;
@ -99,7 +101,8 @@ std::array<Vector, 32> Unicorn::GetVectors() const {
for (size_t i = 0; i < num_vecs; ++i)
ptrs[i] = &vecs[i];
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(vec_ids.data()), (void**)ptrs.data(), num_vecs));
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(vec_ids.data()),
reinterpret_cast<void**>(ptrs.data()), num_vecs));
return vecs;
}
@ -109,7 +112,8 @@ void Unicorn::SetVectors(const std::array<Vector, 32>& value) {
for (size_t i = 0; i < num_vecs; ++i)
ptrs[i] = &value[i];
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(vec_ids.data()), (void**)ptrs.data(), num_vecs));
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(vec_ids.data()),
reinterpret_cast<void* const *>(const_cast<Vector**>(ptrs.data())), num_vecs));
}
u32 Unicorn::GetFpcr() const {