Skip to content

Commit

Permalink
Merge pull request #1967 from ibuclaw/target3
Browse files Browse the repository at this point in the history
Add new Target hook to retrieve member field alignment.
  • Loading branch information
yebblies committed May 7, 2013
2 parents 041f86c + bb5178a commit c3d0c0d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/declaration.c
Expand Up @@ -25,6 +25,7 @@
#include "statement.h"
#include "hdrgen.h"
#include "ctfe.h"
#include "target.h"

AggregateDeclaration *isAggregate(Type *t); // from opover.c

Expand Down Expand Up @@ -1841,7 +1842,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);
Expand Down
12 changes: 12 additions & 0 deletions src/target.c
Expand Up @@ -59,6 +59,10 @@ void Target::init()
}
}

/******************************
* Return memory alignment size of type.
*/

unsigned Target::alignsize (Type* type)
{
assert (type->isTypeBasic());
Expand Down Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions src/target.h
Expand Up @@ -25,6 +25,7 @@ struct Target

static void init();
static unsigned alignsize(Type* type);
static unsigned fieldalign(Type* type);
};

#endif

0 comments on commit c3d0c0d

Please sign in to comment.