kernel structure

linux/list.h
0018 /*
0019  * Simple doubly linked list implementation.
0020  *
0021  * Some of the internal functions ("__xxx") are useful when
0022  * manipulating whole lists rather than single entries, as
0023  * sometimes we already know the next/prev entries and we can
0024  * generate better code by using them directly rather than
0025  * using the generic single-entry routines.
0026  */

0028 struct list_head { 0029 struct list_head *next, *prev; 0030 }; 0031 0032 #define LIST_HEAD_INIT(name) { &(name), &(name) } 0033 0034 #define LIST_HEAD(name) \ 0035 struct list_head name = LIST_HEAD_INIT(name) 0036 0037 #define INIT_LIST_HEAD(ptr) do { \ 0038 (ptr)->next = (ptr); (ptr)->prev = (ptr); \ 0039 } while (0)


0432 /* 
0433  * Double linked lists with a single pointer list head. 
0434  * Mostly useful for hash tables where the two pointer list head is 
0435  * too wasteful.
0436  * You lose the ability to access the tail in O(1).
0437  */ 
0438 
0439 struct hlist_head { 
0440         struct hlist_node *first; 
0441 }; 
0442 
0443 struct hlist_node { 
0444         struct hlist_node *next, **pprev; 
0445 }; 
0446 
0447 #define HLIST_HEAD_INIT { .first = NULL } 
0448 #define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }
0449 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) 
0450 #define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL)

虽是基础的数据结构, 在内核使用很广。 在smp中加入了rcu

转载于:https://www.cnblogs.com/kwingmei/p/3274603.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值