it will help to remove code duplication in places that currently open code registration of several types.
Signed-off-by: Igor Mammedov <[email protected]> --- I'm going to use it for CPU types in followup patches CC: [email protected] --- include/qemu/module.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/qemu/module.h b/include/qemu/module.h index 56dd218..29f9089 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -52,6 +52,16 @@ typedef enum { #define type_init(function) module_init(function, MODULE_INIT_QOM) #define trace_init(function) module_init(function, MODULE_INIT_TRACE) +#define type_init_from_array(array) \ +static void do_qemu_init_ ## array(void) \ +{ \ + int i; \ + for (i = 0; i < ARRAY_SIZE(array); i++) { \ + type_register_static(&array[i]); \ + } \ +} \ +module_init(do_qemu_init_ ## array, MODULE_INIT_QOM) + #define block_module_load_one(lib) module_load_one("block-", lib) void register_module_init(void (*fn)(void), module_init_type type); -- 2.7.4
