[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1610921764-7526-2-git-send-email-alan.maguire@oracle.com>
Date: Sun, 17 Jan 2021 22:16:01 +0000
From: Alan Maguire <alan.maguire@...cle.com>
To: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org
Cc: kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org, morbo@...gle.com,
shuah@...nel.org, bpf@...r.kernel.org, netdev@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
Alan Maguire <alan.maguire@...cle.com>
Subject: [PATCH v2 bpf-next 1/4] libbpf: add btf_has_size() and btf_int() inlines
BTF type data dumping will use them in later patches, and they
are useful generally when handling BTF data.
Signed-off-by: Alan Maguire <alan.maguire@...cle.com>
---
tools/lib/bpf/btf.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index 1237bcd..0c48f2e 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -294,6 +294,20 @@ static inline bool btf_is_datasec(const struct btf_type *t)
return btf_kind(t) == BTF_KIND_DATASEC;
}
+static inline bool btf_has_size(const struct btf_type *t)
+{
+ switch (BTF_INFO_KIND(t->info)) {
+ case BTF_KIND_INT:
+ case BTF_KIND_STRUCT:
+ case BTF_KIND_UNION:
+ case BTF_KIND_ENUM:
+ case BTF_KIND_DATASEC:
+ return true;
+ default:
+ return false;
+ }
+}
+
static inline __u8 btf_int_encoding(const struct btf_type *t)
{
return BTF_INT_ENCODING(*(__u32 *)(t + 1));
@@ -309,6 +323,11 @@ static inline __u8 btf_int_bits(const struct btf_type *t)
return BTF_INT_BITS(*(__u32 *)(t + 1));
}
+static inline __u32 btf_int(const struct btf_type *t)
+{
+ return *(__u32 *)(t + 1);
+}
+
static inline struct btf_array *btf_array(const struct btf_type *t)
{
return (struct btf_array *)(t + 1);
--
1.8.3.1
Powered by blists - more mailing lists