Commit 56003374 authored by Ken Thompson's avatar Ken Thompson

change array padding in structures

to pad to size of element rather
than size of array.

R=r
OCL=24641
CL=24641
parent 8a70545b
......@@ -50,18 +50,28 @@ offmod(Type *t)
}
}
uint32
arrayelemwidth(Type *t)
{
while(t->etype == TARRAY && t->bound >= 0)
t = t->type;
return t->width;
}
uint32
widstruct(Type *t, uint32 o, int flag)
{
Type *f;
int32 w;
int32 w, m;
for(f=t->type; f!=T; f=f->down) {
if(f->etype != TFIELD)
fatal("widstruct: not TFIELD: %lT", f);
dowidth(f->type);
w = f->type->width;
o = rnd(o, w);
m = arrayelemwidth(f->type);
o = rnd(o, m);
f->width = o; // really offset for TFIELD
o += w;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment