Lines Matching defs:list
31 * list handling. No list looping yet.
60 * Prepend an item to a list
62 * @param item The element to add to the list
63 * @param list The list to prepend to
65 static inline void list_add(struct list_head *item, struct list_head *list)
67 item->prev = list;
68 item->next = list->next;
69 list->next->prev = item;
70 list->next = item;
74 * Append an item to a list
76 * @param item The element to add to the list
77 * @param list The list to append to
79 static inline void list_addtail(struct list_head *item, struct list_head *list)
81 item->next = list;
82 item->prev = list->prev;
83 list->prev->next = item;
84 list->prev = item;
87 static inline bool list_is_empty(const struct list_head *list);
116 static inline bool list_is_empty(const struct list_head *list)
118 return list->next == list;
121 static inline bool list_is_linked(const struct list_head *list)
124 assert((list->prev != NULL) == (list->next != NULL));
126 return list->next != NULL;
130 * Returns whether the list has exactly one element.
132 static inline bool list_is_singular(const struct list_head *list)
134 return list_is_linked(list) && !list_is_empty(list) && list->next->next == list;
137 static inline unsigned list_length(const struct list_head *list)
141 for (node = list->next; node != list; node = node->next)
168 static inline void list_validate(const struct list_head *list)
171 assert(list_is_linked(list));
172 assert(list->next->prev == list && list->prev->next == list);
173 for (node = list->next; node != list; node = node->next)
178 * Move an item from one place in a list to another
180 * The item can be in this list, or in another.