Commit 44a82746 authored by Rob Pike's avatar Rob Pike

minor tweak to still non-portable alignment calculation

R=rsc
DELTA=4  (1 added, 1 deleted, 2 changed)
OCL=18528
CL=18533
parent 554d0aa5
......@@ -289,12 +289,13 @@ func (t *StructTypeStruct) Size() int {
return t.size
}
size := 0;
structalignmask := 7; // BUG: we know structs are 8-aligned
for i := 0; i < len(t.field); i++ {
elemsize := t.field[i].typ.Get().Size();
// pad until at (elemsize mod 8) boundary
align := elemsize - 1;
if align > 7 { // BUG: we know structs are 8-aligned
align = 7
if align > structalignmask {
align = structalignmask
}
if align > 0 {
size = (size + align) & ^align;
......@@ -302,7 +303,6 @@ func (t *StructTypeStruct) Size() int {
t.field[i].offset = size;
size += elemsize;
}
structalignmask := 7; // TODO: knows that size fits in int32 (also can't use const here)
size = (size + structalignmask) & ^(structalignmask);
t.size = size;
return size;
......
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