2 * Operating system kernel abstraction -- linked lists.
4 * Copyright (C) 2009-2010 Cambridge Silicon Radio Ltd.
6 * Refer to LICENSE.txt included with this source code for details on
14 * Initialize an empty list.
18 void os_list_init(struct os_list *list)
20 list->head.next = list->head.prev = &list->head;
26 * @return true iff the list contains no nodes.
30 int os_list_empty(struct os_list *list)
32 return list->head.next == &list->head;
35 static void os_list_add(struct os_list_node *prev, struct os_list_node *new,
36 struct os_list_node *next)
45 * Add a node to the tail of the list.
47 * @param list the list.
48 * @param node the list node to add.
52 void os_list_add_tail(struct os_list *list, struct os_list_node *node)
54 os_list_add(list->head.prev, node, &list->head);
58 * Remove a node from a list.
60 * @param node the node to remove.
64 void os_list_del(struct os_list_node *node)
66 node->prev->next = node->next;
67 node->next->prev = node->prev;
69 node->prev = node->next = NULL;
73 * The node at the head of the list.
75 * @param list the list.
77 * @return the node at the head of the list; or os_list_end() if the
82 struct os_list_node *os_list_head(struct os_list *list)
84 return list->head.next;
88 * The node marking the end of a list.
90 * @param list the list.
92 * @return the node that marks the end of the list.
96 struct os_list_node *os_list_end(struct os_list *list)