Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros
list.h File Reference
#include <linux/types.h>
#include <linux/stddef.h>
#include <linux/poison.h>
#include <linux/const.h>

Go to the source code of this file.

Macros

#define LIST_HEAD_INIT(name)   { &(name), &(name) }
 
#define LIST_HEAD(name)   struct list_head name = LIST_HEAD_INIT(name)
 
#define list_entry(ptr, type, member)   container_of(ptr, type, member)
 
#define list_first_entry(ptr, type, member)   list_entry((ptr)->next, type, member)
 
#define list_for_each(pos, head)   for (pos = (head)->next; pos != (head); pos = pos->next)
 
#define __list_for_each(pos, head)   for (pos = (head)->next; pos != (head); pos = pos->next)
 
#define list_for_each_prev(pos, head)   for (pos = (head)->prev; pos != (head); pos = pos->prev)
 
#define list_for_each_safe(pos, n, head)
 
#define list_for_each_prev_safe(pos, n, head)
 
#define list_for_each_entry(pos, head, member)
 
#define list_for_each_entry_reverse(pos, head, member)
 
#define list_prepare_entry(pos, head, member)   ((pos) ? : list_entry(head, typeof(*pos), member))
 
#define list_for_each_entry_continue(pos, head, member)
 
#define list_for_each_entry_continue_reverse(pos, head, member)
 
#define list_for_each_entry_from(pos, head, member)
 
#define list_for_each_entry_safe(pos, n, head, member)
 
#define list_for_each_entry_safe_continue(pos, n, head, member)
 
#define list_for_each_entry_safe_from(pos, n, head, member)
 
#define list_for_each_entry_safe_reverse(pos, n, head, member)
 
#define list_safe_reset_next(pos, n, member)   n = list_entry(pos->member.next, typeof(*pos), member)
 
#define HLIST_HEAD_INIT   { .first = NULL }
 
#define HLIST_HEAD(name)   struct hlist_head name = { .first = NULL }
 
#define INIT_HLIST_HEAD(ptr)   ((ptr)->first = NULL)
 
#define hlist_entry(ptr, type, member)   container_of(ptr,type,member)
 
#define hlist_for_each(pos, head)   for (pos = (head)->first; pos ; pos = pos->next)
 
#define hlist_for_each_safe(pos, n, head)
 
#define hlist_for_each_entry(tpos, pos, head, member)
 
#define hlist_for_each_entry_continue(tpos, pos, member)
 
#define hlist_for_each_entry_from(tpos, pos, member)
 
#define hlist_for_each_entry_safe(tpos, pos, n, head, member)
 

Macro Definition Documentation

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

__list_for_each - iterate over a list : the &struct list_head to use as a loop cursor. : the head for your list.

This variant doesn't differ from list_for_each() any more. We don't do prefetching in either case.

Definition at line 380 of file list.h.

#define hlist_entry (   ptr,
  type,
  member 
)    container_of(ptr,type,member)

Definition at line 660 of file list.h.

#define hlist_for_each (   pos,
  head 
)    for (pos = (head)->first; pos ; pos = pos->next)

Definition at line 662 of file list.h.

#define hlist_for_each_entry (   tpos,
  pos,
  head,
  member 
)
Value:
for (pos = (head)->first; \
pos && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)

hlist_for_each_entry - iterate over list of given type : the type * to use as a loop cursor. : the &struct hlist_node to use as a loop cursor. : the head for your list. : the name of the hlist_node within the struct.

Definition at line 676 of file list.h.

#define hlist_for_each_entry_continue (   tpos,
  pos,
  member 
)
Value:
for (pos = (pos)->next; \
pos && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)

hlist_for_each_entry_continue - iterate over a hlist continuing after current point : the type * to use as a loop cursor. : the &struct hlist_node to use as a loop cursor. : the name of the hlist_node within the struct.

Definition at line 688 of file list.h.

#define hlist_for_each_entry_from (   tpos,
  pos,
  member 
)
Value:
for (; pos && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)

hlist_for_each_entry_from - iterate over a hlist continuing from current point : the type * to use as a loop cursor. : the &struct hlist_node to use as a loop cursor. : the name of the hlist_node within the struct.

Definition at line 700 of file list.h.

#define hlist_for_each_entry_safe (   tpos,
  pos,
  n,
  head,
  member 
)
Value:
for (pos = (head)->first; \
pos && ({ n = pos->next; 1; }) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = n)

hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry : the type * to use as a loop cursor. : the &struct hlist_node to use as a loop cursor.
: another &struct hlist_node to use as temporary storage : the head for your list. : the name of the hlist_node within the struct.

Definition at line 713 of file list.h.

#define hlist_for_each_safe (   pos,
  n,
  head 
)
Value:
for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
pos = n)

Definition at line 665 of file list.h.

#define HLIST_HEAD (   name)    struct hlist_head name = { .first = NULL }

Definition at line 568 of file list.h.

#define HLIST_HEAD_INIT   { .first = NULL }

Definition at line 567 of file list.h.

#define INIT_HLIST_HEAD (   ptr)    ((ptr)->first = NULL)

Definition at line 569 of file list.h.

#define list_entry (   ptr,
  type,
  member 
)    container_of(ptr, type, member)

list_entry - get the struct for this entry : the &struct list_head pointer. : the type of the struct this is embedded in. : the name of the list_struct within the struct.

