Message ID | 20250212213249.45574-20-philmd@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | qom: Constify class_data | expand |
On 2/12/25 13:32, Philippe Mathieu-Daudé wrote: > All TypeInfo::class_data point to const data. > Enforce that in the structure, so future class_data > stays in .rodata. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > include/qom/object.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/qom/object.h b/include/qom/object.h > index 1d5b0337242..31adc2ef174 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -488,7 +488,7 @@ struct TypeInfo > > void (*class_init)(ObjectClass *klass, const void *data); > void (*class_base_init)(ObjectClass *klass, const void *data); > - const void *class_data; > + const void *const class_data; > > const InterfaceInfo *interfaces; > }; This doesn't do what you think it does. I'm surprised it compiles. r~
On 12/2/25 23:11, Richard Henderson wrote: > On 2/12/25 13:32, Philippe Mathieu-Daudé wrote: >> All TypeInfo::class_data point to const data. >> Enforce that in the structure, so future class_data >> stays in .rodata. >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> >> --- >> include/qom/object.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/qom/object.h b/include/qom/object.h >> index 1d5b0337242..31adc2ef174 100644 >> --- a/include/qom/object.h >> +++ b/include/qom/object.h >> @@ -488,7 +488,7 @@ struct TypeInfo >> void (*class_init)(ObjectClass *klass, const void *data); >> void (*class_base_init)(ObjectClass *klass, const void *data); >> - const void *class_data; >> + const void *const class_data; >> const InterfaceInfo *interfaces; >> }; > > > This doesn't do what you think it does. Per cdecl(1): const void *class_data; // declare class_data as pointer to const void const void *const class_data; // declare class_data as const pointer to const void > I'm surprised it compiles. I had to add the previous and virtio-pci patches to make it compile. How should be what I'm looking for, or how should I describe it? Thanks, Phil.
diff --git a/include/qom/object.h b/include/qom/object.h index 1d5b0337242..31adc2ef174 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -488,7 +488,7 @@ struct TypeInfo void (*class_init)(ObjectClass *klass, const void *data); void (*class_base_init)(ObjectClass *klass, const void *data); - const void *class_data; + const void *const class_data; const InterfaceInfo *interfaces; };
All TypeInfo::class_data point to const data. Enforce that in the structure, so future class_data stays in .rodata. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/qom/object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)