[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 4/7] machine: DEFINE_MACHINE macro
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH v3 4/7] machine: DEFINE_MACHINE macro |
Date: |
Fri, 4 Sep 2015 15:37:06 -0300 |
The macro will allow easy registration of a TYPE_MACHINE subclass, using
only the machine name and a MachineClass initialization function as
parameter.
Signed-off-by: Eduardo Habkost <address@hidden>
---
Changes series v1 -> series v2: none
Changes series v2 -> series v3:
* Don't set MachineClass::name explicitly
(Now TYPE_MACHINE does that automatically)
* Use MACHINE_TYPE_NAME macro
---
include/hw/boards.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 178517c..befae01 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -158,4 +158,21 @@ struct MachineState {
AccelState *accelerator;
};
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+ static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
+ { \
+ MachineClass *mc = MACHINE_CLASS(oc); \
+ machine_initfn(mc); \
+ } \
+ static const TypeInfo machine_initfn##_typeinfo = { \
+ .name = MACHINE_TYPE_NAME(namestr), \
+ .parent = TYPE_MACHINE, \
+ .class_init = machine_initfn##_class_init, \
+ }; \
+ static void machine_initfn##_register_types(void) \
+ { \
+ type_register_static(&machine_initfn##_typeinfo); \
+ } \
+ machine_init(machine_initfn##_register_types)
+
#endif
--
2.1.0
- [Qemu-devel] [PATCH v3 0/7] machine registration: Use QOM, eliminate QEMUMachine, Eduardo Habkost, 2015/09/04
- [Qemu-devel] [PATCH v3 2/7] exynos4: Use MachineClass instead of exynos4_machines array, Eduardo Habkost, 2015/09/04
- [Qemu-devel] [PATCH v3 1/7] exynos4: Use EXYNOS4210_NCPUS instead of max_cpus on error message, Eduardo Habkost, 2015/09/04
- [Qemu-devel] [PATCH v3 4/7] machine: DEFINE_MACHINE macro,
Eduardo Habkost <=
- [Qemu-devel] [PATCH v3 3/7] exynos4: Declare each QEMUMachine as a separate variable, Eduardo Habkost, 2015/09/04
- [Qemu-devel] [PATCH v3 7/7] machine: Eliminate QEMUMachine and qemu_register_machine(), Eduardo Habkost, 2015/09/04
- [Qemu-devel] [PATCH v3 5/7] mac_world: Break long line, Eduardo Habkost, 2015/09/04
- [Qemu-devel] [PATCH v3 6/7] Use DEFINE_MACHINE to register all machines, Eduardo Habkost, 2015/09/04
- [Qemu-devel] [PATCH 6a/7] Revert use of DEFINE_MACHINE() for registrations of multiple machines, Andreas Färber, 2015/09/19
- Re: [Qemu-devel] [PATCH v3 0/7] machine registration: Use QOM, eliminate QEMUMachine, Andreas Färber, 2015/09/19