首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

链表有关问题

2012-05-05 
链表问题hlist_for_each_entry(tpos, pos, head, member)\for (pos (head)-first\pos && ({ prefetch(

链表问题
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)
prefetch(pos->next);1; 加;1;是干什么?哪位高手知道?

[解决办法]
pos && ({ prefetch(pos->next); 1;}) && \
可能是想让两个&&之间的值为1吧。
[解决办法]
int main()
{
printf("%d\n", ({0; 1;}));
printf("%d\n", ({1; 0;}));
}

[解决办法]
for (pos = (head)->first; xxxx ; pos = pos->next)
中间判断循环结束条件那一大串,分开来看就是:
如果pos为NULL就结束循环,否则执行prefetch和hlist_entry
加上两个;1; 是为了忽略掉prefetch和hlist_entry的返回值,使pos成为判断循环结束的唯一条件。

a && b; 如果表达式a的结果是0,就不会执行表达式b
所以,当pos为NULL, prefetch和hlist_entry不会执行。

热点排行