aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler
diff options
context:
space:
mode:
authorPimyn Girgis <bemenboshra2001@gmail.com>2024-08-06 14:10:45 +0000
committerDmitry Vyukov <dvyukov@google.com>2024-08-12 09:22:32 +0000
commit421e1cbedb47cb499201512defc2baf79d7b87f7 (patch)
treed3575138e30c98c96e6ecc180b4b06fdcd71fa4b /pkg/compiler
parent1fef415f27727712346c8e7ad9c945e74d217b1b (diff)
pkg/mgrconfig, prog, tools: allow automatically generated or manually written descriptions or both
Add "Auto" type and allow to choose descriptions mode in configurations. Defaults to using manual only.
Diffstat (limited to 'pkg/compiler')
-rw-r--r--pkg/compiler/gen.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/pkg/compiler/gen.go b/pkg/compiler/gen.go
index 1fcf8dcac..891cd1644 100644
--- a/pkg/compiler/gen.go
+++ b/pkg/compiler/gen.go
@@ -78,7 +78,7 @@ func (comp *compiler) collectCallArgSizes() map[string][]uint64 {
comp.error(arg.Pos, "%v arg %v is larger than pointer size", n.Name.Name, arg.Name.Name)
continue
}
- argID := fmt.Sprintf("%v|%v", n.CallName, i)
+ argID := fmt.Sprintf("%v|%v", getCallName(n), i)
if _, ok := argPos[argID]; !ok {
argSizes[i] = typ.Size()
argPos[argID] = arg.Pos
@@ -90,17 +90,26 @@ func (comp *compiler) collectCallArgSizes() map[string][]uint64 {
continue
}
}
- callArgSizes[n.CallName] = argSizes
+ callArgSizes[getCallName(n)] = argSizes
}
return callArgSizes
}
+func getCallName(n *ast.Call) string {
+ for _, attr := range n.Attrs {
+ if attr.Ident == "automatic" {
+ return n.Name.Name
+ }
+ }
+ return n.CallName
+}
+
func (comp *compiler) genSyscalls() []*prog.Syscall {
callArgSizes := comp.collectCallArgSizes()
var calls []*prog.Syscall
for _, decl := range comp.desc.Nodes {
if n, ok := decl.(*ast.Call); ok && n.NR != ^uint64(0) {
- calls = append(calls, comp.genSyscall(n, callArgSizes[n.CallName]))
+ calls = append(calls, comp.genSyscall(n, callArgSizes[getCallName(n)]))
}
}
// We assign SquashableElem here rather than during pointer type generation