281 #define DLIST_STATIC_INIT(name) {{&(name).head, &(name).head}}
282 #define DCLIST_STATIC_INIT(name) {{{&(name).dlist.head, &(name).dlist.head}}, 0}
283 #define SLIST_STATIC_INIT(name) {{NULL}}
302 #define dlist_member_check(head, node) ((void) (head))
303 #define dlist_check(head) ((void) (head))
304 #define slist_check(head) ((void) (head))
528 (node->
next != NULL && node->
prev != NULL));
530 return node->
next == NULL;
558 return (
char *) head->
head.
next - off;
575 return (
char *) head->
head.
prev - off;
593 #define dlist_container(type, membername, ptr) \
594 (AssertVariableIsOfTypeMacro(ptr, dlist_node *), \
595 AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
596 ((type *) ((char *) (ptr) - offsetof(type, membername))))
603 #define dlist_head_element(type, membername, lhead) \
604 (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
605 (type *) dlist_head_element_off(lhead, offsetof(type, membername)))
612 #define dlist_tail_element(type, membername, lhead) \
613 (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
614 ((type *) dlist_tail_element_off(lhead, offsetof(type, membername))))
623 #define dlist_foreach(iter, lhead) \
624 for (AssertVariableIsOfTypeMacro(iter, dlist_iter), \
625 AssertVariableIsOfTypeMacro(lhead, dlist_head *), \
626 (iter).end = &(lhead)->head, \
627 (iter).cur = (iter).end->next ? (iter).end->next : (iter).end; \
628 (iter).cur != (iter).end; \
629 (iter).cur = (iter).cur->next)
640 #define dlist_foreach_modify(iter, lhead) \
641 for (AssertVariableIsOfTypeMacro(iter, dlist_mutable_iter), \
642 AssertVariableIsOfTypeMacro(lhead, dlist_head *), \
643 (iter).end = &(lhead)->head, \
644 (iter).cur = (iter).end->next ? (iter).end->next : (iter).end, \
645 (iter).next = (iter).cur->next; \
646 (iter).cur != (iter).end; \
647 (iter).cur = (iter).next, (iter).next = (iter).cur->next)
654 #define dlist_reverse_foreach(iter, lhead) \
655 for (AssertVariableIsOfTypeMacro(iter, dlist_iter), \
656 AssertVariableIsOfTypeMacro(lhead, dlist_head *), \
657 (iter).end = &(lhead)->head, \
658 (iter).cur = (iter).end->prev ? (iter).end->prev : (iter).end; \
659 (iter).cur != (iter).end; \
660 (iter).cur = (iter).cur->prev)
685 return (head->
count == 0);
947 #define dclist_container(type, membername, ptr) \
948 dlist_container(type, membername, ptr)
955 #define dclist_head_element(type, membername, lhead) \
956 (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
957 (type *) dclist_head_element_off(lhead, offsetof(type, membername)))
964 #define dclist_tail_element(type, membername, lhead) \
965 (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, dlist_node), \
966 ((type *) dclist_tail_element_off(lhead, offsetof(type, membername))))
970 #define dclist_foreach(iter, lhead) \
971 dlist_foreach(iter, &((lhead)->dlist))
973 #define dclist_foreach_modify(iter, lhead) \
974 dlist_foreach_modify(iter, &((lhead)->dlist))
976 #define dclist_reverse_foreach(iter, lhead) \
977 dlist_reverse_foreach(iter, &((lhead)->dlist))
1047 return node->
next != NULL;
1061 static inline void *
1065 return (
char *) head->
head.
next - off;
1106 #define slist_container(type, membername, ptr) \
1107 (AssertVariableIsOfTypeMacro(ptr, slist_node *), \
1108 AssertVariableIsOfTypeMacro(((type *) NULL)->membername, slist_node), \
1109 ((type *) ((char *) (ptr) - offsetof(type, membername))))
1116 #define slist_head_element(type, membername, lhead) \
1117 (AssertVariableIsOfTypeMacro(((type *) NULL)->membername, slist_node), \
1118 (type *) slist_head_element_off(lhead, offsetof(type, membername)))
1132 #define slist_foreach(iter, lhead) \
1133 for (AssertVariableIsOfTypeMacro(iter, slist_iter), \
1134 AssertVariableIsOfTypeMacro(lhead, slist_head *), \
1135 (iter).cur = (lhead)->head.next; \
1136 (iter).cur != NULL; \
1137 (iter).cur = (iter).cur->next)
1148 #define slist_foreach_modify(iter, lhead) \
1149 for (AssertVariableIsOfTypeMacro(iter, slist_mutable_iter), \
1150 AssertVariableIsOfTypeMacro(lhead, slist_head *), \
1151 (iter).prev = &(lhead)->head, \
1152 (iter).cur = (iter).prev->next, \
1153 (iter).next = (iter).cur ? (iter).cur->next : NULL; \
1154 (iter).cur != NULL; \
1155 (iter).prev = (iter).cur, \
1156 (iter).cur = (iter).next, \
1157 (iter).next = (iter).next ? (iter).next->next : NULL)
#define Assert(condition)
static dlist_node * dlist_prev_node(dlist_head *head, dlist_node *node)
struct slist_iter slist_iter
static void slist_delete_current(slist_mutable_iter *iter)
struct dlist_iter dlist_iter
static void dlist_delete_from_thoroughly(dlist_head *head, dlist_node *node)
static void dlist_insert_after(dlist_node *after, dlist_node *node)
static void * slist_head_element_off(slist_head *head, size_t off)
static void * dclist_tail_element_off(dclist_head *head, size_t off)
static void dlist_init(dlist_head *head)
static void dlist_delete_from(dlist_head *head, dlist_node *node)
static bool dlist_has_next(const dlist_head *head, const dlist_node *node)
static void * dlist_tail_element_off(dlist_head *head, size_t off)
static bool dlist_has_prev(const dlist_head *head, const dlist_node *node)
void slist_delete(slist_head *head, const slist_node *node)
static void dclist_push_tail(dclist_head *head, dlist_node *node)
static void * dclist_head_element_off(dclist_head *head, size_t off)
static void dlist_insert_before(dlist_node *before, dlist_node *node)
static dlist_node * dclist_tail_node(dclist_head *head)
#define dlist_check(head)
static void dlist_delete_thoroughly(dlist_node *node)
static bool dclist_has_next(const dclist_head *head, const dlist_node *node)
static void dlist_delete(dlist_node *node)
static uint32 dclist_count(const dclist_head *head)
static bool dclist_is_empty(const dclist_head *head)
static void slist_init(slist_head *head)
static bool dlist_node_is_detached(const dlist_node *node)
static dlist_node * dlist_next_node(dlist_head *head, dlist_node *node)
static void dclist_move_head(dclist_head *head, dlist_node *node)
struct dlist_head dlist_head
static void * dlist_head_element_off(dlist_head *head, size_t off)
static dlist_node * dlist_pop_head_node(dlist_head *head)
static bool slist_is_empty(const slist_head *head)
static void dlist_push_head(dlist_head *head, dlist_node *node)
static bool dlist_is_empty(const dlist_head *head)
static void slist_insert_after(slist_node *after, slist_node *node)
static void slist_push_head(slist_head *head, slist_node *node)
static dlist_node * dclist_next_node(dclist_head *head, dlist_node *node)
struct slist_head slist_head
#define slist_check(head)
static void dlist_push_tail(dlist_head *head, dlist_node *node)
static void dclist_delete_from(dclist_head *head, dlist_node *node)
static slist_node * slist_next_node(slist_head *head, slist_node *node)
struct dclist_head dclist_head
static void dclist_delete_from_thoroughly(dclist_head *head, dlist_node *node)
struct dlist_mutable_iter dlist_mutable_iter
static dlist_node * dclist_head_node(dclist_head *head)
static void dclist_push_head(dclist_head *head, dlist_node *node)
static void dclist_move_tail(dclist_head *head, dlist_node *node)
static void dclist_insert_before(dclist_head *head, dlist_node *before, dlist_node *node)
static void dclist_init(dclist_head *head)
static void dlist_move_head(dlist_head *head, dlist_node *node)
static bool slist_has_next(const slist_head *head, const slist_node *node)
static bool dclist_has_prev(const dclist_head *head, const dlist_node *node)
static void dlist_node_init(dlist_node *node)
struct slist_mutable_iter slist_mutable_iter
static dlist_node * dlist_head_node(dlist_head *head)
static dlist_node * dclist_prev_node(dclist_head *head, dlist_node *node)
static void dlist_move_tail(dlist_head *head, dlist_node *node)
static slist_node * slist_head_node(slist_head *head)
#define dlist_member_check(head, node)
static void dclist_insert_after(dclist_head *head, dlist_node *after, dlist_node *node)
static slist_node * slist_pop_head_node(slist_head *head)
static dlist_node * dclist_pop_head_node(dclist_head *head)
static dlist_node * dlist_tail_node(dlist_head *head)
static int before(chr x, chr y)