Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btf: Add BTF_ID_LIST_SINGLE macro

Add a convenience macro that allows defining a BTF ID list with
a single item. This lets us cut down on repetitive macros.

Suggested-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200921121227.255763-4-lmb@cloudflare.com

authored by

Lorenz Bauer and committed by
Alexei Starovoitov
27774b70 0d004c02

+16
+8
include/linux/btf_ids.h
··· 76 76 #define BTF_ID_LIST_GLOBAL(name) \ 77 77 __BTF_ID_LIST(name, globl) 78 78 79 + /* The BTF_ID_LIST_SINGLE macro defines a BTF_ID_LIST with 80 + * a single entry. 81 + */ 82 + #define BTF_ID_LIST_SINGLE(name, prefix, typename) \ 83 + BTF_ID_LIST(name) \ 84 + BTF_ID(prefix, typename) 85 + 79 86 /* 80 87 * The BTF_ID_UNUSED macro defines 4 zero bytes. 81 88 * It's used when we want to define 'unused' entry ··· 147 140 #define BTF_ID(prefix, name) 148 141 #define BTF_ID_UNUSED 149 142 #define BTF_ID_LIST_GLOBAL(name) u32 name[1]; 143 + #define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 name[1]; 150 144 #define BTF_SET_START(name) static struct btf_id_set name = { 0 }; 151 145 #define BTF_SET_START_GLOBAL(name) static struct btf_id_set name = { 0 }; 152 146 #define BTF_SET_END(name)
+8
tools/include/linux/btf_ids.h
··· 76 76 #define BTF_ID_LIST_GLOBAL(name) \ 77 77 __BTF_ID_LIST(name, globl) 78 78 79 + /* The BTF_ID_LIST_SINGLE macro defines a BTF_ID_LIST with 80 + * a single entry. 81 + */ 82 + #define BTF_ID_LIST_SINGLE(name, prefix, typename) \ 83 + BTF_ID_LIST(name) \ 84 + BTF_ID(prefix, typename) 85 + 79 86 /* 80 87 * The BTF_ID_UNUSED macro defines 4 zero bytes. 81 88 * It's used when we want to define 'unused' entry ··· 147 140 #define BTF_ID(prefix, name) 148 141 #define BTF_ID_UNUSED 149 142 #define BTF_ID_LIST_GLOBAL(name) u32 name[1]; 143 + #define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 name[1]; 150 144 #define BTF_SET_START(name) static struct btf_id_set name = { 0 }; 151 145 #define BTF_SET_START_GLOBAL(name) static struct btf_id_set name = { 0 }; 152 146 #define BTF_SET_END(name)