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

Re: [PATCH 00/15] hw: expand DEFINE_MACHINE to explicit TypeInfo registration



On Fri, 30 Oct 2026, Pierrick Bouvier wrote:
On 10/30/2026 4:09 PM, BALATON Zoltan wrote:
On Fri, 30 Oct 2026, Yonggang Luo wrote:
DEFINE_MACHINE and DEFINE_MACHINE_EXTENDED hide the TypeInfo and the
type_init
function that calls type_register_static(). A later change needs to
pass a

That's the point of the macro to hide the boiler plate code.

target mask into that registration, and the macros have no parameter
for it.

Couldn't you just change the macros to take that parameter instead of
expanding it everywhere?


Problem of macros is that they don't have default parameters, so you
need variants for everything:

DEFINE_MACHINE
DEFINE_MACHINE_EXTENDED
DEFINE_MACHINE_WITH_INTERFACES
DEFINE_MACHINE_WITH_INTERFACE_ARRAY
and now would need a new variant, with variant for other existing ones.

In the end, it's just simpler to remove this and add the boilerplate.
It's written once and never modified, so using a macro just save typing
those lines once.

Regards,
BALATON Zoltan

This series expands every caller first, with no behavior change, so the
follow-up only replaces the type_register_static() call.

Each machine file gains a class_init function, a TypeInfo, and a
type_init
function that calls type_register_static(). The last patch removes
DEFINE_MACHINE* and DEFINE_SECURE_MACHINE* from include/hw/core/boards.h.

Macros help reading the code not saving typing. If the actual functionality is buried in a lot of boiler plate it's harder to understand and spot bugs so putting the unintresting boiler plate behind a macro is better even if you need a separate version for different cases. Then the code that uses the macro will be much more obvious and not just a lot of boiler plate.

Regards,
BALATON Zoltan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.