From 569e996e365dd84091636a91c78ec1888bdb11ef Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Tue, 25 Dec 2012 19:26:57 +0100 Subject: [PATCH] cleanup: Use round_up2() instead of duplicating it. --- adt/bitfiddle.h | 2 ++ type.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/adt/bitfiddle.h b/adt/bitfiddle.h index 7aeb33a..334d3a5 100644 --- a/adt/bitfiddle.h +++ b/adt/bitfiddle.h @@ -12,7 +12,9 @@ #ifndef _FIRM_BITFIDDLE_H_ #define _FIRM_BITFIDDLE_H_ +#include #include + #include "util.h" /* some functions here assume ints are 32 bit wide */ 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; -- 2.20.1