qemu-devel
[Top][All Lists]
Advanced

[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



reply via email to

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