github.com/dylandreimerink/gobpfld@v0.6.1-0.20220205171531-e79c330ad608/ebpf/neg.go (about) 1 package ebpf 2 3 import "fmt" 4 5 var _ Instruction = (*Neg32)(nil) 6 7 type Neg32 struct { 8 Dest Register 9 } 10 11 func (a *Neg32) Raw() ([]RawInstruction, error) { 12 return []RawInstruction{ 13 {Op: BPF_ALU | BPF_NEG, Reg: NewReg(0, a.Dest)}, 14 }, nil 15 } 16 17 func (a *Neg32) String() string { 18 return fmt.Sprintf("w%s = -w%s", a.Dest, a.Dest) 19 } 20 21 var _ Instruction = (*Neg64)(nil) 22 23 type Neg64 struct { 24 Dest Register 25 } 26 27 func (a *Neg64) Raw() ([]RawInstruction, error) { 28 return []RawInstruction{ 29 {Op: BPF_ALU64 | BPF_NEG, Reg: NewReg(0, a.Dest)}, 30 }, nil 31 } 32 33 func (a *Neg64) String() string { 34 return fmt.Sprintf("r%s = -r%s", a.Dest, a.Dest) 35 }