aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-26 18:21:51 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-26 18:21:51 +0100
commit6284466bc9b948ccf0bfbdb4c80475712d1883c0 (patch)
tree0362f921e431f15a3b8b8cee3da5dec5bf6ac823 /sys
parentd1322dff4c35c033147ce97845e394576d42d7e9 (diff)
prog: properly squash bitfields
Diffstat (limited to 'sys')
-rw-r--r--sys/test/32.go14
-rw-r--r--sys/test/64.go14
-rw-r--r--sys/test/any.txt12
3 files changed, 35 insertions, 5 deletions
diff --git a/sys/test/32.go b/sys/test/32.go
index ca7c3715e..8b3dc2892 100644
--- a/sys/test/32.go
+++ b/sys/test/32.go
@@ -23,7 +23,8 @@ var structDescs_32 = []*KeyedStruct{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16be", FldName: "f3", TypeSize: 2}, BigEndian: true}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 6}}, IsPad: true},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int64", FldName: "f4", TypeSize: 8}}},
- &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f5", IsVarlen: true}, Type: &StructType{Key: StructKey{Name: "any1"}}},
+ &StructType{Key: StructKey{Name: "anybitfields"}, FldName: "f5"},
+ &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f6", IsVarlen: true}, Type: &StructType{Key: StructKey{Name: "any1"}}},
}, AlignAttr: 8}},
{Key: StructKey{Name: "any1"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "any1", IsVarlen: true}, Fields: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "f1", TypeSize: 4, IsOptional: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", TypeSize: 1}}}},
@@ -32,6 +33,15 @@ var structDescs_32 = []*KeyedStruct{
&UnionType{Key: StructKey{Name: "anyunion1"}, FldName: "f4"},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f5", IsVarlen: true}},
}, AlignAttr: 2}},
+ {Key: StructKey{Name: "anybitfields"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "anybitfields", TypeSize: 4}, Fields: []Type{
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}, BitfieldLen: 2, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f2", TypeSize: 1}, BitfieldOff: 2, BitfieldLen: 3, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f3", TypeSize: 1}, BitfieldOff: 5, BitfieldLen: 1}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 1}}, IsPad: true},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f4", TypeSize: 2}, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f5", TypeSize: 2}, BitfieldOff: 1, BitfieldLen: 10, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f6", TypeSize: 2}, BitfieldOff: 11, BitfieldLen: 3}},
+ }}},
{Key: StructKey{Name: "anyunion0"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "anyunion0", TypeSize: 8}, Fields: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "anyres32", FldName: "res32", TypeSize: 4}},
&ResourceType{TypeCommon: TypeCommon{TypeName: "anyres64", FldName: "res64", TypeSize: 8}},
@@ -772,4 +782,4 @@ var consts_32 = []ConstValue{
{Name: "ONLY_32BITS_CONST", Value: 1},
}
-const revision_32 = "0d78e9b1f441c9ae33361f9778195af0a245ffdd"
+const revision_32 = "10a1935b1f3ef8f206e29a3b6863de4cac10bd9e"
diff --git a/sys/test/64.go b/sys/test/64.go
index 9407c1873..ed996452d 100644
--- a/sys/test/64.go
+++ b/sys/test/64.go
@@ -23,7 +23,8 @@ var structDescs_64 = []*KeyedStruct{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16be", FldName: "f3", TypeSize: 2}, BigEndian: true}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 6}}, IsPad: true},
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int64", FldName: "f4", TypeSize: 8}}},
- &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f5", IsVarlen: true}, Type: &StructType{Key: StructKey{Name: "any1"}}},
+ &StructType{Key: StructKey{Name: "anybitfields"}, FldName: "f5"},
+ &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f6", IsVarlen: true}, Type: &StructType{Key: StructKey{Name: "any1"}}},
}, AlignAttr: 8}},
{Key: StructKey{Name: "any1"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "any1", IsVarlen: true}, Fields: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "f1", TypeSize: 8, IsOptional: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", TypeSize: 1}}}},
@@ -32,6 +33,15 @@ var structDescs_64 = []*KeyedStruct{
&UnionType{Key: StructKey{Name: "anyunion1"}, FldName: "f4"},
&BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "f5", IsVarlen: true}},
}, AlignAttr: 2}},
+ {Key: StructKey{Name: "anybitfields"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "anybitfields", TypeSize: 4}, Fields: []Type{
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}, BitfieldLen: 2, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f2", TypeSize: 1}, BitfieldOff: 2, BitfieldLen: 3, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f3", TypeSize: 1}, BitfieldOff: 5, BitfieldLen: 1}},
+ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 1}}, IsPad: true},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f4", TypeSize: 2}, BitfieldLen: 1, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f5", TypeSize: 2}, BitfieldOff: 1, BitfieldLen: 10, BitfieldMdl: true}},
+ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", FldName: "f6", TypeSize: 2}, BitfieldOff: 11, BitfieldLen: 3}},
+ }}},
{Key: StructKey{Name: "anyunion0"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "anyunion0", TypeSize: 8}, Fields: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "anyres32", FldName: "res32", TypeSize: 4}},
&ResourceType{TypeCommon: TypeCommon{TypeName: "anyres64", FldName: "res64", TypeSize: 8}},
@@ -770,4 +780,4 @@ var consts_64 = []ConstValue{
{Name: "IPPROTO_UDP", Value: 17},
}
-const revision_64 = "e361957ea430829459298bc20840e4edbd324930"
+const revision_64 = "7c718fa299ed570a4acbd25a1fcf2448c4e2a2d4"
diff --git a/sys/test/any.txt b/sys/test/any.txt
index 6a4e285ac..b0a0d0162 100644
--- a/sys/test/any.txt
+++ b/sys/test/any.txt
@@ -13,7 +13,8 @@ any0 {
f2 int32
f3 int16be
f4 int64
- f5 array[any1]
+ f5 anybitfields
+ f6 array[any1]
} [align_8]
any1 {
@@ -33,3 +34,12 @@ anyunion1 [
i8 int8
i32 int32
] [varlen]
+
+anybitfields {
+ f1 int8:2
+ f2 int8:3
+ f3 int8:1
+ f4 int16:1
+ f5 int16:10
+ f6 int16:3
+}