| 1 | package asm |
| 2 | |
| 3 | import "github.com/cilium/ebpf/internal/platform" |
| 4 | |
| 5 | //go:generate go tool stringer -output func_string.go -type=BuiltinFunc |
| 6 | |
| 7 | // BuiltinFunc is a built-in eBPF function. |
| 8 | type BuiltinFunc uint32 |
| 9 | |
| 10 | // BuiltinFuncForPlatform returns a platform specific function constant. |
| 11 | // |
| 12 | // Use this if the library doesn't provide a constant yet. |
| 13 | func BuiltinFuncForPlatform(plat string, value uint32) (BuiltinFunc, error) { |
| 14 | return platform.EncodeConstant[BuiltinFunc](plat, value) |
| 15 | } |
| 16 | |
| 17 | // Call emits a function call. |
| 18 | func (fn BuiltinFunc) Call() Instruction { |
| 19 | return Instruction{ |
| 20 | OpCode: OpCode(JumpClass).SetJumpOp(Call), |
| 21 | Constant: int64(fn), |
| 22 | } |
| 23 | } |