container_of 见解
来源:互联网 发布:网页在线视频剪辑软件 编辑:程序博客网 时间:2024/05/22 01:29
看内核的网络子系统又碰到container_of,以前碰过,又忘了。今天重温,发现真不一样
#define container_of(ptr, type, member) ({ \
const typeof(((type *)0)->member) * __mptr = (ptr);\(type *)((char *)__mptr - offsetof(type, member)); })
const typeof(((type *)0)->member) * __mptr = (ptr);
这个定义一个指针__mptr等于ptr,这个很关键,因为const typeof(((type *)0)->member) * 这个定义是0地址偏移量,赋值之后就是ptr,
这个再经过(type *)((char *)__mptr - offsetof(type, member));
我们就得到ptr所在的结构体的首地址。
0 0
- container_of 见解
- container_of
- container_of
- container_of
- container_of
- container_of()
- container_of()
- container_of
- container_of
- container_of()
- container_of
- container_of()
- container_of
- container_of
- container_of()
- container_of()
- container_of
- container_of
- 再次学习javascript中的参数传递
- 用代码手写布局
- spring
- 银汇通支付:沈阳将推广无线POS机上门收电费
- 为什么要用960px?——网页内容宽度分析
- container_of 见解
- java get 请求乱码
- ArcGIS Runtime SDK For Android 授权方法(去除水印)
- C#: 带有背景文本的TextBox
- 银汇通支付让收银台跟着用户走,交易成本节
- 关于 Java 中 finally 语句块的深度辨析
- linux常用命令
- 解决表单GET提交后台数据乱码问题
- Cracking the coding interview(中文版)