From ba09afc8b503771ed9adae6761c813a8e316468d Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Sun, 11 Mar 2018 13:41:19 -0400 Subject: [PATCH] pc: Generate init functions with a macro All pc-i440fx and pc-q35 init functions simply call the corresponding compat function and then call the main init function. Use a macro to generate that code. Backports commit 99fbeafee8b568e796863980365080abdb8d675e from qemu --- qemu/hw/i386/pc_piix.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/qemu/hw/i386/pc_piix.c b/qemu/hw/i386/pc_piix.c index c737a839..6af28934 100644 --- a/qemu/hw/i386/pc_piix.c +++ b/qemu/hw/i386/pc_piix.c @@ -48,10 +48,16 @@ static void pc_compat_2_2(struct uc_struct *uc, MachineState *machine) { } -static int pc_init_pci_2_2(struct uc_struct *uc, MachineState *machine) -{ - pc_compat_2_2(uc, machine); - return pc_init1(uc, machine); -} +// Unicorn: Modified for use with unicorn (no need for an option function) +#define DEFINE_I440FX_MACHINE(suffix, name, compatfn) \ + static int pc_init_##suffix(struct uc_struct *uc, MachineState *machine) \ + { \ + void (*compat)(struct uc_struct *uc, MachineState *m) = (compatfn); \ + if (compat) { \ + compat(uc, machine); \ + } \ + return pc_init1(uc, machine); \ + } \ + DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix) -DEFINE_PC_MACHINE(v2_2, "pc-i440fx-2.2", pc_init_pci_2_2); +DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2);