QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2151|回复: 2

关于LIST_ENTRY的实现

[复制链接]
发表于 2005-12-25 21:46:30 | 显示全部楼层 |阅读模式
今天看了看2.6内核的list.h文件,发现LIST_ENTRY的实现和以前不一样了,现在是
#define list_entry(ptr, type, member) \
        container_of(ptr, type, member)
而对container_of的定义只在aio.h找到 下面的
#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)

还是没有具体的实现,请问具体实现在哪里,谢谢!
发表于 2005-12-26 16:22:35 | 显示全部楼层
在kernel.h文件中:

#define container_of(ptr, type, member) ({                        \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);        \
        (type *)( (char *)__mptr - offsetof(type,member) );})
回复

使用道具 举报

 楼主| 发表于 2005-12-28 17:57:16 | 显示全部楼层
谢谢,能解释一下 const typeof( ((type *)0)->member )什么意思吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-4 18:02 , Processed in 0.073622 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表