diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2022-07-06 06:56:48 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-07-06 07:15:19 +0300 |
commit | b8a195dc299391bc171c47971974ec6d5ea6fb14 (patch) | |
tree | 63e855285962578ce692db6cdfbc96ed5f6a82c3 /tools/lib | |
parent | ec6209c8d42f815bc3bef10934637ca92114cd1b (diff) | |
download | linux-b8a195dc299391bc171c47971974ec6d5ea6fb14.tar.xz |
libbpf: add bpf_core_type_matches() helper macro
This patch finalizes support for the proposed type match relation in libbpf by
adding bpf_core_type_matches() macro which emits TYPE_MATCH relocation.
Clang support for this relocation was added in [0].
[0] https://reviews.llvm.org/D126838
Signed-off-by: Daniel Müller <deso@posteo.net>¬
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>¬
Link: https://lore.kernel.org/bpf/20220628160127.607834-7-deso@posteo.net¬
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/bpf/bpf_core_read.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf_core_read.h b/tools/lib/bpf/bpf_core_read.h index 2308f4990e96..496e6a8ee0dc 100644 --- a/tools/lib/bpf/bpf_core_read.h +++ b/tools/lib/bpf/bpf_core_read.h @@ -185,6 +185,16 @@ enum bpf_enum_value_kind { __builtin_preserve_type_info(*(typeof(type) *)0, BPF_TYPE_EXISTS) /* + * Convenience macro to check that provided named type + * (struct/union/enum/typedef) "matches" that in a target kernel. + * Returns: + * 1, if the type matches in the target kernel's BTF; + * 0, if the type does not match any in the target kernel + */ +#define bpf_core_type_matches(type) \ + __builtin_preserve_type_info(*(typeof(type) *)0, BPF_TYPE_MATCHES) + +/* * Convenience macro to get the byte size of a provided named type * (struct/union/enum/typedef) in a target kernel. * Returns: |