Definition at line 350 of file list.h.

#define list_first_entry (   ptr,
  type,
  member 
)    list_entry((ptr)->next, type, member)

list_first_entry - get the first element from a list : the list head to take the element from. : the type of the struct this is embedded in. : the name of the list_struct within the struct.

Note, that list is expected to be not empty.

Definition at line 361 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 : the &struct list_head to use as a loop cursor. : the head for your list.

Definition at line 369 of file list.h.

#define list_for_each_entry (   pos,
  head,
  member 
)
Value:
for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))

list_for_each_entry - iterate over list of given type : the type * to use as a loop cursor. : the head for your list. : the name of the list_struct within the struct.

Definition at line 418 of file list.h.

#define list_for_each_entry_continue (   pos,
  head,
  member 
)
Value:
for (pos = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))

list_for_each_entry_continue - continue iteration over list of given type : the type * to use as a loop cursor. : the head for your list. : the name of the list_struct within the struct.

Continue to iterate over list of given type, continuing after the current position.

Definition at line 454 of file list.h.

#define list_for_each_entry_continue_reverse (   pos,
  head,
  member 
)
Value:
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))

list_for_each_entry_continue_reverse - iterate backwards from the given point : the type * to use as a loop cursor. : the head for your list. : the name of the list_struct within the struct.

Start to iterate over list of given type backwards, continuing after the current position.

Definition at line 468 of file list.h.

#define list_for_each_entry_from (   pos,
  head,
  member 
)
Value:
for (; &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))

list_for_each_entry_from - iterate over list of given type from the current point : the type * to use as a loop cursor. : the head for your list. : the name of the list_struct within the struct.

Iterate over list of given type, continuing from current position.

Definition at line 481 of file list.h.

#define list_for_each_entry_reverse (   pos,
  head,
  member 
)
Value:
for (pos = list_entry((head)->prev, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))

list_for_each_entry_reverse - iterate backwards over list of given type. : the type * to use as a loop cursor. : the head for your list. : the name of the list_struct within the struct.

Definition at line 429 of file list.h.

#define list_for_each_entry_safe (   pos,
  n,
  head,
  member 
)
Value:
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))

list_for_each_entry_safe - iterate over list of given type safe against removal of list entry : the type * to use as a loop cursor.
: another type * to use as temporary storage : the head for your list. : the name of the list_struct within the struct.

Definition at line 492 of file list.h.

#define list_for_each_entry_safe_continue (   pos,
  n,
  head,
  member 
)
Value:
for (pos = list_entry(pos->member.next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))

list_for_each_entry_safe_continue - continue list iteration safe against removal : the type * to use as a loop cursor.
: another type * to use as temporary storage : the head for your list. : the name of the list_struct within the struct.

Iterate over list of given type, continuing after current point, safe against removal of list entry.

Definition at line 508 of file list.h.

#define list_for_each_entry_safe_from (   pos,
  n,
  head,
  member 
)
Value:
for (n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))

list_for_each_entry_safe_from - iterate over list from current point safe against removal : the type * to use as a loop cursor.
: another type * to use as temporary storage : the head for your list. : the name of the list_struct within the struct.

Iterate over list of given type from current point, safe against removal of list entry.

Definition at line 524 of file list.h.

#define list_for_each_entry_safe_reverse (   pos,
  n,
  head,
  member 
)
Value:
for (pos = list_entry((head)->prev, typeof(*pos), member), \
n = list_entry(pos->member.prev, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.prev, typeof(*n), member))

list_for_each_entry_safe_reverse - iterate backwards over list safe against removal : the type * to use as a loop cursor.
: another type * to use as temporary storage : the head for your list. : the name of the list_struct within the struct.

Iterate backwards over list of given type, safe against removal of list entry.

Definition at line 539 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 : the &struct list_head to use as a loop cursor. : the head for your list.

Definition at line 388 of file list.h.

#define list_for_each_prev_safe (   pos,
  n,
  head 
)
Value:
for (pos = (head)->prev, n = pos->prev; \
pos != (head); \
pos = n, n = pos->prev)

list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry : the &struct list_head to use as a loop cursor.
: another &struct list_head to use as temporary storage : the head for your list.

Definition at line 407 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 : the &struct list_head to use as a loop cursor.
: another &struct list_head to use as temporary storage : the head for your list.

Definition at line 397 of file list.h.

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

Definition at line 21 of file list.h.

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

Definition at line 19 of file list.h.

#define list_prepare_entry (   pos,
  head,
  member 
)    ((pos) ? : list_entry(head, typeof(*pos), member))

list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() : the type * to use as a start point : the head of the list : the name of the list_struct within the struct.

Prepares a pos entry for use as a start point in list_for_each_entry_continue().

Definition at line 442 of file list.h.

#define list_safe_reset_next (   pos,
  n,
  member 
)    n = list_entry(pos->member.next, typeof(*pos), member)

list_safe_reset_next - reset a stale list_for_each_entry_safe loop : the loop cursor used in the list_for_each_entry_safe loop
: temporary storage used in list_for_each_entry_safe : the name of the list_struct within the struct.

list_safe_reset_next is not safe to use in general if the list may be modified concurrently (eg. the lock is dropped in the loop body). An exception to this is if the cursor element (pos) is pinned in the list, and list_safe_reset_next is called after re-taking the lock and before completing the current iteration of the loop body.

Definition at line 557 of file list.h.