aboutsummaryrefslogtreecommitdiff
path: root/qom/object.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-09-13 14:46:17 -0700
committerRichard Henderson <richard.henderson@linaro.org>2023-10-03 08:01:02 -0700
commitad4ec2798fd7066bc9d879dcbdeae96073ad370f (patch)
tree86ac01d3c21906cd55f6748a7f0663496b8003b4 /qom/object.c
parentef6d8210a2570b5f7c5e02ab422c92f527b62be7 (diff)
downloadqemu-ad4ec2798fd7066bc9d879dcbdeae96073ad370f.zip
qemu-ad4ec2798fd7066bc9d879dcbdeae96073ad370f.tar.gz
qemu-ad4ec2798fd7066bc9d879dcbdeae96073ad370f.tar.bz2
qom: Propagate alignment through type system
Propagate alignment just like size. This is required in order to get the correct alignment on most cpu subclasses where the size and alignment is only specified for the base cpu type. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'qom/object.c')
-rw-r--r--qom/object.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c
index e25f1e9..8557fe8 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -220,6 +220,19 @@ static size_t type_object_get_size(TypeImpl *ti)
return 0;
}
+static size_t type_object_get_align(TypeImpl *ti)
+{
+ if (ti->instance_align) {
+ return ti->instance_align;
+ }
+
+ if (type_has_parent(ti)) {
+ return type_object_get_align(type_get_parent(ti));
+ }
+
+ return 0;
+}
+
size_t object_type_get_instance_size(const char *typename)
{
TypeImpl *type = type_get_by_name(typename);
@@ -293,6 +306,7 @@ static void type_initialize(TypeImpl *ti)
ti->class_size = type_class_get_size(ti);
ti->instance_size = type_object_get_size(ti);
+ ti->instance_align = type_object_get_align(ti);
/* Any type with zero instance_size is implicitly abstract.
* This means interface types are all abstract.
*/