X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/1b471813a2ba287c2ace9cf6c866f330c725b99c..5fc669295655ec0eea7722aa4a48921dc6b700ec:/lunaix-os/includes/lunaix/ds/llist.h diff --git a/lunaix-os/includes/lunaix/ds/llist.h b/lunaix-os/includes/lunaix/ds/llist.h index 1a6ec9b..9af9dd1 100644 --- a/lunaix-os/includes/lunaix/ds/llist.h +++ b/lunaix-os/includes/lunaix/ds/llist.h @@ -64,7 +64,7 @@ llist_delete(struct llist_header* elem) static inline int llist_empty(struct llist_header* elem) { - return elem->next == elem; + return elem->next == elem && elem->prev == elem; } /** @@ -87,4 +87,27 @@ llist_empty(struct llist_header* elem) &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) +struct hlist_node +{ + struct hlist_node *next, **pprev; +}; + +static inline void +hlist_del(struct hlist_node* node) +{ + *node->pprev = node->next; + node->next = 0; + node->pprev = 0; +} + +static inline void +hlist_add(struct hlist_node** head, struct hlist_node* node) +{ + node->next = *head; + if (*head) { + (*head)->pprev = &node->next; + } + node->pprev = head; + *head = node; +} #endif /* __LUNAIX_LLIST_H */