aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec.go
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-01-10 16:45:52 +0100
committerAndrey Konovalov <andreyknvl@google.com>2017-01-17 13:25:33 +0100
commit54e0cede4384b7c1655f9183577bfccc11d9a7d5 (patch)
tree68e1f734a5e82ac7ecbe2968942d9983650ed8f8 /prog/encodingexec.go
parentf6c7b90523285663e51fc6804ae2c0c171bb390c (diff)
prog: add bitfields to templates
Now it's possible to use `int32:18` to denote a bitfield of size 18 as a struct field. This fixes #72.
Diffstat (limited to 'prog/encodingexec.go')
-rw-r--r--prog/encodingexec.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go
index 17cb2b553..57ff32eab 100644
--- a/prog/encodingexec.go
+++ b/prog/encodingexec.go
@@ -46,7 +46,9 @@ func (p *Prog) SerializeForExec(pid int) []byte {
w.args[base] = &argInfo{}
}
w.args[arg] = &argInfo{Offset: w.args[base].CurSize}
- w.args[base].CurSize += arg.Size()
+ if arg.Type.BitfieldLength() == 0 || arg.Type.BitfieldLast() {
+ w.args[base].CurSize += arg.Size()
+ }
})
// Generate copyin instructions that fill in data into pointer arguments.
foreachArg(c, func(arg, _ *Arg, _ *[]*Arg) {
@@ -149,6 +151,8 @@ func (w *execContext) writeArg(arg *Arg, pid int) {
w.write(ExecArgConst)
w.write(arg.Size())
w.write(arg.Value(pid))
+ w.write(arg.Type.BitfieldOffset())
+ w.write(arg.Type.BitfieldLength())
case ArgResult:
w.write(ExecArgResult)
w.write(arg.Size())
@@ -159,10 +163,14 @@ func (w *execContext) writeArg(arg *Arg, pid int) {
w.write(ExecArgConst)
w.write(arg.Size())
w.write(physicalAddr(arg))
+ w.write(0) // bit field offset
+ w.write(0) // bit field length
case ArgPageSize:
w.write(ExecArgConst)
w.write(arg.Size())
w.write(arg.AddrPage * pageSize)
+ w.write(0) // bit field offset
+ w.write(0) // bit field length
case ArgData:
w.write(ExecArgData)
w.write(uintptr(len(arg.Data)))