libFirm 1.20
|
Doubly linked lists. More...
Defines | |
#define | LIST_HEAD_INIT(name) { &(name), &(name) } |
Static initializer for a list header. | |
#define | LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name) |
Defines a (static) list reference. | |
#define | INIT_LIST_HEAD(ptr) |
Initializes a list header. | |
#define | list_entry(ptr, type, member) _list_container_of(ptr, type, member) |
list_entry - get the struct for this entry | |
#define | list_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next) |
list_for_each - iterate over a list | |
#define | __list_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next) |
__list_for_each - iterate over a list | |
#define | list_for_each_prev(pos, head) for (pos = (head)->prev; pos != (head); pos = pos->prev) |
list_for_each_prev - iterate over a list backwards | |
#define | list_for_each_safe(pos, n, head) |
list_for_each_safe - iterate over a list safe against removal of list entry | |
#define | list_for_each_entry(type, pos, head, member) |
list_for_each_entry - iterate over list of given type | |
#define | list_for_each_entry_reverse(type, pos, head, member) |
list_for_each_entry_reverse - iterate backwards over list of given type. | |
#define | list_for_each_entry_safe(type, pos, n, head, member) |
list_for_each_entry_safe - iterate over list of given type safe against removal of list entry | |
Typedefs | |
typedef struct list_head | list_head |
List Header. | |
Functions | |
static void | __list_add (struct list_head *new_node, struct list_head *prev, struct list_head *next) |
Inserts a new entry between two known consecutive entries. | |
static void | list_add (struct list_head *new_node, struct list_head *head) |
Adds a new entry. | |
static void | list_add_tail (struct list_head *new_node, struct list_head *head) |
Adds a new entry. | |
static void | __list_del (struct list_head *prev, struct list_head *next) |
Deletes a list entry by making the prev/next entries point to each other. | |
static void | list_del (struct list_head *entry) |
Deletes entry from list. | |
static void | list_del_init (struct list_head *entry) |
Deletes entry from list and reinitialize it. | |
static void | list_move (struct list_head *list, struct list_head *head) |
Deletes from one list and add as another's head. | |
static void | list_move_tail (struct list_head *list, struct list_head *head) |
Deletes from one list and add as another's tail. | |
static int | list_empty (const struct list_head *head) |
Tests whether a list is empty. | |
static void | __list_splice (struct list_head *list, struct list_head *head) |
Join two nonempty lists. | |
static void | list_splice (struct list_head *list, struct list_head *head) |
list_splice - join two lists | |
static void | list_splice_init (struct list_head *list, struct list_head *head) |
list_splice_init - join two lists and reinitialize the emptied list. |
Doubly linked lists.
Simple doubly linked list implementation.
Some of the internal functions ("__xxx") are useful when manipulating whole lists rather than single entries, as sometimes we already know the next/prev entries and we can generate better code by using them directly rather than using the generic single-entry routines.
#define __list_for_each | ( | pos, | |
head | |||
) | for (pos = (head)->next; pos != (head); pos = pos->next) |
__list_for_each - iterate over a list
pos | the &struct list_head to use as a loop counter. |
head | the head for your list. |
This variant differs from list_for_each() in that it's the simplest possible list iteration code, no ing is done. Use this for code that knows the list to be very short (empty or 1 entry) most of the time.
#define INIT_LIST_HEAD | ( | ptr | ) |
do { \ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0)
Initializes a list header.
Definition at line 37 of file list.h.
Referenced by list_del_init(), and list_splice_init().
#define list_entry | ( | ptr, | |
type, | |||
member | |||
) | _list_container_of(ptr, type, member) |
#define list_for_each | ( | pos, | |
head | |||
) | for (pos = (head)->next; pos != (head); pos = pos->next) |
#define list_for_each_entry | ( | type, | |
pos, | |||
head, | |||
member | |||
) |
for (pos = list_entry((head)->next, type, member); \ &pos->member != (head); \ pos = list_entry(pos->member.next, type, member))
list_for_each_entry - iterate over list of given type
type | the type of the struct where the listhead is embedded in |
pos | the type * to use as a loop counter. |
head | the head for your list. |
member | the name of the list_struct within the struct. |
#define list_for_each_entry_reverse | ( | type, | |
pos, | |||
head, | |||
member | |||
) |
for (pos = list_entry((head)->prev, type, member); \ &pos->member != (head); \ pos = list_entry(pos->member.prev, type, member))
list_for_each_entry_reverse - iterate backwards over list of given type.
type | the type of the struct where the listhead is embedded in |
pos | the type * to use as a loop counter. |
head | the head for your list. |
member | the name of the list_struct within the struct. |
#define list_for_each_entry_safe | ( | type, | |
pos, | |||
n, | |||
head, | |||
member | |||
) |
for (pos = list_entry((head)->next, type, member), \ n = list_entry(pos->member.next, type, member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, type, member))
list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
type | the type of the struct where the listhead is embedded in |
pos | the type * to use as a loop counter. |
n | another type * to use as temporary storage |
head | the head for your list. |
member | the name of the list_struct within the struct. |
#define list_for_each_prev | ( | pos, | |
head | |||
) | for (pos = (head)->prev; pos != (head); pos = pos->prev) |
#define list_for_each_safe | ( | pos, | |
n, | |||
head | |||
) |
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
list_for_each_safe - iterate over a list safe against removal of list entry
pos | the &struct list_head to use as a loop counter. |
n | another &struct list_head to use as temporary storage |
head | the head for your list. |
#define LIST_HEAD | ( | name | ) | struct list_head name = LIST_HEAD_INIT(name) |
#define LIST_HEAD_INIT | ( | name | ) | { &(name), &(name) } |
static void __list_add | ( | struct list_head * | new_node, |
struct list_head * | prev, | ||
struct list_head * | next | ||
) | [inline, static] |
Inserts a new entry between two known consecutive entries.
This is only for internal list manipulation where we know the prev/next entries already!
Definition at line 59 of file list.h.
Referenced by list_add(), and list_add_tail().
Deletes a list entry by making the prev/next entries point to each other.
This is only for internal list manipulation where we know the prev/next entries already!
Definition at line 102 of file list.h.
Referenced by list_del(), list_del_init(), list_move(), and list_move_tail().
Join two nonempty lists.
list
is possibly empty. list | the new list to add. |
head | the place to add it in the first list. |
Definition at line 173 of file list.h.
Referenced by list_splice(), and list_splice_init().
Adds a new entry.
new_node | new entry to be added |
head | list head to add it after |
Insert a new entry after the specified head. This is good for implementing stacks.
Definition at line 77 of file list.h.
References __list_add().
Referenced by list_move().
Adds a new entry.
new_node | new entry to be added |
head | list head to add it before |
Insert a new entry before the specified head. This is useful for implementing queues.
Definition at line 90 of file list.h.
References __list_add().
Referenced by list_move_tail().
static void list_del | ( | struct list_head * | entry | ) | [inline, static] |
Deletes entry from list.
entry | the element to delete from the list. |
Definition at line 116 of file list.h.
References __list_del().
static void list_del_init | ( | struct list_head * | entry | ) | [inline, static] |
Deletes entry from list and reinitialize it.
entry | the element to delete from the list. |
Definition at line 128 of file list.h.
References __list_del(), and INIT_LIST_HEAD.
static int list_empty | ( | const struct list_head * | head | ) | [inline, static] |
Tests whether a list is empty.
head | the list to test. |
Definition at line 161 of file list.h.
Referenced by list_splice(), and list_splice_init().
Deletes from one list and add as another's head.
list | the entry to move |
head | the head that will precede our entry |
Definition at line 139 of file list.h.
References __list_del(), and list_add().
Deletes from one list and add as another's tail.
list | the entry to move |
head | the head that will follow our entry |
Definition at line 150 of file list.h.
References __list_del(), and list_add_tail().
list_splice - join two lists
list | the new list to add. |
head | the place to add it in the first list. |
Definition at line 192 of file list.h.
References __list_splice(), and list_empty().
list_splice_init - join two lists and reinitialize the emptied list.
list | the new list to add. |
head | the place to add it in the first list. |
The list at list is reinitialized
Definition at line 205 of file list.h.
References __list_splice(), INIT_LIST_HEAD, and list_empty().