mcabber/list.h
author tailor@frmp8452
Thu, 30 Jun 2005 21:39:31 +0000
changeset 0 b3b2332715fb
permissions -rw-r--r--
Tailorization of /trunk Import of the upstream sources from Repository: file:///tmp/svn-mcabber Module: /trunk Revision: 15
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     1
#ifndef _LINUX_LIST_H
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     2
#define _LINUX_LIST_H
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     3
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     4
/*
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     5
 * Simple doubly linked list implementation.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     6
 *
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     7
 * Some of the internal functions ("__xxx") are useful when
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     8
 * manipulating whole lists rather than single entries, as
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
     9
 * sometimes we already know the next/prev entries and we can
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    10
 * generate better code by using them directly rather than
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    11
 * using the generic single-entry routines.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    12
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    13
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    14
struct list_head {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    15
  struct list_head *next, *prev;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    16
};
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    17
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    18
#define LIST_HEAD_INIT(name) { &(name), &(name) }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    19
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    20
#define LIST_HEAD(name) \
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    21
	struct list_head name = LIST_HEAD_INIT(name)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    22
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    23
#define INIT_LIST_HEAD(ptr) do { \
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    24
	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    25
} while (0)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    26
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    27
/*
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    28
 * Insert a new entry between two known consecutive entries. 
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    29
 *
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    30
 * This is only for internal list manipulation where we know
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    31
 * the prev/next entries already!
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    32
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    33
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    34
__list_add(struct list_head *new,
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    35
	   struct list_head *prev, struct list_head *next)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    36
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    37
  next->prev = new;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    38
  new->next = next;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    39
  new->prev = prev;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    40
  prev->next = new;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    41
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    42
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    43
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    44
 * list_add - add a new entry
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    45
 * @new: new entry to be added
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    46
 * @head: list head to add it after
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    47
 *
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    48
 * Insert a new entry after the specified head.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    49
 * This is good for implementing stacks.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    50
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    51
static inline void list_add(struct list_head *new, struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    52
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    53
  __list_add(new, head, head->next);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    54
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    55
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    56
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    57
 * list_add_tail - add a new entry
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    58
 * @new: new entry to be added
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    59
 * @head: list head to add it before
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    60
 *
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    61
 * Insert a new entry before the specified head.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    62
 * This is useful for implementing queues.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    63
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    64
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    65
list_add_tail(struct list_head *new, struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    66
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    67
  __list_add(new, head->prev, head);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    68
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    69
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    70
/*
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    71
 * Delete a list entry by making the prev/next entries
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    72
 * point to each other.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    73
 *
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    74
 * This is only for internal list manipulation where we know
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    75
 * the prev/next entries already!
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    76
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    77
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    78
__list_del(struct list_head *prev, struct list_head *next)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    79
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    80
  next->prev = prev;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    81
  prev->next = next;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    82
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    83
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    84
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    85
 * list_del - deletes entry from list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    86
 * @entry: the element to delete from the list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    87
 * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    88
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    89
static inline void list_del(struct list_head *entry)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    90
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    91
  __list_del(entry->prev, entry->next);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    92
  entry->next = (void *) 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    93
  entry->prev = (void *) 0;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    94
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    95
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    96
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    97
 * list_del_init - deletes entry from list and reinitialize it.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    98
 * @entry: the element to delete from the list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
    99
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   100
static inline void list_del_init(struct list_head *entry)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   101
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   102
  __list_del(entry->prev, entry->next);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   103
  INIT_LIST_HEAD(entry);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   104
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   105
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   106
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   107
 * list_move - delete from one list and add as another's head
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   108
 * @list: the entry to move
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   109
 * @head: the head that will precede our entry
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   110
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   111
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   112
list_move(struct list_head *list, struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   113
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   114
  __list_del(list->prev, list->next);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   115
  list_add(list, head);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   116
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   117
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   118
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   119
 * list_move_tail - delete from one list and add as another's tail
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   120
 * @list: the entry to move
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   121
 * @head: the head that will follow our entry
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   122
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   123
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   124
list_move_tail(struct list_head *list, struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   125
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   126
  __list_del(list->prev, list->next);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   127
  list_add_tail(list, head);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   128
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   129
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   130
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   131
 * list_empty - tests whether a list is empty
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   132
 * @head: the list to test.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   133
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   134
static inline int list_empty(struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   135
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   136
  return head->next == head;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   137
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   138
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   139
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   140
__list_splice(struct list_head *list, struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   141
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   142
  struct list_head *first = list->next;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   143
  struct list_head *last = list->prev;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   144
  struct list_head *at = head->next;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   145
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   146
  first->prev = head;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   147
  head->next = first;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   148
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   149
  last->next = at;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   150
  at->prev = last;
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   151
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   152
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   153
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   154
 * list_splice - join two lists
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   155
 * @list: the new list to add.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   156
 * @head: the place to add it in the first list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   157
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   158
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   159
list_splice(struct list_head *list, struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   160
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   161
  if (!list_empty(list))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   162
    __list_splice(list, head);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   163
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   164
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   165
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   166
 * list_splice_init - join two lists and reinitialise the emptied list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   167
 * @list: the new list to add.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   168
 * @head: the place to add it in the first list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   169
 *
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   170
 * The list at @list is reinitialised
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   171
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   172
static inline void
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   173
list_splice_init(struct list_head *list, struct list_head *head)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   174
{
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   175
  if (!list_empty(list)) {
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   176
    __list_splice(list, head);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   177
    INIT_LIST_HEAD(list);
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   178
  }
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   179
}
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   180
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   181
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   182
 * list_entry - get the struct for this entry
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   183
 * @ptr:	the &struct list_head pointer.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   184
 * @type:	the type of the struct this is embedded in.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   185
 * @member:	the name of the list_struct within the struct.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   186
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   187
#define list_entry(ptr, type, member) \
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   188
	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   189
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   190
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   191
 * list_for_each_safe	-	iterate over a list safe against removal of list entry
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   192
 * @pos:	the &struct list_head to use as a loop counter.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   193
 * @n:		another &struct list_head to use as temporary storage
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   194
 * @head:	the head for your list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   195
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   196
#define list_for_each_safe(pos, n, head) \
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   197
	for (pos = (head)->next, n = pos->next; pos != (head); \
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   198
		pos = n, n = pos->next)
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   199
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   200
/**
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   201
 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   202
 * @pos:	the type * to use as a loop counter.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   203
 * @n:		another type * to use as temporary storage
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   204
 * @head:	the head for your list.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   205
 * @member:	the name of the list_struct within the struct.
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   206
 */
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   207
#define list_for_each_entry_safe(pos, n, head, member)			\
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   208
	for (pos = list_entry((head)->next, typeof(*pos), member),	\
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   209
		n = list_entry(pos->member.next, typeof(*pos), member);	\
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   210
	     &pos->member != (head); 					\
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   211
	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   212
b3b2332715fb Tailorization of /trunk
tailor@frmp8452
parents:
diff changeset
   213
#endif