On 9/2/25 19:53, Philippe Mathieu-Daudé wrote:
On 9/2/25 19:44, Philippe Mathieu-Daudé wrote:
On 6/2/25 22:16, Richard Henderson wrote:
It would be nice if this were const, i.e.
.class_data = (void *) &(const RISCVCPUDef){
...
},
This will in fact create an anonymous object in .rodata.
We have other uses that do the extra casting away const,
e.g. armsse_variants in hw/arm/armsse.c. Although I suspect
*all* usage of .class_init can and should be with const data.
The only non-const use I noticed is Xtensa:
Also the object_class_foreach() callbacks update 'data':
static void object_class_get_list_tramp(ObjectClass *klass, void *opaque)
{
GSList **list = opaque;
*list = g_slist_prepend(*list, klass);
}
GSList *object_class_get_list(const char *implements_type,
bool include_abstract)
{
GSList *list = NULL;
object_class_foreach(object_class_get_list_tramp,
implements_type, include_abstract, &list);
return list;
}