From: Lorenz Bauer <lmb@cloudflare.com>
To: ast@kernel.org, yhs@fb.com, daniel@iogearbox.net, kafai@fb.com,
andriin@fb.com
Cc: bpf@vger.kernel.org, kernel-team@cloudflare.com,
Lorenz Bauer <lmb@cloudflare.com>
Subject: [PATCH bpf-next v3 03/11] btf: Add BTF_ID_LIST_SINGLE macro
Date: Thu, 10 Sep 2020 13:56:23 +0100 [thread overview]
Message-ID: <20200910125631.225188-4-lmb@cloudflare.com> (raw)
In-Reply-To: <20200910125631.225188-1-lmb@cloudflare.com>
Add a convenience macro that allows defining a BTF ID list with
a single item. This lets us cut down on repetitive macros.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Suggested-by: Andrii Nakryiko <andriin@fb.com>
---
include/linux/btf_ids.h | 8 ++++++++
tools/include/linux/btf_ids.h | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
index 210b086188a3..57890b357f85 100644
--- a/include/linux/btf_ids.h
+++ b/include/linux/btf_ids.h
@@ -76,6 +76,13 @@ extern u32 name[];
#define BTF_ID_LIST_GLOBAL(name) \
__BTF_ID_LIST(name, globl)
+/* The BTF_ID_LIST_SINGLE macro defines a BTF_ID_LIST with
+ * a single entry.
+ */
+#define BTF_ID_LIST_SINGLE(name, prefix, typename) \
+ BTF_ID_LIST(name) \
+ BTF_ID(prefix, typename)
+
/*
* The BTF_ID_UNUSED macro defines 4 zero bytes.
* It's used when we want to define 'unused' entry
@@ -140,6 +147,7 @@ extern struct btf_id_set name;
#define BTF_ID(prefix, name)
#define BTF_ID_UNUSED
#define BTF_ID_LIST_GLOBAL(name) u32 name[1];
+#define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 name[1];
#define BTF_SET_START(name) static struct btf_id_set name = { 0 };
#define BTF_SET_START_GLOBAL(name) static struct btf_id_set name = { 0 };
#define BTF_SET_END(name)
diff --git a/tools/include/linux/btf_ids.h b/tools/include/linux/btf_ids.h
index 210b086188a3..57890b357f85 100644
--- a/tools/include/linux/btf_ids.h
+++ b/tools/include/linux/btf_ids.h
@@ -76,6 +76,13 @@ extern u32 name[];
#define BTF_ID_LIST_GLOBAL(name) \
__BTF_ID_LIST(name, globl)
+/* The BTF_ID_LIST_SINGLE macro defines a BTF_ID_LIST with
+ * a single entry.
+ */
+#define BTF_ID_LIST_SINGLE(name, prefix, typename) \
+ BTF_ID_LIST(name) \
+ BTF_ID(prefix, typename)
+
/*
* The BTF_ID_UNUSED macro defines 4 zero bytes.
* It's used when we want to define 'unused' entry
@@ -140,6 +147,7 @@ extern struct btf_id_set name;
#define BTF_ID(prefix, name)
#define BTF_ID_UNUSED
#define BTF_ID_LIST_GLOBAL(name) u32 name[1];
+#define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 name[1];
#define BTF_SET_START(name) static struct btf_id_set name = { 0 };
#define BTF_SET_START_GLOBAL(name) static struct btf_id_set name = { 0 };
#define BTF_SET_END(name)
--
2.25.1
next prev parent reply other threads:[~2020-09-10 21:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 12:56 [PATCH bpf-next v3 00/11] Make check_func_arg type checks table driven Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 01/11] btf: make btf_set_contains take a const pointer Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 02/11] bpf: check scalar or invalid register in check_helper_mem_access Lorenz Bauer
2020-09-10 12:56 ` Lorenz Bauer [this message]
2020-09-10 17:28 ` [PATCH bpf-next v3 03/11] btf: Add BTF_ID_LIST_SINGLE macro Martin KaFai Lau
2020-09-10 12:56 ` [PATCH bpf-next v3 04/11] bpf: allow specifying a BTF ID per argument in function protos Lorenz Bauer
2020-09-10 17:58 ` Martin KaFai Lau
2020-09-11 9:41 ` Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 05/11] bpf: make BTF pointer type checking generic Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 06/11] bpf: make reference tracking generic Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 07/11] bpf: make context access check generic Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 08/11] bpf: set meta->raw_mode for pointers close to use Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 09/11] bpf: check ARG_PTR_TO_SPINLOCK register type in check_func_arg Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 10/11] bpf: hoist type checking for nullable arg types Lorenz Bauer
2020-09-10 12:56 ` [PATCH bpf-next v3 11/11] bpf: use a table to drive helper arg type checks Lorenz Bauer
2020-09-10 17:53 ` Martin KaFai Lau
2020-09-16 17:00 ` [PATCH bpf-next v3 00/11] Make check_func_arg type checks table driven Martin KaFai Lau
2020-09-16 17:54 ` Lorenz Bauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200910125631.225188-4-lmb@cloudflare.com \
--to=lmb@cloudflare.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=kernel-team@cloudflare.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox