diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2014-04-08 22:52:18 +0200 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-04-11 06:47:26 +0400 |
commit | ba47f76156c7fbffe09c2f09fa41eb72aa5c06fd (patch) | |
tree | 4879f4c96c610993395d11fa6f2cc84254b790c3 | |
parent | f6bad674803eb1a6205ed9c440992aa0af7e535a (diff) | |
download | accel-ppp-ba47f76156c7fbffe09c2f09fa41eb72aa5c06fd.tar.gz accel-ppp-ba47f76156c7fbffe09c2f09fa41eb72aa5c06fd.zip |
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 <g.nault@alphalink.fr>
-rw-r--r-- | accel-pppd/triton/list.h | 13 |
1 files changed, 12 insertions, 1 deletions
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; } @@ -191,6 +191,17 @@ static inline void list_splice_init(struct list_head *list, ((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. * @head: the head for your list. |