tests: Fix Windows build when DYNARMIC_TESTS_USE_UNICORN is enabled

This commit is contained in:
MerryMage 2019-05-05 18:43:09 +01:00
parent bab4e29075
commit 0495b2c779
7 changed files with 26 additions and 39 deletions

View file

@ -126,7 +126,7 @@ u32 GenRandomInst(u32 pc, bool is_last_inst) {
while (true) {
const size_t index = RandInt<size_t>(0, instructions.generators.size() - 1);
const u32 inst = instructions.generators[index].Generate();
if (std::any_of(instructions.invalid.begin(), instructions.invalid.end(), [inst](const auto& invalid) { return invalid.Match(inst); })) {
continue;
}
@ -150,7 +150,7 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit, A32Unicorn<ArmTestEnv>& uni
const std::vector<u32>& instructions, const u32 cpsr, const u32 fpscr) {
const u32 initial_pc = regs[15];
const u32 num_words = initial_pc / sizeof(u32);
const u32 code_mem_size = num_words + instructions.size();
const u32 code_mem_size = num_words + static_cast<u32>(instructions.size());
jit_env.code_mem.resize(code_mem_size + 1);
uni_env.code_mem.resize(code_mem_size + 1);

View file

@ -26,7 +26,6 @@ if (DYNARMIC_TESTS_USE_UNICORN)
unicorn_emu/a32_unicorn.h
unicorn_emu/a64_unicorn.cpp
unicorn_emu/a64_unicorn.h
unicorn_emu/unicorn_load.cpp
)
target_link_libraries(dynarmic_tests PRIVATE Unicorn::Unicorn)
endif()

View file

@ -87,14 +87,14 @@ constexpr std::array<int, Unicorn::A32::num_gprs> gpr_ids{
template <class TestEnvironment>
Unicorn::A32::RegisterArray A32Unicorn<TestEnvironment>::GetRegisters() const {
Unicorn::A32::RegisterArray regs;
Unicorn::A32::RegisterArray regs{};
Unicorn::A32::RegisterPtrArray ptrs;
for (size_t i = 0; i < ptrs.size(); ++i) {
ptrs[i] = &regs[i];
}
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(gpr_ids.data()),
reinterpret_cast<void**>(ptrs.data()), Unicorn::A32::num_gprs));
reinterpret_cast<void**>(ptrs.data()), static_cast<int>(Unicorn::A32::num_gprs)));
return regs;
}
@ -106,7 +106,7 @@ void A32Unicorn<TestEnvironment>::SetRegisters(const RegisterArray& value) {
}
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(gpr_ids.data()),
reinterpret_cast<void**>(const_cast<u32**>(ptrs.data())), ptrs.size()));
reinterpret_cast<void**>(const_cast<u32**>(ptrs.data())), static_cast<int>(ptrs.size())));
}
using DoubleExtRegPtrArray = std::array<Unicorn::A32::ExtRegArray::pointer, Unicorn::A32::num_ext_regs/2>;
@ -121,13 +121,13 @@ constexpr std::array<int, Unicorn::A32::num_ext_regs/2> double_ext_reg_ids{
template <class TestEnvironment>
Unicorn::A32::ExtRegArray A32Unicorn<TestEnvironment>::GetExtRegs() const {
Unicorn::A32::ExtRegArray ext_regs;
Unicorn::A32::ExtRegArray ext_regs{};
DoubleExtRegPtrArray ptrs;
for (size_t i = 0; i < ptrs.size(); ++i)
ptrs[i] = &ext_regs[i*2];
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(double_ext_reg_ids.data()),
reinterpret_cast<void**>(ptrs.data()), ptrs.size()));
reinterpret_cast<void**>(ptrs.data()), static_cast<int>(ptrs.size())));
return ext_regs;
}
@ -140,7 +140,7 @@ void A32Unicorn<TestEnvironment>::SetExtRegs(const ExtRegArray& value) {
}
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(double_ext_reg_ids.data()),
reinterpret_cast<void* const *>(const_cast<u32**>(ptrs.data())), ptrs.size()));
reinterpret_cast<void* const *>(const_cast<u32**>(ptrs.data())), static_cast<int>(ptrs.size())));
}
template <class TestEnvironment>

