mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-02 06:39:07 +08:00
libbpf: Introduce bpf_ksym_exists() macro.
Introduce bpf_ksym_exists() macro that can be used by BPF programs to detect at load time whether particular ksym (either variable or kfunc) is present in the kernel. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20230317201920.62030-4-alexei.starovoitov@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
fd28ca4b5b
commit
c401b96718
@@ -177,6 +177,11 @@ enum libbpf_tristate {
|
|||||||
#define __kptr_untrusted __attribute__((btf_type_tag("kptr_untrusted")))
|
#define __kptr_untrusted __attribute__((btf_type_tag("kptr_untrusted")))
|
||||||
#define __kptr __attribute__((btf_type_tag("kptr")))
|
#define __kptr __attribute__((btf_type_tag("kptr")))
|
||||||
|
|
||||||
|
#define bpf_ksym_exists(sym) ({ \
|
||||||
|
_Static_assert(!__builtin_constant_p(!!sym), #sym " should be marked as __weak"); \
|
||||||
|
!!sym; \
|
||||||
|
})
|
||||||
|
|
||||||
#ifndef ___bpf_concat
|
#ifndef ___bpf_concat
|
||||||
#define ___bpf_concat(a, b) a ## b
|
#define ___bpf_concat(a, b) a ## b
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user