Skip to content

Commit fd56e00

Browse files
anakryikoAlexei Starovoitov
authored and
Alexei Starovoitov
committed
libbpf: Fix use of PT_REGS_PARM macros with vmlinux.h
Add detection of vmlinux.h to bpf_tracing.h header for PT_REGS macro. Currently, BPF applications have to define __KERNEL__ symbol to use correct definition of struct pt_regs on x86 arch. This is due to different field names under internal kernel vs UAPI conditions. To make this more transparent for users, detect vmlinux.h by checking __VMLINUX_H__ symbol. Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent ca7dc27 commit fd56e00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/bpf_tracing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
#if defined(bpf_target_x86)
5151

52-
#ifdef __KERNEL__
52+
#if defined(__KERNEL__) || defined(__VMLINUX_H__)
5353
#define PT_REGS_PARM1(x) ((x)->di)
5454
#define PT_REGS_PARM2(x) ((x)->si)
5555
#define PT_REGS_PARM3(x) ((x)->dx)

0 commit comments

Comments
 (0)