Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
llist.h File Reference
#include <linux/kernel.h>
#include <asm/cmpxchg.h>

Go to the source code of this file.

Data Structures

struct  llist_head
 
struct  llist_node
 

Macros

#define LLIST_HEAD_INIT(name)   { NULL }
 
#define LLIST_HEAD(name)   struct llist_head name = LLIST_HEAD_INIT(name)
 
#define llist_entry(ptr, type, member)   container_of(ptr, type, member)
 
#define llist_for_each(pos, node)   for ((pos) = (node); pos; (pos) = (pos)->next)
 
#define llist_for_each_entry(pos, node, member)
 

Functions

bool llist_add_batch (struct llist_node *new_first, struct llist_node *new_last, struct llist_head *head)
 
struct llist_nodellist_del_first (struct llist_head *head)
 

Macro Definition Documentation

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

llist_entry - get the struct of this entry : the &struct llist_node pointer. : the type of the struct this is embedded in. : the name of the llist_node within the struct.

Definition at line 87 of file llist.h.

#define llist_for_each (   pos,
  node 
)    for ((pos) = (node); pos; (pos) = (pos)->next)

llist_for_each - iterate over some deleted entries of a lock-less list : the &struct llist_node to use as a loop cursor : the first entry of deleted list entries

In general, some entries of the lock-less list can be traversed safely only after being deleted from list, so start with an entry instead of list head.

If being used on entries deleted from lock-less list directly, the traverse order is from the newest to the oldest added entry. If you want to traverse from the oldest to the newest, you must reverse the order by yourself before traversing.

Definition at line 104 of file llist.h.

#define llist_for_each_entry (   pos,
  node,
  member 
)
Value:
for ((pos) = llist_entry((node), typeof(*(pos)), member); \
&(pos)->member != NULL; \
(pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))

llist_for_each_entry - iterate over some deleted entries of lock-less list of given type : the type * to use as a loop cursor. : the fist entry of deleted list entries. : the name of the llist_node with the struct.

In general, some entries of the lock-less list can be traversed safely only after being removed from list, so start with an entry instead of list head.

If being used on entries deleted from lock-less list directly, the traverse order is from the newest to the oldest added entry. If you want to traverse from the oldest to the newest, you must reverse the order by yourself before traversing.

Definition at line 122 of file llist.h.

#define LLIST_HEAD (   name)    struct llist_head name = LLIST_HEAD_INIT(name)

Definition at line 70 of file llist.h.

#define LLIST_HEAD_INIT (   name)    { NULL }

Definition at line 69 of file llist.h.

Function Documentation

bool llist_add_batch ( struct llist_node new_first,
struct llist_node new_last,
struct llist_head head 
)

llist_add_batch - add several linked entries in batch : first entry in batch to be added : last entry in batch to be added : the head for your lock-less list

Return whether list is empty before adding.

Definition at line 39 of file llist.c.

struct llist_node* llist_del_first ( struct llist_head head)
read

llist_del_first - delete the first entry of lock-less list : the head for your lock-less list

If list is empty, return NULL, otherwise, return the first entry deleted, this is the newest added one.

Only one llist_del_first user can be used simultaneously with multiple llist_add users without lock. Because otherwise llist_del_first, llist_add, llist_add (or llist_del_all, llist_add, llist_add) sequence in another user may change ->first->next, but keep ->first. If multiple consumers are needed, please use llist_del_all or use lock between consumers.

Definition at line 71 of file llist.c.