打印本文 打印本文 关闭窗口 关闭窗口
Linux 中的链表
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1772  更新时间:2009/4/22 20:45:24  文章录入:mintao  责任编辑:mintao
ead: the head for your list.
 * @member: the name of the list_struct within the struct.
 */
#define list_for_each_entry_reverse(pos, head, member)   \
 for (pos = list_entry((head)->prev, typeof(*pos), member), \
       prefetch(pos->member.prev);   \
      &pos->member != (head);      \
      pos = list_entry(pos->member.prev, typeof(*pos), member), \
       prefetch(pos->member.prev))

/**
 * list_prepare_entry - prepare a pos entry for use as a start point in
 *   list_for_each_entry_continue
 * @pos: the type * to use as a start point
 * @head: the head of the list
 * @member: the name of the list_struct within the struct.
 */
#define list_prepare_entry(pos, head, member) \
 ((pos) ? : list_entry(head, typeof(*pos), member))

/**
 * list_for_each_entry_continue - iterate over list of given type
 *   continuing after existing point
 * @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_continue(pos, head, member)   \
 for (pos = list_entry(pos->member.next, typeof(*pos), member), \
       prefetch(pos->member.next);   \
      &pos->member != (head);     \
      pos = list_entry(pos->member.next, typeof(*pos), member), \
       prefetch(pos->member.next))

/**
 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
 * @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_entry_safe(pos, n, head, member)   \
 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))

#endif

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口