View file

@ -9,7 +9,13 @@
#include <array>
#include <vector>
#ifdef _MSC_VER
#pragma warning(push, 0)
#include <unicorn/unicorn.h>
#pragma warning(pop)
#else
#include <unicorn/unicorn.h>
#endif
#include "common/common_types.h"

View file

@ -71,13 +71,13 @@ constexpr std::array<int, A64Unicorn::num_gprs> gpr_ids{
};
A64Unicorn::RegisterArray A64Unicorn::GetRegisters() const {
RegisterArray regs;
RegisterArray regs{};
RegisterPtrArray ptrs;
for (size_t i = 0; i < ptrs.size(); ++i)
ptrs[i] = &regs[i];
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(gpr_ids.data()),
reinterpret_cast<void**>(ptrs.data()), num_gprs));
reinterpret_cast<void**>(ptrs.data()), static_cast<int>(num_gprs)));
return regs;
}
@ -87,7 +87,7 @@ void A64Unicorn::SetRegisters(const RegisterArray& value) {
ptrs[i] = &value[i];
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(gpr_ids.data()),
reinterpret_cast<void**>(const_cast<u64**>(ptrs.data())), num_gprs));
reinterpret_cast<void**>(const_cast<u64**>(ptrs.data())), static_cast<int>(num_gprs)));
}
constexpr std::array<int, A64Unicorn::num_vecs> vec_ids{
@ -98,13 +98,13 @@ constexpr std::array<int, A64Unicorn::num_vecs> vec_ids{
};
A64Unicorn::VectorArray A64Unicorn::GetVectors() const {
VectorArray vecs;
VectorArray vecs{};
VectorPtrArray ptrs;
for (size_t i = 0; i < ptrs.size(); ++i)
ptrs[i] = &vecs[i];
CHECKED(uc_reg_read_batch(uc, const_cast<int*>(vec_ids.data()),
reinterpret_cast<void**>(ptrs.data()), num_vecs));
reinterpret_cast<void**>(ptrs.data()), static_cast<int>(num_vecs)));
return vecs;
}
@ -115,7 +115,7 @@ void A64Unicorn::SetVectors(const VectorArray& value) {
ptrs[i] = &value[i];
CHECKED(uc_reg_write_batch(uc, const_cast<int*>(vec_ids.data()),
reinterpret_cast<void* const *>(const_cast<Vector**>(ptrs.data())), num_vecs));
reinterpret_cast<void* const *>(const_cast<Vector**>(ptrs.data())), static_cast<int>(num_vecs)));
}
u32 A64Unicorn::GetFpcr() const {

View file

@ -9,7 +9,13 @@
#include <array>
#include <vector>
#ifdef _MSC_VER
#pragma warning(push, 0)
#include <unicorn/unicorn.h>
#pragma warning(pop)
#else
#include <unicorn/unicorn.h>
#endif
#include "common/common_types.h"
#include "A64/testenv.h"

View file

@ -1,24 +0,0 @@
/* This file is part of the dynarmic project.
* Copyright (c) 2018 MerryMage
* This software may be used and distributed according to the terms of the GNU
* General Public License version 2 or any later version.
*/
// Load Unicorn DLL once on Windows using RAII
#ifdef _WIN32
#include <unicorn/arm64.h>
#include <unicorn_dynload.h>
#include "common/assert.h"
static struct LoadDll {
public:
LoadDll() {
ASSERT(uc_dyn_load(NULL, 0));
}
~LoadDll() {
ASSERT(uc_dyn_free());
}
static LoadDll g_load_dll;
} load_dll;
#endif