Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler
versions with less parameters based on that. This is inspired by how
the OBJECT_DEFINE macros do this in a similar way to allow using the
shortened definition in more complex cases too.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
include/hw/boards.h | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index f424b2b505..8e8eff2f6d 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -761,7 +761,8 @@ struct MachineState {
} \
} while (0)
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+ machine_initfn, ABSTRACT, ...) \
static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
{ \
MachineClass *mc = MACHINE_CLASS(oc); \
@@ -769,8 +770,11 @@ struct MachineState {
} \
static const TypeInfo machine_initfn##_typeinfo = { \
.name = MACHINE_TYPE_NAME(namestr), \
- .parent = TYPE_MACHINE, \
+ .parent = TYPE_##PARENT_NAME, \
.class_init = machine_initfn##_class_init, \
+ .instance_size = sizeof(InstanceName), \
+ .abstract = ABSTRACT, \
+ .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \
}; \
static void machine_initfn##_register_types(void) \
{ \
@@ -778,6 +782,14 @@ struct MachineState {
} \
type_init(machine_initfn##_register_types)
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+ DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+ false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+ DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+ false, __VA_ARGS__)
+
extern GlobalProperty hw_compat_10_0[];
extern const size_t hw_compat_10_0_len;
--
2.41.3