您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页container_of宏

container_of宏

来源:伴沃教育

title: container_of宏
date: 2019/7/24 15:49:26
toc: true
---

container_of宏

解析

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


#define list_entry(link, type, member) \
    ((type *)((char *)(link)-(unsigned long)(&((type *)0)->member)))
const typeof( ((type *)0)->member ) *__mptr = (ptr);

参考链接

offsetof与container_of宏总结

list_entry的宏定义

内核链表

转载于:https://www.cnblogs.com/zongzi10010/p/11238681.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务