[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qom: add helpers REGISTER_STATIC_TYPE[S]()
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH] qom: add helpers REGISTER_STATIC_TYPE[S]() |
Date: |
Tue, 3 Oct 2017 16:44:28 +0100 |
On 3 October 2017 at 13:14, Igor Mammedov <address@hidden> wrote:
> it will help to remove code duplication in places
> that currently open code registration of static
> type[s] and remove necessity to declare function
> for type_init() to call, when only static types
> need to be registered.
>
> 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 ++++++++++
> include/qom/object.h | 10 ++++++++++
> qom/object.c | 9 +++++++++
> 3 files changed, 29 insertions(+)
>
> diff --git a/include/qemu/module.h b/include/qemu/module.h
> index 56dd218..60dd632 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 REGISTER_STATIC_TYPES(t, nr) \
> +static void do_qemu_init_ ## t(void) \
> +{ \
> + type_register_static_array(t, nr); \
> +} \
> +type_init(do_qemu_init_ ## t)
Could we use
type_register_static_array(t, ARRAY_SIZE(t));
here to save the caller having to pass the array size,
or is that too magic?
thanks
-- PMM
- Re: [Qemu-devel] [PATCH 01/38] qom: add helper type_init_from_array(), (continued)
- 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
- 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](),
Peter Maydell <=
- Re: [Qemu-devel] [PATCH] qom: add helpers REGISTER_STATIC_TYPE[S](), Igor Mammedov, 2017/10/03
[Qemu-devel] [PATCH v2 0/3] add DEFINE_TYPES() helper to simplify batch type registration, Igor Mammedov, 2017/10/04
[Qemu-devel] [PATCH v2 1/3] qom: update doc comment for type_register[_static](), Igor Mammedov, 2017/10/04
Re: [Qemu-devel] [PATCH v2 1/3] qom: update doc comment for type_register[_static](), Eduardo Habkost, 2017/10/04
[Qemu-devel] [PATCH v2 3/3] qom: add helper macro DEFINE_TYPES(), Igor Mammedov, 2017/10/04
Re: [Qemu-devel] [PATCH v2 3/3] qom: add helper macro DEFINE_TYPES(), Eduardo Habkost, 2017/10/04
Re: [Qemu-devel] [PATCH v2 3/3] qom: add helper macro DEFINE_TYPES(), Igor Mammedov, 2017/10/05