]> Cypherpunks repositories - gostls13.git/commitdiff
change array padding in structures
authorKen Thompson <ken@golang.org>
Sat, 7 Feb 2009 21:31:34 +0000 (13:31 -0800)
committerKen Thompson <ken@golang.org>
Sat, 7 Feb 2009 21:31:34 +0000 (13:31 -0800)
to pad to size of element rather
than size of array.

R=r
OCL=24641
CL=24641

src/cmd/6g/align.c

index a2a8e2808bd540de2b204481ba34aae3bbe98177..dabd6385e7711a655bd0f609cda585ffb6a9b224 100644 (file)
@@ -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;
        }