[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/21] machine: DEFINE_MACHINE() macro
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL 17/21] machine: DEFINE_MACHINE() macro |
Date: |
Sat, 19 Sep 2015 16:43:26 +0200 |
From: Eduardo Habkost <address@hidden>
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>
Signed-off-by: Andreas Färber <address@hidden>
---
include/hw/boards.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 586f939..4fe2ce5 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -159,4 +159,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.4
- [Qemu-devel] [PULL 07/21] arm: Rename virt machine class to use MACHINE_TYPE_NAME, (continued)
- [Qemu-devel] [PULL 07/21] arm: Rename virt machine class to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 09/21] s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 12/21] machine: Ensure all TYPE_MACHINE subclasses have the right suffix, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 10/21] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 08/21] pseries: Rename machine class names to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 11/21] mac99: Use MACHINE_TYPE_NAME to encode class name, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 14/21] exynos4: Use EXYNOS4210_NCPUS instead of max_cpus on error message, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 13/21] machine: Set MachineClass::name automatically, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 15/21] exynos4: Use MachineClass instead of exynos4_machines array, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 16/21] exynos4: Declare each QEMUMachine as a separate variable, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 17/21] machine: DEFINE_MACHINE() macro,
Andreas Färber <=
- [Qemu-devel] [PULL 18/21] mac_world: Break long line, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 21/21] machine: Eliminate QEMUMachine and qemu_register_machine(), Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 20/21] Revert use of DEFINE_MACHINE() for registrations of multiple machines, Andreas Färber, 2015/09/19
[Qemu-devel] [PULL 19/21] Use DEFINE_MACHINE() to register all machines, Andreas Färber, 2015/09/19
Re: [Qemu-devel] [PULL 00/21] QOM devices patch queue 2015-09-19, Peter Maydell, 2015/09/19