hw/boards: Extend DEFINE_MACHINE macro to cover more use cases
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> Message-ID: <d75c8bbed97650f1a4d2d675444582a240a335b4.1760798392.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
This commit is contained in:
parent
0f212b0d12
commit
ce837a4fd6
1 changed files with 14 additions and 2 deletions
|
|
@ -506,7 +506,8 @@ struct MachineState {
|
|||
* DEFINE_VIRT_MACHINE_IMPL(false, major, minor, micro, _, tag)
|
||||
*/
|
||||
|
||||
#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); \
|
||||
|
|
@ -514,8 +515,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) \
|
||||
{ \
|
||||
|
|
@ -523,6 +527,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__)
|
||||
|
||||
/*
|
||||
* Helper for dispatching different macros based on how
|
||||
* many __VA_ARGS__ are passed. Supports 1 to 5 variadic
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue