|
[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 Sun, 1 Nov 2026, Yonggang Luo wrote: On Sun, Nov 1, 2026 at 1:06 AM BALATON Zoltan <balaton@xxxxxxxxxx> wrote:On Sat, 31 Oct 2026, Yonggang Luo wrote:On Sat, Oct 31, 2026 at 8:42 PM BALATON Zoltan <balaton@xxxxxxxxxx> wrote: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 aThat'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 ZoltanThis 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 ofI think mainly because DEFINE_MACHINE* and DEFINE_SECURE_MACHINE* are not defined properly that causes them to not be extended easily. DEFINE_TYPES is another example, use them can extend easily, how about always use DEFINE_TYPES? Or add a DEFINE_TYPE to replace DEFINE_MACHINE* and DEFINE_SECURE_MACHINE*?Maybe I'm missing the problem but DEFINE_MACHINE macros are just convenience wrappers around DEFINE_MACHINE_EXTENDED. So why can't you add the needed parameter to DEFINE_MACHINE_EXTENDED and use that for machines that need it, or if it's needed by all machines then make the new parameter required and add it to all convenience wrappers too so you can keep using DEFINE_MACHINE* and just need to add one parameter to it in machines?That's the issue, add parameter to DEFINE_MACHINE_EXTENDED means all calls to it also need to be changed, that means touch many $target_arch files. currently it's 13. But after these That's not different from expanding the macro which would touch the same files. changes, there will be much more usage on it, and if we want to add more parameters or attributes to it, it will be a new tree-wide change. Do you expect to need more parameters? Can't you add them at once then? And DEFINE_TYPES do not suffer from such issues. As the TypeInfo[] is explicit defined for DEFINE_TYPES My point is that keeping the boiler plate as little as possible makes the code more readable. DEFINE_TYPES hides some of the boiler plate, DEFINE_MACHINE hides even more so converting to DEFINE_TYPES would expose some even if it's better than no macro at all. What exactly are the parameters missing from DEFINE_MACHINE_EXTENDED that need to be added? Regards, BALATON Zoltan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |