list: fix shit

This commit is contained in:
anna 2021-08-05 17:11:54 +02:00
parent c24b183c60
commit b4046795c8
Signed by: fef
GPG key ID: EC22E476DC2D3D84

View file

@ -3,6 +3,8 @@
#pragma once #pragma once
#include <ardix/util.h> #include <ardix/util.h>
#include <stddef.h>
#include <toolchain.h> #include <toolchain.h>
struct list_head { struct list_head {
@ -50,7 +52,7 @@ __always_inline void list_init(struct list_head *head)
cursor = (cursor)->prev) cursor = (cursor)->prev)
#define list_for_each_safe(head, cursor, tmp) \ #define list_for_each_safe(head, cursor, tmp) \
for (cursor = (head)->next, tmp = cursor; \ for (cursor = (head)->next, tmp = (cursor)->next; \
tmp != (head); \ tmp != (head); \
tmp = (tmp)->next, cursor = tmp) tmp = (tmp)->next, cursor = tmp)
@ -67,7 +69,7 @@ __always_inline void list_init(struct list_head *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)->member != (head); \ (tmp)->member.prev != (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);