69,373
社区成员
发帖
与我相关
我的任务
分享
1. /**
2. * container_of - 通过结构体的一个成员获取容器结构体的指针
3. * @ptr: 指向成员的指针。
4. * @type: 成员所嵌入的容器结构体类型。
5. * @member: 结构体中的成员名。
6. *
7. */
8. #define container_of(ptr, type, member) ({ \
9. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
10. (type *)( (char *)__mptr - offsetof(type,member) );})