[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array()
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array() |
Date: |
Mon, 2 Oct 2017 11:07:43 +0200 |
it will help to remove code duplication in places
that currently open code registration of several
types.
Signed-off-by: Igor Mammedov <address@hidden>
---
I'm going to use it for CPU types in followup patches
CC: address@hidden
---
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
- [Qemu-devel] [PATCH 00/38] generalize parsing of cpu_model (part 2), Igor Mammedov, 2017/10/02
- [Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array(),
Igor Mammedov <=
- Re: [Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array(), Philippe Mathieu-Daudé, 2017/10/02
- Re: [Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array(), Eduardo Habkost, 2017/10/02
- Re: [Qemu-devel] [PATCH] qom: add helpers REGISTER_STATIC_TYPE[S](), Eduardo Habkost, 2017/10/03
- Re: [Qemu-devel] [PATCH] qom: add helpers REGISTER_STATIC_TYPE[S](), Igor Mammedov, 2017/10/03
- Re: [Qemu-devel] [PATCH] qom: add helpers REGISTER_STATIC_TYPE[S](), Eduardo Habkost, 2017/10/03
- Re: [Qemu-devel] [PATCH] qom: add helpers REGISTER_STATIC_TYPE[S](), Igor Mammedov, 2017/10/03