forked from nuttx/nuttx-update
list: update list.h
The function name comes from list.h inside Linux, but rewrite from scratch to avoid the copyright issue. Since many developers are familiar with Linux list API. Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
50cad1536d
commit
dc096f951e
1 changed files with 15 additions and 0 deletions
|
@ -92,6 +92,8 @@
|
|||
#define list_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
#define list_first_entry(list, type, member) container_of((list)->next, type, member)
|
||||
#define list_last_entry(list, type, member) container_of((list)->prev, type, member)
|
||||
#define list_next_entry(list, type, member) container_of((list)->member.next, type, member)
|
||||
#define list_prev_entry(list, type, member) container_of((list)->member.prev, type, member)
|
||||
|
||||
#define list_add_after(entry, new_entry) list_add_head(entry, new_entry)
|
||||
#define list_add_head(list, item) \
|
||||
|
@ -129,6 +131,14 @@
|
|||
} \
|
||||
while (0)
|
||||
|
||||
#define list_delete_init(item) \
|
||||
do \
|
||||
{ \
|
||||
list_delete(item); \
|
||||
list_initialize(item); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define list_remove_head_type(list, type, member) \
|
||||
({ \
|
||||
FAR struct list_node *__node = list_remove_head(list); \
|
||||
|
@ -247,6 +257,11 @@
|
|||
&entry->member != (list); entry = temp, \
|
||||
temp = container_of(temp->member.next, type, member))
|
||||
|
||||
#define list_for_every_entry_continue(list, head, type, member) \
|
||||
for ((list) = list_next_entry(list, type, member); \
|
||||
&(list)->member != (head); \
|
||||
(list) = list_next_entry(list, type, member))
|
||||
|
||||
/* iterates over the list in reverse order, entry should be the container
|
||||
* structure type
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue