当前位置: 技术问答>linux和unix
内核的链表操作好强大啊!
来源: 互联网 发布时间:2016-09-26
本文导语: 内核代码果然不是一般人能写出来的,比如像链表,会写的人很多,但是能强内核那样,多功能多合一的代码恐怕能写出来的人就很少了。 static inline void __list_add(struct list_head *new, struct list_head *prev, ...
内核代码果然不是一般人能写出来的,比如像链表,会写的人很多,但是能强内核那样,多功能多合一的代码恐怕能写出来的人就很少了。
这短短的三个函数就已经把链表,队列,栈的操作集合在一起了,太强大了!在结合一个container_of宏简直就是perfect太完美了!
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
static inline void list_add_tail(struct list_head *new, struct list_head *head)
{
__list_add(new, head->prev, head);
}
这短短的三个函数就已经把链表,队列,栈的操作集合在一起了,太强大了!在结合一个container_of宏简直就是perfect太完美了!
|
呵呵,看内核代码简直就像是在欣赏一件艺术品。
|
新手膜拜~~~
|
kernel代码都是顶尖高手写的!
|
没有看内核代码之前,对自已的C那是信心十足啊,看了,那是相当的无地自容。
|
看不懂
|
牛人~~
|
恩,很简洁
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。