summaryrefslogtreecommitdiff
path: root/samples/bpf/libbpf.h
diff options
context:
space:
mode:
Diffstat (limited to 'samples/bpf/libbpf.h')
-rw-r--r--samples/bpf/libbpf.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/samples/bpf/libbpf.h b/samples/bpf/libbpf.h
index 3705fba453a0..8ab36a04c174 100644
--- a/samples/bpf/libbpf.h
+++ b/samples/bpf/libbpf.h
@@ -135,6 +135,16 @@ struct bpf_insn;
.off = OFF, \
.imm = 0 })
+/* Atomic memory add, *(uint *)(dst_reg + off16) += src_reg */
+
+#define BPF_STX_XADD(SIZE, DST, SRC, OFF) \
+ ((struct bpf_insn) { \
+ .code = BPF_STX | BPF_SIZE(SIZE) | BPF_XADD, \
+ .dst_reg = DST, \
+ .src_reg = SRC, \
+ .off = OFF, \
+ .imm = 0 })
+
/* Memory store, *(uint *) (dst_reg + off16) = imm32 */
#define BPF_ST_MEM(SIZE, DST, OFF, IMM) \