- 追加された行はこの色です。
- 削除された行はこの色です。
*参照元 [#wa2d8c1b]
#backlinks
*説明 [#edc1867e]
-パス: [[linux-4.4.1/]]
-パス: [[linux-4.4.1/include/linux/list.h]]
-FIXME: これは何?
--説明
-リストを含む構造体のポインタを取得するマクロ。
--container_of() も参照のこと。
--[[linux-4.4.1/container_of()]]
**引数 [#v2dbbc49]
-
--
-struct list_head *ptr
--構造体内のリスト先頭へのポインタを指定する。
--struct list_head * を推奨する。
--別の型を指定してもコンパイルエラーにはならないが、struct list_head * 以外の型のポインタから構造体のポインタを求めたい場合は container_of() を使った方が良い。
--[[linux-4.4.1/list_head]]
-type
--ptr に指定したポインタが指すメンバ、これを含む「構造体名」を指定する。
マクロはここで指定した型のポインタを返す。
-member
--ptr に指定したポインタが指す「メンバ名」を指定する。
--type に指定した型は member に指定した名前のメンバを持っていないとコンパイルエラーになる。
**返り値 [#gf56cc7a]
-
--
-type *
--例えば list_entry(a, struct hogehoge, b) とすれば、struct hogehoge * が返ってくる。
**参考 [#l0730889]
*実装 [#q75f08ed]
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_head within the struct.
*/
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
-
-container_of() を呼び出すだけ。
--[[linux-4.4.1/container_of()]]
*コメント [#ca9cf61e]