aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-04 20:51:56 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-04 20:51:56 +0200
commit1c0d4caf7c7a6ddd5cf24091249448bf2e169495 (patch)
tree1f4d78d3a33158bfa05c415ddeddc6eaa5659995 /pkg
parentb6e402dd48c4b835a3a1cd53d4216fe0643392f5 (diff)
sys: change BitfieldLast to BitfieldMiddle
That's the condition we always want. Currently we always check: t.BitfieldOffset() == 0 || t.BitfieldLast() now can check just: !t.BitfieldMiddle()
Diffstat (limited to 'pkg')
-rw-r--r--pkg/compiler/gen.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go
index 6634609bd..62c36b735 100644
--- a/pkg/compiler/gen.go
+++ b/pkg/compiler/gen.go
@@ -141,7 +141,7 @@ func (comp *compiler) genStructDescs(syscalls []*sys.Call) []*sys.KeyedStruct {
t.TypeSize = 0
if !varlen {
for _, f := range t.Fields {
- if f.BitfieldLength() == 0 || f.BitfieldLast() {
+ if !f.BitfieldMiddle() {
t.TypeSize += f.Size()
}
}
@@ -230,30 +230,30 @@ func (comp *compiler) markBitfields(fields []sys.Type) {
if f.BitfieldLength() == 0 {
continue
}
- off, last := bfOffset, false
+ off, middle := bfOffset, true
bfOffset += f.BitfieldLength()
if i == len(fields)-1 || // Last bitfield in a group, if last field of the struct...
fields[i+1].BitfieldLength() == 0 || // or next field is not a bitfield...
f.Size() != fields[i+1].Size() || // or next field is of different size...
bfOffset+fields[i+1].BitfieldLength() > f.Size()*8 { // or next field does not fit into the current group.
- last, bfOffset = true, 0
+ middle, bfOffset = false, 0
}
- setBitfieldOffset(f, off, last)
+ setBitfieldOffset(f, off, middle)
}
}
-func setBitfieldOffset(t0 sys.Type, offset uint64, last bool) {
+func setBitfieldOffset(t0 sys.Type, offset uint64, middle bool) {
switch t := t0.(type) {
case *sys.IntType:
- t.BitfieldOff, t.BitfieldLst = offset, last
+ t.BitfieldOff, t.BitfieldMdl = offset, middle
case *sys.ConstType:
- t.BitfieldOff, t.BitfieldLst = offset, last
+ t.BitfieldOff, t.BitfieldMdl = offset, middle
case *sys.LenType:
- t.BitfieldOff, t.BitfieldLst = offset, last
+ t.BitfieldOff, t.BitfieldMdl = offset, middle
case *sys.FlagsType:
- t.BitfieldOff, t.BitfieldLst = offset, last
+ t.BitfieldOff, t.BitfieldMdl = offset, middle
case *sys.ProcType:
- t.BitfieldOff, t.BitfieldLst = offset, last
+ t.BitfieldOff, t.BitfieldMdl = offset, middle
default:
panic(fmt.Sprintf("type %#v can't be a bitfield", t))
}
@@ -280,7 +280,7 @@ func (comp *compiler) addAlignment(fields []sys.Type, varlen, packed bool, align
// TODO(dvyukov): this is wrong: if alignAttr!=0, we must use it, not max
align := alignAttr
for i, f := range fields {
- if i > 0 && (fields[i-1].BitfieldLength() == 0 || fields[i-1].BitfieldLast()) {
+ if i > 0 && !fields[i-1].BitfieldMiddle() {
a := comp.typeAlign(f)
if align < a {
align = a
@@ -293,7 +293,7 @@ func (comp *compiler) addAlignment(fields []sys.Type, varlen, packed bool, align
}
}
newFields = append(newFields, f)
- if (f.BitfieldLength() == 0 || f.BitfieldLast()) && (i != len(fields)-1 || !f.Varlen()) {
+ if !f.BitfieldMiddle() && (i != len(fields)-1 || !f.Varlen()) {
// Increase offset if the current field is not a bitfield
// or it's the last bitfield in a set, except when it's
// the last field in a struct and has variable length.