qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array()


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array()
Date: Mon, 2 Oct 2017 11:15:51 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 10/02/2017 06:07 AM, Igor Mammedov wrote:
it will help to remove code duplication in places
that currently open code registration of several
types.

Signed-off-by: Igor Mammedov <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Philippe Mathieu-Daudé <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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]