mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 04:45:31 +00:00
target/arm/cpu: Use ARRAY_SIZE() to iterate over ARMCPUInfo[]
Since on the aarch64-linux-user build, arm_cpus[] is empty, add the cpu_count variable and only iterate when it is non-zero. Backports commit 92b6a659388ab3735e5fbb17ac486923b681f57f from qemu
This commit is contained in:
parent
4016b667f3
commit
cfe94f63f3
|
@ -1982,7 +1982,6 @@ static const ARMCPUInfo arm_cpus[] = {
|
||||||
{ .name = "any", .initfn = arm_max_initfn },
|
{ .name = "any", .initfn = arm_max_initfn },
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{ .name = NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void arm_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *data)
|
static void arm_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *data)
|
||||||
|
@ -2043,7 +2042,7 @@ void arm_cpu_register(struct uc_struct *uc, const ARMCPUInfo *info)
|
||||||
|
|
||||||
void arm_cpu_register_types(void *opaque)
|
void arm_cpu_register_types(void *opaque)
|
||||||
{
|
{
|
||||||
const ARMCPUInfo *info = arm_cpus;
|
const size_t cpu_count = ARRAY_SIZE(arm_cpus);
|
||||||
|
|
||||||
TypeInfo arm_cpu_type_info = {0};
|
TypeInfo arm_cpu_type_info = {0};
|
||||||
arm_cpu_type_info.name = TYPE_ARM_CPU,
|
arm_cpu_type_info.name = TYPE_ARM_CPU,
|
||||||
|
@ -2059,8 +2058,11 @@ void arm_cpu_register_types(void *opaque)
|
||||||
|
|
||||||
type_register(opaque, &arm_cpu_type_info);
|
type_register(opaque, &arm_cpu_type_info);
|
||||||
|
|
||||||
while (info->name) {
|
if (cpu_count) {
|
||||||
arm_cpu_register(opaque, info);
|
size_t i;
|
||||||
info++;
|
|
||||||
|
for (i = 0; i < cpu_count; ++i) {
|
||||||
|
arm_cpu_register(opaque, &arm_cpus[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -386,7 +386,6 @@ static const ARMCPUInfo aarch64_cpus[] = {
|
||||||
{ .name = "cortex-a53", .initfn = aarch64_a53_initfn },
|
{ .name = "cortex-a53", .initfn = aarch64_a53_initfn },
|
||||||
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
|
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
|
||||||
{ .name = "max", .initfn = aarch64_max_initfn },
|
{ .name = "max", .initfn = aarch64_max_initfn },
|
||||||
{ .name = NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static QEMU_UNUSED_FUNC bool aarch64_cpu_get_aarch64(Object *obj, Error **errp)
|
static QEMU_UNUSED_FUNC bool aarch64_cpu_get_aarch64(Object *obj, Error **errp)
|
||||||
|
@ -430,6 +429,7 @@ void aarch64_cpu_register(struct uc_struct *uc, const ARMCPUInfo *info)
|
||||||
void aarch64_cpu_register_types(void *opaque)
|
void aarch64_cpu_register_types(void *opaque)
|
||||||
{
|
{
|
||||||
const ARMCPUInfo *info = aarch64_cpus;
|
const ARMCPUInfo *info = aarch64_cpus;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
static TypeInfo aarch64_cpu_type_info = { 0 };
|
static TypeInfo aarch64_cpu_type_info = { 0 };
|
||||||
aarch64_cpu_type_info.name = TYPE_AARCH64_CPU;
|
aarch64_cpu_type_info.name = TYPE_AARCH64_CPU;
|
||||||
|
@ -443,8 +443,7 @@ void aarch64_cpu_register_types(void *opaque)
|
||||||
|
|
||||||
type_register_static(opaque, &aarch64_cpu_type_info);
|
type_register_static(opaque, &aarch64_cpu_type_info);
|
||||||
|
|
||||||
while (info->name) {
|
for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) {
|
||||||
aarch64_cpu_register(opaque, info);
|
aarch64_cpu_register(opaque, &aarch64_cpus[i]);
|
||||||
info++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue