projects
/
platform
/
kernel
/
linux-starfive.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5fc13ad
)
libbpf: Introduce bpf_ksym_exists() macro.
author
Alexei Starovoitov
<ast@kernel.org>
Fri, 17 Mar 2023 20:19:19 +0000
(13:19 -0700)
committer
Andrii Nakryiko
<andrii@kernel.org>
Fri, 17 Mar 2023 22:46:00 +0000
(15:46 -0700)
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
tools/lib/bpf/bpf_helpers.h
patch
|
blob
|
history
diff --git
a/tools/lib/bpf/bpf_helpers.h
b/tools/lib/bpf/bpf_helpers.h
index
7d12d3e
..
e7e1a8a
100644
(file)
--- a/
tools/lib/bpf/bpf_helpers.h
+++ b/
tools/lib/bpf/bpf_helpers.h
@@
-177,6
+177,11
@@
enum libbpf_tristate {
#define __kptr_untrusted __attribute__((btf_type_tag("kptr_untrusted")))
#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
#define ___bpf_concat(a, b) a ## b
#endif