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

posted on 2013-08-22 12:26  kwingmei  阅读(206)  评论(0编辑  收藏  举报

导航