Message ID | 20231010092901.99189-15-philmd@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | target: Make 'cpu-qom.h' really target agnostic | expand |
On 10/10/23 02:28, Philippe Mathieu-Daudé wrote: > When multiple QOM types are registered in the same file, > it is simpler to use the the DEFINE_TYPES() macro. In > particular because type array declared with such macro > are easier to review. > > In few commits we are going to add more types, so replace > the type_register_static() to ease further reviews. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > target/sparc/cpu.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
On 10/10/2023 10:28, Philippe Mathieu-Daudé wrote: > When multiple QOM types are registered in the same file, > it is simpler to use the the DEFINE_TYPES() macro. In > particular because type array declared with such macro > are easier to review. > > In few commits we are going to add more types, so replace > the type_register_static() to ease further reviews. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > target/sparc/cpu.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > > diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c > index 8ba96ae225..1e66413e94 100644 > --- a/target/sparc/cpu.c > +++ b/target/sparc/cpu.c > @@ -924,17 +924,21 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) > cc->tcg_ops = &sparc_tcg_ops; > } > > -static const TypeInfo sparc_cpu_type_info = { > - .name = TYPE_SPARC_CPU, > - .parent = TYPE_CPU, > - .instance_size = sizeof(SPARCCPU), > - .instance_align = __alignof(SPARCCPU), > - .instance_init = sparc_cpu_initfn, > - .abstract = true, > - .class_size = sizeof(SPARCCPUClass), > - .class_init = sparc_cpu_class_init, > +static const TypeInfo sparc_cpu_types[] = { > + { > + .name = TYPE_SPARC_CPU, > + .parent = TYPE_CPU, > + .instance_size = sizeof(SPARCCPU), > + .instance_align = __alignof(SPARCCPU), > + .instance_init = sparc_cpu_initfn, > + .abstract = true, > + .class_size = sizeof(SPARCCPUClass), > + .class_init = sparc_cpu_class_init, > + } > }; > > +DEFINE_TYPES(sparc_cpu_types) > + > static void sparc_cpu_cpudef_class_init(ObjectClass *oc, void *data) > { > SPARCCPUClass *scc = SPARC_CPU_CLASS(oc); > @@ -959,7 +963,6 @@ static void sparc_cpu_register_types(void) > { > int i; > > - type_register_static(&sparc_cpu_type_info); > for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { > sparc_register_cpudef_type(&sparc_defs[i]); > } Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> ATB, Mark.
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 8ba96ae225..1e66413e94 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -924,17 +924,21 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_ops = &sparc_tcg_ops; } -static const TypeInfo sparc_cpu_type_info = { - .name = TYPE_SPARC_CPU, - .parent = TYPE_CPU, - .instance_size = sizeof(SPARCCPU), - .instance_align = __alignof(SPARCCPU), - .instance_init = sparc_cpu_initfn, - .abstract = true, - .class_size = sizeof(SPARCCPUClass), - .class_init = sparc_cpu_class_init, +static const TypeInfo sparc_cpu_types[] = { + { + .name = TYPE_SPARC_CPU, + .parent = TYPE_CPU, + .instance_size = sizeof(SPARCCPU), + .instance_align = __alignof(SPARCCPU), + .instance_init = sparc_cpu_initfn, + .abstract = true, + .class_size = sizeof(SPARCCPUClass), + .class_init = sparc_cpu_class_init, + } }; +DEFINE_TYPES(sparc_cpu_types) + static void sparc_cpu_cpudef_class_init(ObjectClass *oc, void *data) { SPARCCPUClass *scc = SPARC_CPU_CLASS(oc); @@ -959,7 +963,6 @@ static void sparc_cpu_register_types(void) { int i; - type_register_static(&sparc_cpu_type_info); for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { sparc_register_cpudef_type(&sparc_defs[i]); }
When multiple QOM types are registered in the same file, it is simpler to use the the DEFINE_TYPES() macro. In particular because type array declared with such macro are easier to review. In few commits we are going to add more types, so replace the type_register_static() to ease further reviews. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- target/sparc/cpu.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)