- 追加された行はこの色です。
- 削除された行はこの色です。
*参照元 [#b82b100d]
#backlinks
*説明 [#i70a3452]
-パス: [[linux-4.4.1/include/linux/list.h]]
-FIXME: これは何?
--説明
リストの先頭を指す専用の struct list_head がある?
もしくは list_head は最後と最初が繋がっている循環リストなので、リストの最後の要素が分かっていても使えるかもしれない。
struct some {
int data_foo;
struct list_head list;
int data_bar;
};
struct some some_list[N];
...
/* リストの先頭の要素が持ってる struct list_head */
struct list_head *some_list_first = &some_list[0].list;
/* リストの先頭の要素を指すためだけの struct list_head */
struct list_head some_list_head;
some_list_head.next = some_list_first;
...
struct some *some_first = list_first_entry(&some_list_head, struct some, list);
**引数 [#g55960b8]
-
--
-struct list_head *ptr
--リストの先頭要素を next メンバが指している、struct list_head のポインタ
--[[linux-4.4.1/list_head]]
-type
--ptr に渡した struct list_head の next が指すリスト(A とする)
--A をメンバに持つ構造体の型名
-member
--ptr に渡した struct list_head の next が指すリスト(A とする)
--A が指している構造体のメンバ名
**返り値 [#gbf4f86b]
-
--
-type *
--ptr に渡した struct list_head の next が指すリスト(A とする)
--A をメンバに持つ構造体の先頭を指すポインタ
**参考 [#ve54fdf1]
*実装 [#p41aa079]
/**
* list_first_entry - get the first element from a list
* @ptr: the list head to take the element from.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_head within the struct.
*
* Note, that list is expected to be not empty.
*/
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
-
-ptr は struct list_head * なので、next メンバを持っている。
--[[linux-4.4.1/list_entry()]]
*コメント [#q416727a]