libFirm
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Doubly linked lists. More...

Macros

#define LIST_HEAD_INIT(name)   { &(name), &(name) }
 Static initializer for a list header. More...
 
#define LIST_HEAD(name)   struct list_head name = LIST_HEAD_INIT(name)
 Defines a (static) list reference. More...
 
#define INIT_LIST_HEAD(ptr)
 Initializes a list header. More...
 
#define list_entry(ptr, type, member)   _list_container_of(ptr, type, member)
 list_entry - get the struct for this entry More...
 
#define list_for_each(pos, head)   for (pos = (head)->next; pos != (head); pos = pos->next)
 list_for_each - iterate over a list More...
 
#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 More...
 
#define list_for_each_safe(pos, n, head)
 list_for_each_safe - iterate over a list safe against removal of list entry More...
 
#define list_for_each_entry(type, pos, head, member)
 list_for_each_entry - iterate over list of given type More...
 
#define list_for_each_entry_reverse(type, pos, head, member)
 list_for_each_entry_reverse - iterate backwards over list of given type. More...
 
#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 More...
 

Typedefs

typedef struct list_head list_head
 List Header. More...
 

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. More...
 
static void list_add (struct list_head *new_node, struct list_head *head)
 Adds a new entry. More...
 
static void list_add_tail (struct list_head *new_node, struct list_head *head)
 Adds a new entry. More...
 
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. More...
 
static void list_del (struct list_head *entry)
 Deletes entry from list. More...
 
static void list_del_init (struct list_head *entry)
 Deletes entry from list and reinitialize it. More...
 
static void list_move (struct list_head *list, struct list_head *head)
 Deletes from one list and add as another's head. More...
 
static void list_move_tail (struct list_head *list, struct list_head *head)
 Deletes from one list and add as another's tail. More...
 
static int list_empty (const struct list_head *head)
 Tests whether a list is empty. More...
 
static void __list_splice (struct list_head *list, struct list_head *head)
 Join two nonempty lists. More...
 
static void list_splice (struct list_head *list, struct list_head *head)
 list_splice - join two lists More...
 
static void list_splice_init (struct list_head *list, struct list_head *head)
 list_splice_init - join two lists and reinitialize the emptied list. More...
 

Detailed Description

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.

Macro Definition Documentation

#define INIT_LIST_HEAD (   ptr)
Value:
do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)

Initializes a list header.

Definition at line 39 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)

list_entry - get the struct for this entry

Parameters
ptrthe &struct list_head pointer.
typethe type of the struct this is embedded in.
memberthe name of the list_struct within the struct.

Definition at line 219 of file list.h.

#define list_for_each (   pos,
  head 
)    for (pos = (head)->next; pos != (head); pos = pos->next)

list_for_each - iterate over a list

Parameters
posthe &struct list_head to use as a loop counter.
headthe head for your list.

Definition at line 227 of file list.h.

#define list_for_each_entry (   type,
  pos,
  head,
  member 
)
Value:
for (type *pos = list_entry((head)->next, type, member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, type, member))
#define list_entry(ptr, type, member)
list_entry - get the struct for this entry
Definition: list.h:219

list_for_each_entry - iterate over list of given type

Parameters
typethe type of the struct where the listhead is embedded in
posthe type * to use as a loop counter.
headthe head for your list.
memberthe name of the list_struct within the struct.

Definition at line 255 of file list.h.

#define list_for_each_entry_reverse (   type,
  pos,
  head,
  member 
)
Value:
for (type *pos = list_entry((head)->prev, type, member); \
&pos->member != (head); \
pos = list_entry(pos->member.prev, type, member))
#define list_entry(ptr, type, member)
list_entry - get the struct for this entry
Definition: list.h:219

list_for_each_entry_reverse - iterate backwards over list of given type.

Parameters
typethe type of the struct where the listhead is embedded in
posthe type * to use as a loop counter.
headthe head for your list.
memberthe name of the list_struct within the struct.

Definition at line 267 of file list.h.

#define list_for_each_entry_safe (   type,
  pos,
  n,
  head,
  member 
)
Value:
for (type *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))
#define list_entry(ptr, type, member)
list_entry - get the struct for this entry
Definition: list.h:219

list_for_each_entry_safe - iterate over list of given type safe against removal of list entry

Parameters
typethe type of the struct where the listhead is embedded in
posthe type * to use as a loop counter.
nanother type * to use as temporary storage
headthe head for your list.
memberthe name of the list_struct within the struct.

Definition at line 281 of file list.h.

#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

Parameters
posthe &struct list_head to use as a loop counter.
headthe head for your list.

Definition at line 235 of file list.h.

#define list_for_each_safe (   pos,
  n,
  head 
)
Value:
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

Parameters
posthe &struct list_head to use as a loop counter.
nanother &struct list_head to use as temporary storage
headthe head for your list.

Definition at line 244 of file list.h.

#define LIST_HEAD (   name)    struct list_head name = LIST_HEAD_INIT(name)

Defines a (static) list reference.

Definition at line 35 of file list.h.

#define LIST_HEAD_INIT (   name)    { &(name), &(name) }

Static initializer for a list header.

Definition at line 32 of file list.h.

Typedef Documentation

typedef struct list_head list_head

List Header.

Put this into all list elements and at the place where you want to keep references to the list.

Definition at line 29 of file list.h.

Function Documentation

static void __list_add ( struct list_head new_node,
struct list_head prev,
struct list_head next 
)
inlinestatic

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 58 of file list.h.

Referenced by list_add(), and list_add_tail().

static void __list_del ( struct list_head prev,
struct list_head next 
)
inlinestatic

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 101 of file list.h.

Referenced by list_del(), list_del_init(), list_move(), and list_move_tail().

static void __list_splice ( struct list_head list,
struct list_head head 
)
inlinestatic

Join two nonempty lists.

Note
Use list_splice() if list is possibly empty.
Parameters
listthe new list to add.
headthe place to add it in the first list.

Definition at line 172 of file list.h.

Referenced by list_splice(), and list_splice_init().

static void list_add ( struct list_head new_node,
struct list_head head 
)
inlinestatic

Adds a new entry.

Parameters
new_nodenew entry to be added
headlist head to add it after

Insert a new entry after the specified head. This is good for implementing stacks.

Definition at line 76 of file list.h.

References __list_add().

Referenced by list_move().

static void list_add_tail ( struct list_head new_node,
struct list_head head 
)
inlinestatic

Adds a new entry.

Parameters
new_nodenew entry to be added
headlist head to add it before

Insert a new entry before the specified head. This is useful for implementing queues.

Definition at line 89 of file list.h.

References __list_add().

Referenced by list_move_tail().

static void list_del ( struct list_head entry)
inlinestatic

Deletes entry from list.

Parameters
entrythe element to delete from the list.
Note
list_empty on entry does not return true after this, the entry is in an undefined state.

Definition at line 115 of file list.h.

References __list_del().

static void list_del_init ( struct list_head entry)
inlinestatic

Deletes entry from list and reinitialize it.

Parameters
entrythe element to delete from the list.

Definition at line 127 of file list.h.

References __list_del(), and INIT_LIST_HEAD.

static int list_empty ( const struct list_head head)
inlinestatic

Tests whether a list is empty.

Parameters
headthe list to test.

Definition at line 160 of file list.h.

Referenced by list_splice(), and list_splice_init().

static void list_move ( struct list_head list,
struct list_head head 
)
inlinestatic

Deletes from one list and add as another's head.

Parameters
listthe entry to move
headthe head that will precede our entry

Definition at line 138 of file list.h.

References __list_del(), and list_add().

static void list_move_tail ( struct list_head list,
struct list_head head 
)
inlinestatic

Deletes from one list and add as another's tail.

Parameters
listthe entry to move
headthe head that will follow our entry

Definition at line 149 of file list.h.

References __list_del(), and list_add_tail().

static void list_splice ( struct list_head list,
struct list_head head 
)
inlinestatic

list_splice - join two lists

Parameters
listthe new list to add.
headthe place to add it in the first list.

Definition at line 191 of file list.h.

References __list_splice(), and list_empty().

static void list_splice_init ( struct list_head list,
struct list_head head 
)
inlinestatic

list_splice_init - join two lists and reinitialize the emptied list.

Parameters
listthe new list to add.
headthe place to add it in the first list.

The list at list is reinitialized

Definition at line 204 of file list.h.

References __list_splice(), INIT_LIST_HEAD, and list_empty().