Skip to content

Commit

Permalink
qom: Propagate alignment through type system
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rth7680 committed Oct 3, 2023
1 parent ef6d821 commit ad4ec27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qom/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit ad4ec27

Please sign in to comment.