From bb5178aeb3970bcc1d1758b56b1c3393f63210c5 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 6 May 2013 01:17:56 +0100 Subject: [PATCH] Add new Target hook to retrieve member field alignment. --- src/declaration.c | 3 ++- src/target.c | 12 ++++++++++++ src/target.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/declaration.c b/src/declaration.c index 02ea16c8f334..52545cadae48 100644 --- a/src/declaration.c +++ b/src/declaration.c @@ -25,6 +25,7 @@ #include "statement.h" #include "hdrgen.h" #include "ctfe.h" +#include "target.h" AggregateDeclaration *isAggregate(Type *t); // from opover.c @@ -1833,7 +1834,7 @@ void VarDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, unsigned memsize = t->size(loc); // size of member - unsigned memalignsize = t->alignsize(); // size of member for alignment purposes + unsigned memalignsize = Target::fieldalign(t); // size of member for alignment purposes offset = AggregateDeclaration::placeField(poffset, memsize, memalignsize, alignment, &ad->structsize, &ad->alignsize, isunion); diff --git a/src/target.c b/src/target.c index 894d5ae424a4..da07a9dc63c0 100644 --- a/src/target.c +++ b/src/target.c @@ -59,6 +59,10 @@ void Target::init() } } +/****************************** + * Return memory alignment size of type. + */ + unsigned Target::alignsize (Type* type) { assert (type->isTypeBasic()); @@ -92,3 +96,11 @@ unsigned Target::alignsize (Type* type) return type->size(0); } +/****************************** + * Return field alignment size of type. + */ + +unsigned Target::fieldalign (Type* type) +{ + return type->alignsize(); +} diff --git a/src/target.h b/src/target.h index 1a7d759a94b5..ad3d956d0a04 100644 --- a/src/target.h +++ b/src/target.h @@ -25,6 +25,7 @@ struct Target static void init(); static unsigned alignsize(Type* type); + static unsigned fieldalign(Type* type); }; #endif