contain_of 浅析
来源:互联网 发布:mysql入门教程 编辑:程序博客网 时间:2024/04/30 22:02
关于container_of见kernel.h中:
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ /
const typeof( ((type *)0)->member ) *__mptr = (ptr); /
(type *)( (char *)__mptr - offsetof(type,member) );})
container_of在Linux Kernel中的应用非常广泛,它用于获得某结构中某成员的入口地址.
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
TYPE是某struct的类型 0是一个假想TYPE类型struct,MEMBER是该struct中的一个成员. 由于该struct的基地址为0, MEMBER的地址就是该成员相对与struct头地址的偏移量.
原文摘自:http://blog.csdn.net/yinkaizhong/article/details/4093795
- contain_of 浅析
- 理解 linux contain_of() 宏
- Linux kernel contain_of 宏
- 理解 linux contain_of() 宏
- linux 理解contain_of
- contain_of 宏的理解
- offsetof和contain_of
- 关于contain_of的理解
- Linux contain_of() 宏
- Linux contain_of() 宏
- 理解Linux contain_of()宏
- usb-skeleton.c 之 06-- 中间的contain_of()
- usb-skeleton.c 之 06-- 中间的contain_of()
- 浅析
- 浅析
- Linux内核与驱动开发学习总结:initcall 和contain_of宏(十)
- 电子邮件浅析
- 浅析GLib
- C++编译时出现的一个问题,求教高人
- getResourceAsStream
- DWR 使用篇
- 如何从Android模拟器删除系统“无用”程序 获得root
- 使用Hive读取Hbase中的数据
- contain_of 浅析
- jrtplib学习之example1例程分析
- Android NotificationManager 和Notification的使用总结
- Learn Python The Hard Way学习(8) - 打印,还是打印
- 那个年代
- 解决PHP函数ip2long转换IP时数值太大而产生负数的办法
- Learn Python The Hard Way学习(9) - 打印,打印,打印
- 发邮件工具类(1)
- 【热门技术】Ad Hoc 点对点通信模式 -- 移动自组织网络