Add guard macros around likely/unlikely definitions such that, if defined previously, the compilation doesn't break. (Those macros, actually, will be defined in libbpf in a consequent commit.) Signed-off-by: Anton Protopopov <aspsk@xxxxxxxxxxxxx> --- tools/testing/selftests/bpf/bpf_arena_spin_lock.h | 5 +++++ tools/testing/selftests/bpf/progs/iters.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/tools/testing/selftests/bpf/bpf_arena_spin_lock.h b/tools/testing/selftests/bpf/bpf_arena_spin_lock.h index fb8dc0768999..d60d899dd9da 100644 --- a/tools/testing/selftests/bpf/bpf_arena_spin_lock.h +++ b/tools/testing/selftests/bpf/bpf_arena_spin_lock.h @@ -95,8 +95,13 @@ struct arena_qnode { #define _Q_LOCKED_VAL (1U << _Q_LOCKED_OFFSET) #define _Q_PENDING_VAL (1U << _Q_PENDING_OFFSET) +#ifndef likely #define likely(x) __builtin_expect(!!(x), 1) +#endif + +#ifndef unlikely #define unlikely(x) __builtin_expect(!!(x), 0) +#endif struct arena_qnode __arena qnodes[_Q_MAX_CPUS][_Q_MAX_NODES]; diff --git a/tools/testing/selftests/bpf/progs/iters.c b/tools/testing/selftests/bpf/progs/iters.c index 427b72954b87..1b9a908f2607 100644 --- a/tools/testing/selftests/bpf/progs/iters.c +++ b/tools/testing/selftests/bpf/progs/iters.c @@ -7,7 +7,9 @@ #include "bpf_misc.h" #include "bpf_compiler.h" +#ifndef unlikely #define unlikely(x) __builtin_expect(!!(x), 0) +#endif static volatile int zero = 0; -- 2.34.1