X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=type.c;h=319a9fe41054a237d328bac4a17f73a5de3ca1ee;hb=569e996e365dd84091636a91c78ec1888bdb11ef;hp=b49f14027193b8e3df40dc950e221940b8ba249d;hpb=e0806e558f6c5611bcec6649f54d8a8a17ebe473;p=cparser diff --git a/type.c b/type.c index b49f140..319a9fe 100644 --- a/type.c +++ b/type.c @@ -6,6 +6,7 @@ #include +#include "adt/bitfiddle.h" #include "type_t.h" #include "types.h" #include "entity_t.h" @@ -1457,8 +1458,7 @@ void layout_struct_type(compound_type_t *type) alignment = m_alignment; if (!compound->packed) { - il_size_t new_offset = (offset + m_alignment-1) & -m_alignment; - + il_size_t const new_offset = round_up2(offset, m_alignment); if (new_offset > offset) { need_pad = true; offset = new_offset; @@ -1473,7 +1473,7 @@ next: } if (!compound->packed) { - il_size_t new_offset = (offset + alignment-1) & -alignment; + il_size_t const new_offset = round_up2(offset, alignment); if (new_offset > offset) { need_pad = true; offset = new_offset; @@ -1522,7 +1522,7 @@ void layout_union_type(compound_type_t *type) if (m_alignment > alignment) alignment = m_alignment; } - size = (size + alignment - 1) & -alignment; + size = round_up2(size, alignment); compound->size = size; compound->alignment = alignment;