//通过一个字段member的地址 ptr,得到包含它的容器的地址
#define hlist_entry(ptr, type, member)
container_of(ptr,type,member)
//用 pos作为游标来遍历这个链表, prefetch是数据预取
#define hlist_for_each(pos, head)
\
for (pos
= (head)->first; pos && ({ prefetch(pos->next); 1; }); \
pos = pos->next)
#define hlist_for_each_safe(pos,
n, head) \
for (pos
= (head)->first; pos && ({ n = pos->next; 1; }); \
pos = n)
//通用的哈希链表遍历,其中 pos指向当前节点, tpos指向的包含hlist_node的当前结构体的指针
#define hlist_for_each_entry(tpos,
pos, head, member) \
for (pos
= (head)->first; \
pos && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof (*tpos),
member); 1;}); \
pos = pos->next)
/**
* hlist_for_each_entry_continue - iterate over a hlist continuing
after existing point
* @ tpos: the type * to use as a loop counter.
* @ pos: the &struct hlist_node
to use as a loop counter.
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_continue(tpos,
pos, member) \
for (pos
= (pos)->next; \
pos && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof (*tpos),
member); 1;}); \
pos = pos->next)
/**
* hlist_for_each_entry_from - iterate over a hlist continuing from
existing point
* @ tpos: the type * to use as a loop counter.
* @ pos: the &struct hlist_node
to use as a loop counter.
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_from(tpos,
pos, member) \
for (;
pos && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof (*tpos),
member); 1;}); \
pos = pos->next)
/**
* hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
* @ tpos: the type * to use as a loop counter.
* @ pos: the &struct hlist_node
to use as a loop counter.
* @n: another &struct hlist_node to use as temporary storage
* @head: the head for your list.
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_safe(tpos,
pos, n, head, member) \
for (pos
= (head)->first; \
pos && ({ n = pos->next; 1; }) && \
({ tpos = hlist_entry(pos, typeof (*tpos),
member); 1;}); \
pos = n)