mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 02:35:29 +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 },
|
||||
#endif
|
||||
#endif
|
||||
{ .name = NULL }
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
const ARMCPUInfo *info = arm_cpus;
|
||||
const size_t cpu_count = ARRAY_SIZE(arm_cpus);
|
||||
|
||||
TypeInfo arm_cpu_type_info = {0};
|
||||
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);
|
||||
|
||||
while (info->name) {
|
||||
arm_cpu_register(opaque, info);
|
||||
info++;
|
||||
if (cpu_count) {
|
||||
size_t i;
|
||||
|
||||
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-a72", .initfn = aarch64_a72_initfn },
|
||||
{ .name = "max", .initfn = aarch64_max_initfn },
|
||||
{ .name = NULL }
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
const ARMCPUInfo *info = aarch64_cpus;
|
||||
size_t i;
|
||||
|
||||
static TypeInfo aarch64_cpu_type_info = { 0 };
|
||||
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);
|
||||
|
||||
while (info->name) {
|
||||
aarch64_cpu_register(opaque, info);
|
||||
info++;
|
||||
for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) {
|
||||
aarch64_cpu_register(opaque, &aarch64_cpus[i]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue