Skip to content

Commit df0147a

Browse files
theihorKernel Patches Daemon
authored andcommitted
bpf: Add BTF_ID_LIST_END and BTF_ID_LIST_SIZE macros
Implement macros in btf_ids.h to enable a calculation of BTF_ID_LIST size. This is done by declaring an additional __end symbol which can then be used as an indicator of the end of an array. Signed-off-by: Ihor Solodrai <[email protected]>
1 parent 0ff1d70 commit df0147a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/linux/btf_ids.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ asm( \
9797
__BTF_ID_LIST(name, local) \
9898
extern u32 name[];
9999

100+
/*
101+
* The BTF_ID_LIST_END macro may be used to denote an end
102+
* of a BTF_ID_LIST. This enables calculation of the list
103+
* size with BTF_ID_LIST_SIZE.
104+
*/
105+
#define BTF_ID_LIST_END(name) \
106+
BTF_ID_LIST(name##__end)
107+
#define BTF_ID_LIST_SIZE(name) \
108+
(name##__end - name)
109+
100110
#define BTF_ID_LIST_GLOBAL(name, n) \
101111
__BTF_ID_LIST(name, globl)
102112

0 commit comments

Comments
 (0)