list: Adopt list_next_entry() from the Linux kernel

We'll use it to traverse the list of opaque btf_encoder entries in
pahole.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-07-26 17:01:48 -03:00
parent 6edae3e768
commit e9b83dba79
1 changed files with 8 additions and 0 deletions

8
list.h
View File

@ -289,6 +289,14 @@ static inline void list_splice_init(struct list_head *list,
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
/**
* list_next_entry - get the next element in list
* @pos: the type * to cursor
* @member: the name of the list_head within the struct.
*/
#define list_next_entry(pos, member) \
list_entry((pos)->member.next, typeof(*(pos)), member)
/**
* list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop cursor.