aboutsummaryrefslogtreecommitdiffstats
path: root/sys/align.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-10-04 18:55:45 +0200
committerGitHub <noreply@github.com>2016-10-04 18:55:45 +0200
commit42d90e9394c8f4e06b46a65f1e3f932a1e4fc3d1 (patch)
treea1c278f4d18496efbbcaf21dc541e09c588710a3 /sys/align.go
parente73ddfcb3ac418fc690b982f70da15b898096fa5 (diff)
parentf2d77726c8e7d2662bda0414d55073cd51742ff3 (diff)
Merge pull request #77 from xairy/array_as_blob
Emit BufferBlob for array[int8]
Diffstat (limited to 'sys/align.go')
-rw-r--r--sys/align.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/align.go b/sys/align.go
index 6e8563da4..055a433f8 100644
--- a/sys/align.go
+++ b/sys/align.go
@@ -48,14 +48,19 @@ func addAlignment(t *StructType) {
off += pad
fields = append(fields, makePad(pad))
}
- off += f.Size()
fields = append(fields, f)
if at, ok := f.(ArrayType); ok && (at.Kind == ArrayRandLen || (at.Kind == ArrayRangeLen && at.RangeBegin != at.RangeEnd)) {
varLen = true
}
+ if at, ok := f.(BufferType); ok && (at.Kind == BufferBlobRand || (at.Kind == BufferBlobRange && at.RangeBegin != at.RangeEnd)) {
+ varLen = true
+ }
if varLen && i != len(t.Fields)-1 {
panic("embed array in middle of a struct")
}
+ if !varLen {
+ off += f.Size()
+ }
}
if align != 0 && off%align != 0 && !varLen {
pad := align - off%align