list: fix list_for_each_entry_safe
This commit is contained in:
parent
203c167822
commit
b053cc3279
1 changed files with 7 additions and 5 deletions
|
@ -3,6 +3,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ardix/util.h>
|
#include <ardix/util.h>
|
||||||
|
#include <toolchain.h>
|
||||||
|
|
||||||
struct list_head {
|
struct list_head {
|
||||||
struct list_head *next;
|
struct list_head *next;
|
||||||
|
@ -15,10 +16,11 @@ struct list_head {
|
||||||
.prev = &name, \
|
.prev = &name, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define list_init(head) ({ \
|
__always_inline void list_init(struct list_head *head)
|
||||||
(head)->next = head; \
|
{
|
||||||
(head)->prev = head; \
|
head->prev = head;
|
||||||
})
|
head->next = head;
|
||||||
|
}
|
||||||
|
|
||||||
#define list_entry(ptr, type, member) \
|
#define list_entry(ptr, type, member) \
|
||||||
container_of(ptr, type, member)
|
container_of(ptr, type, member)
|
||||||
|
@ -65,7 +67,7 @@ struct list_head {
|
||||||
#define list_for_each_entry_safe(head, cursor, tmp, member) \
|
#define list_for_each_entry_safe(head, cursor, tmp, member) \
|
||||||
for (cursor = list_first_entry(head, typeof(*(cursor)), member), \
|
for (cursor = list_first_entry(head, typeof(*(cursor)), member), \
|
||||||
tmp = list_next_entry(cursor, member); \
|
tmp = list_next_entry(cursor, member); \
|
||||||
tmp != (head); \
|
&(tmp)->member != (head); \
|
||||||
cursor = tmp, tmp = list_next_entry(tmp, member))
|
cursor = tmp, tmp = list_next_entry(tmp, member))
|
||||||
|
|
||||||
void list_insert(struct list_head *head, struct list_head *new);
|
void list_insert(struct list_head *head, struct list_head *new);
|
||||||
|
|
Loading…
Reference in a new issue