Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libbpf: Use 100-character limit to make bpf_tracing.h easier to read

Improve bpf_tracing.h's macro definition readability by keeping them
single-line and better aligned. This makes it easier to follow all those
variadic patterns.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211222213924.1869758-2-andrii@kernel.org

authored by

Andrii Nakryiko and committed by
Alexei Starovoitov
f60edf5b 3cc31d79

+22 -32
+22 -32
tools/lib/bpf/bpf_tracing.h
··· 302 302 #define ___bpf_nth(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _a, _b, _c, N, ...) N 303 303 #endif 304 304 #ifndef ___bpf_narg 305 - #define ___bpf_narg(...) \ 306 - ___bpf_nth(_, ##__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 305 + #define ___bpf_narg(...) ___bpf_nth(_, ##__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 307 306 #endif 308 307 309 - #define ___bpf_ctx_cast0() ctx 310 - #define ___bpf_ctx_cast1(x) ___bpf_ctx_cast0(), (void *)ctx[0] 311 - #define ___bpf_ctx_cast2(x, args...) ___bpf_ctx_cast1(args), (void *)ctx[1] 312 - #define ___bpf_ctx_cast3(x, args...) ___bpf_ctx_cast2(args), (void *)ctx[2] 313 - #define ___bpf_ctx_cast4(x, args...) ___bpf_ctx_cast3(args), (void *)ctx[3] 314 - #define ___bpf_ctx_cast5(x, args...) ___bpf_ctx_cast4(args), (void *)ctx[4] 315 - #define ___bpf_ctx_cast6(x, args...) ___bpf_ctx_cast5(args), (void *)ctx[5] 316 - #define ___bpf_ctx_cast7(x, args...) ___bpf_ctx_cast6(args), (void *)ctx[6] 317 - #define ___bpf_ctx_cast8(x, args...) ___bpf_ctx_cast7(args), (void *)ctx[7] 318 - #define ___bpf_ctx_cast9(x, args...) ___bpf_ctx_cast8(args), (void *)ctx[8] 308 + #define ___bpf_ctx_cast0() ctx 309 + #define ___bpf_ctx_cast1(x) ___bpf_ctx_cast0(), (void *)ctx[0] 310 + #define ___bpf_ctx_cast2(x, args...) ___bpf_ctx_cast1(args), (void *)ctx[1] 311 + #define ___bpf_ctx_cast3(x, args...) ___bpf_ctx_cast2(args), (void *)ctx[2] 312 + #define ___bpf_ctx_cast4(x, args...) ___bpf_ctx_cast3(args), (void *)ctx[3] 313 + #define ___bpf_ctx_cast5(x, args...) ___bpf_ctx_cast4(args), (void *)ctx[4] 314 + #define ___bpf_ctx_cast6(x, args...) ___bpf_ctx_cast5(args), (void *)ctx[5] 315 + #define ___bpf_ctx_cast7(x, args...) ___bpf_ctx_cast6(args), (void *)ctx[6] 316 + #define ___bpf_ctx_cast8(x, args...) ___bpf_ctx_cast7(args), (void *)ctx[7] 317 + #define ___bpf_ctx_cast9(x, args...) ___bpf_ctx_cast8(args), (void *)ctx[8] 319 318 #define ___bpf_ctx_cast10(x, args...) ___bpf_ctx_cast9(args), (void *)ctx[9] 320 319 #define ___bpf_ctx_cast11(x, args...) ___bpf_ctx_cast10(args), (void *)ctx[10] 321 320 #define ___bpf_ctx_cast12(x, args...) ___bpf_ctx_cast11(args), (void *)ctx[11] 322 - #define ___bpf_ctx_cast(args...) \ 323 - ___bpf_apply(___bpf_ctx_cast, ___bpf_narg(args))(args) 321 + #define ___bpf_ctx_cast(args...) ___bpf_apply(___bpf_ctx_cast, ___bpf_narg(args))(args) 324 322 325 323 /* 326 324 * BPF_PROG is a convenience wrapper for generic tp_btf/fentry/fexit and ··· 351 353 352 354 struct pt_regs; 353 355 354 - #define ___bpf_kprobe_args0() ctx 355 - #define ___bpf_kprobe_args1(x) \ 356 - ___bpf_kprobe_args0(), (void *)PT_REGS_PARM1(ctx) 357 - #define ___bpf_kprobe_args2(x, args...) \ 358 - ___bpf_kprobe_args1(args), (void *)PT_REGS_PARM2(ctx) 359 - #define ___bpf_kprobe_args3(x, args...) \ 360 - ___bpf_kprobe_args2(args), (void *)PT_REGS_PARM3(ctx) 361 - #define ___bpf_kprobe_args4(x, args...) \ 362 - ___bpf_kprobe_args3(args), (void *)PT_REGS_PARM4(ctx) 363 - #define ___bpf_kprobe_args5(x, args...) \ 364 - ___bpf_kprobe_args4(args), (void *)PT_REGS_PARM5(ctx) 365 - #define ___bpf_kprobe_args(args...) \ 366 - ___bpf_apply(___bpf_kprobe_args, ___bpf_narg(args))(args) 356 + #define ___bpf_kprobe_args0() ctx 357 + #define ___bpf_kprobe_args1(x) ___bpf_kprobe_args0(), (void *)PT_REGS_PARM1(ctx) 358 + #define ___bpf_kprobe_args2(x, args...) ___bpf_kprobe_args1(args), (void *)PT_REGS_PARM2(ctx) 359 + #define ___bpf_kprobe_args3(x, args...) ___bpf_kprobe_args2(args), (void *)PT_REGS_PARM3(ctx) 360 + #define ___bpf_kprobe_args4(x, args...) ___bpf_kprobe_args3(args), (void *)PT_REGS_PARM4(ctx) 361 + #define ___bpf_kprobe_args5(x, args...) ___bpf_kprobe_args4(args), (void *)PT_REGS_PARM5(ctx) 362 + #define ___bpf_kprobe_args(args...) ___bpf_apply(___bpf_kprobe_args, ___bpf_narg(args))(args) 367 363 368 364 /* 369 365 * BPF_KPROBE serves the same purpose for kprobes as BPF_PROG for ··· 383 391 static __attribute__((always_inline)) typeof(name(0)) \ 384 392 ____##name(struct pt_regs *ctx, ##args) 385 393 386 - #define ___bpf_kretprobe_args0() ctx 387 - #define ___bpf_kretprobe_args1(x) \ 388 - ___bpf_kretprobe_args0(), (void *)PT_REGS_RC(ctx) 389 - #define ___bpf_kretprobe_args(args...) \ 390 - ___bpf_apply(___bpf_kretprobe_args, ___bpf_narg(args))(args) 394 + #define ___bpf_kretprobe_args0() ctx 395 + #define ___bpf_kretprobe_args1(x) ___bpf_kretprobe_args0(), (void *)PT_REGS_RC(ctx) 396 + #define ___bpf_kretprobe_args(args...) ___bpf_apply(___bpf_kretprobe_args, ___bpf_narg(args))(args) 391 397 392 398 /* 393 399 * BPF_KRETPROBE is similar to BPF_KPROBE, except, it only provides optional