Revert use of DEFINE_MACHINE() for registrations of multiple machines

The script used for converting from QEMUMachine had used one
DEFINE_MACHINE() per machine registered. In cases where multiple
machines are registered from one source file, avoid the excessive
generation of module init functions by reverting this unrolling.

Backports commit 8a661aea0e7f6e776c6ebc9abe339a85b34fea1d from qemu
This commit is contained in:
Andreas Färber 2018-03-11 15:17:10 -04:00 committed by Lioncash
parent a7f59d7771
commit 048aaf05ca
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7
3 changed files with 26 additions and 4 deletions

View File

@ -51,12 +51,34 @@ static int sun4u_init(struct uc_struct *uc, MachineState *machine)
return 0;
}
static void sun4u_machine_init(struct uc_struct *uc, MachineClass *mc)
static void sun4u_class_init(struct uc_struct *uc, ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(uc, oc);
mc->init = sun4u_init;
mc->max_cpus = 1; /* XXX for now */
mc->is_default = 1;
mc->arch = UC_ARCH_SPARC;
}
DEFINE_MACHINE("sun4u", sun4u_machine_init)
static const TypeInfo sun4u_type = {
MACHINE_TYPE_NAME("sun4u"),
TYPE_MACHINE,
0,
0,
NULL,
NULL,
NULL,
NULL,
NULL,
sun4u_class_init,
};
void sun4u_machine_init(struct uc_struct *uc)
{
type_register_static(uc, &sun4u_type);
}

View File

@ -3,6 +3,6 @@
void sparc_cpu_register_types(void *opaque);
void leon3_generic_machine_init_register_types(struct uc_struct *uc);
void sun4u_machine_init_register_types(struct uc_struct *uc);
void sun4u_machine_init(struct uc_struct *uc);
#endif

View File

@ -110,7 +110,7 @@ void sparc64_uc_init(struct uc_struct* uc)
{
register_accel_types(uc);
sparc_cpu_register_types(uc);
sun4u_machine_init_register_types(uc);
sun4u_machine_init(uc);
uc->reg_read = sparc_reg_read;
uc->reg_write = sparc_reg_write;
uc->reg_reset = sparc_reg_reset;