diff options
| author | Andrey Konovalov <andreyknvl@google.com> | 2017-01-17 18:55:06 +0100 |
|---|---|---|
| committer | Andrey Konovalov <andreyknvl@google.com> | 2017-01-18 13:07:53 +0100 |
| commit | 11fa77cbbed73f018515d2ec5c6bff4123aa763a (patch) | |
| tree | 18537dd3ac9a9558c3754c13fd5a19024838cf15 | |
| parent | ab500f0861124519ca4001a83c4e8752c6b3f3cb (diff) | |
prog, sys: fix struct with bitfields size calculation
| -rw-r--r-- | prog/prog.go | 4 | ||||
| -rw-r--r-- | sys/decl.go | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/prog/prog.go b/prog/prog.go index cd8f43d32..b6f4c62b2 100644 --- a/prog/prog.go +++ b/prog/prog.go @@ -112,7 +112,9 @@ func (a *Arg) Size() uintptr { case *sys.StructType: var size uintptr for _, fld := range a.Inner { - size += fld.Size() + if fld.Type.BitfieldLength() == 0 || fld.Type.BitfieldLast() { + size += fld.Size() + } } return size case *sys.UnionType: diff --git a/sys/decl.go b/sys/decl.go index 6c756fa07..d16534a7f 100644 --- a/sys/decl.go +++ b/sys/decl.go @@ -303,7 +303,9 @@ func (t *StructType) Size() uintptr { } var size uintptr for _, f := range t.Fields { - size += f.Size() + if f.BitfieldLength() == 0 || f.BitfieldLast() { + size += f.Size() + } } return size } |
