diff options
Diffstat (limited to 'pkg/csource/csource.go')
| -rw-r--r-- | pkg/csource/csource.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 0c9f78e71..54cf2fa39 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -351,25 +351,27 @@ func (ctx *context) fmtCallBody(call prog.ExecCall) string { } funcName = fmt.Sprintf("((intptr_t(*)(%v))CAST(%v))", args, callName) } - for _, arg := range call.Args { + for i, arg := range call.Args { switch arg := arg.(type) { case prog.ExecArgConst: if arg.Format != prog.FormatNative && arg.Format != prog.FormatBigEndian { panic("string format in syscall argument") } + com := ctx.argComment(call.Meta.Args[i], arg) suf := ctx.literalSuffix(arg, native) - argsStrs = append(argsStrs, handleBigEndian(arg, ctx.constArgToStr(arg, suf))) + argsStrs = append(argsStrs, com+handleBigEndian(arg, ctx.constArgToStr(arg, suf))) case prog.ExecArgResult: if arg.Format != prog.FormatNative && arg.Format != prog.FormatBigEndian { panic("string format in syscall argument") } + com := ctx.argComment(call.Meta.Args[i], arg) val := ctx.resultArgToStr(arg) if native && ctx.target.PtrSize == 4 { // syscall accepts args as ellipsis, resources are uint64 // and take 2 slots without the cast, which would be wrong. val = "(intptr_t)" + val } - argsStrs = append(argsStrs, val) + argsStrs = append(argsStrs, com+val) default: panic(fmt.Sprintf("unknown arg type: %+v", arg)) } @@ -499,6 +501,10 @@ func (ctx *context) copyout(w *bytes.Buffer, call prog.ExecCall, resCopyout bool } } +func (ctx *context) argComment(field prog.Field, arg prog.ExecArg) string { + return "/*" + field.Name + "=" + "*/" +} + func (ctx *context) constArgToStr(arg prog.ExecArgConst, suffix string) string { mask := (uint64(1) << (arg.Size * 8)) - 1 v := arg.Value & mask |
