Message ID | 20221025222802.2295103-8-eddyz87@gmail.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | BPF |
Headers | show |
Series | Use uapi kernel headers with vmlinux.h | expand |
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index 68a70ac03c80..f8e8946b61a7 100644 --- a/tools/bpf/bpftool/btf.c +++ b/tools/bpf/bpftool/btf.c @@ -466,7 +466,9 @@ static int dump_btf_c(const struct btf *btf, struct btf_dump *d; int err = 0, i; - d = btf_dump__new(btf, btf_dump_printf, NULL, NULL); + LIBBPF_OPTS(btf_dump_opts, opts); + opts.emit_header_guards = true; + d = btf_dump__new(btf, btf_dump_printf, NULL, &opts); err = libbpf_get_error(d); if (err) return err;
Enables header guards generation for BTF dumps in C format, e.g. vmlinux.h would be printed as follows: ... #ifndef _UAPI_LINUX_TCP_H enum { TCP_NO_QUEUE = 0, TCP_RECV_QUEUE = 1, TCP_SEND_QUEUE = 2, TCP_QUEUES_NR = 3, }; #endif /* _UAPI_LINUX_TCP_H */ ... Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> --- tools/bpf/bpftool/btf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)