qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: BALATON Zoltan <balaton@eik.bme.hu>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
	Pierrick Bouvier <pierrick.bouvier@linaro.org>
Subject: Re: [PATCH 01/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases
Date: Tue, 10 Jun 2025 09:24:58 +0200	[thread overview]
Message-ID: <6b7aa048-bdb7-40a4-995a-9257afc99708@linaro.org> (raw)
In-Reply-To: <ad355178b2a3fe285854ed2e25b288baf0fd6e05.1746139668.git.balaton@eik.bme.hu>

Hi Zoltan,

On 2/5/25 01:20, BALATON Zoltan wrote:
> Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler
> versions with less parameters based on that. This is inspired by how
> the OBJECT_DEFINE macros do this in a similar way to allow using the
> shortened definition in more complex cases too.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
>   include/hw/boards.h | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 765dc8dd35..6e52d4d10c 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -744,7 +744,8 @@ struct MachineState {
>           } \
>       } while (0)
>   
> -#define DEFINE_MACHINE(namestr, machine_initfn) \
> +#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
> +                                machine_initfn, ABSTRACT, ...) \
>       static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
>       { \
>           MachineClass *mc = MACHINE_CLASS(oc); \
> @@ -752,8 +753,11 @@ struct MachineState {
>       } \
>       static const TypeInfo machine_initfn##_typeinfo = { \
>           .name       = MACHINE_TYPE_NAME(namestr), \
> -        .parent     = TYPE_MACHINE, \
> +        .parent     = TYPE_##PARENT_NAME, \

As it doesn't save much, lets simply pass the full PARENT_TYPE,
not PARENT_NAME. But, do we really need it?

>           .class_init = machine_initfn##_class_init, \
> +        .instance_size = sizeof(InstanceName), \
> +        .abstract = ABSTRACT, \
> +        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \
>       }; \
>       static void machine_initfn##_register_types(void) \
>       { \
> @@ -761,6 +765,14 @@ struct MachineState {
>       } \
>       type_init(machine_initfn##_register_types)
>   
> +#define DEFINE_MACHINE(namestr, machine_initfn) \
> +    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
> +                            false, { })
> +
> +#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
> +    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
> +                            false, __VA_ARGS__)
> +
>   extern GlobalProperty hw_compat_10_0[];
>   extern const size_t hw_compat_10_0_len;
>   



  reply	other threads:[~2025-06-10  7:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01 23:20 [PATCH 00/13] Pegasos2 clean up and pegasos1 emulation BALATON Zoltan
2025-05-01 23:20 ` [PATCH 01/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases BALATON Zoltan
2025-06-10  7:24   ` Philippe Mathieu-Daudé [this message]
2025-06-10 11:38     ` BALATON Zoltan
2025-05-01 23:20 ` [PATCH 02/13] ppc/vof: Make nextprop behave more like Open Firmware BALATON Zoltan
2025-05-01 23:20 ` [PATCH 03/13] hw/ppc/pegasos2: Remove explicit name properties from device tree BALATON Zoltan
2025-05-01 23:20 ` [PATCH 04/13] hw/ppc/pegasos2: Change device tree generation BALATON Zoltan
2025-05-01 23:20 ` [PATCH 05/13] hw/ppc/pegasos2: Remove fdt pointer from machine state BALATON Zoltan
2025-05-01 23:20 ` [PATCH 06/13] hw/ppc/pegasos2: Rename mv field in " BALATON Zoltan
2025-06-10  7:28   ` Philippe Mathieu-Daudé
2025-05-01 23:20 ` [PATCH 07/13] hw/ppc/pegasos2: Add south bridge pointer in the " BALATON Zoltan
2025-06-10  7:28   ` Philippe Mathieu-Daudé
2025-05-01 23:20 ` [PATCH 08/13] hw/ppc/pegasos2: Move PCI IRQ routing setup to a function BALATON Zoltan
2025-05-01 23:20 ` [PATCH 09/13] hw/ppc/pegasos2: Move hardware specific parts out of machine reset BALATON Zoltan
2025-05-01 23:20 ` [PATCH 10/13] hw/ppc/pegasos2: Introduce abstract superclass BALATON Zoltan
2025-05-01 23:20 ` [PATCH 11/13] hw/ppc/pegasos2: Add bus frequency to machine state BALATON Zoltan
2025-05-01 23:20 ` [PATCH 12/13] hw/ppc/pegasos2: Add Pegasos I emulation BALATON Zoltan
2025-05-01 23:20 ` [PATCH 13/13] hw/ppc/pegasos2: Add VOF support for pegasos1 BALATON Zoltan
2025-05-22 22:31 ` [PATCH 00/13] Pegasos2 clean up and pegasos1 emulation BALATON Zoltan
2025-06-02 12:27   ` BALATON Zoltan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b7aa048-bdb7-40a4-995a-9257afc99708@linaro.org \
    --to=philmd@linaro.org \
    --cc=balaton@eik.bme.hu \
    --cc=npiggin@gmail.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).