From ba47f76156c7fbffe09c2f09fa41eb72aa5c06fd Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Tue, 8 Apr 2014 22:52:18 +0200 Subject: triton: implement list_first_entry() * Add list_first_entry() to list.h * Declare parameter of list_empty() as const Both changes are already included in Linux kernel sources. Signed-off-by: Guillaume Nault --- accel-pppd/triton/list.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/accel-pppd/triton/list.h b/accel-pppd/triton/list.h index d95dd71..b17afab 100644 --- a/accel-pppd/triton/list.h +++ b/accel-pppd/triton/list.h @@ -135,7 +135,7 @@ static inline void list_move_tail(struct list_head *list, * list_empty - tests whether a list is empty * @head: the list to test. */ -static inline int list_empty(struct list_head *head) +static inline int list_empty(const struct list_head *head) { return head->next == head; } @@ -190,6 +190,17 @@ static inline void list_splice_init(struct list_head *list, #define list_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) +/** + * list_first_entry - get the first element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + * + * Note, that list is expected to be not empty. + */ +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->next, type, member) + /** * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop counter. -- cgit v1.2.3