参照元†
- struct list_head *ptr
- 構造体内のリスト先頭へのポインタを指定する。
- struct list_head * を推奨する。
- 別の型を指定してもコンパイルエラーにはならないが、struct list_head * 以外の型のポインタから構造体のポインタを求めたい場合は container_of() を使った方が良い。
- linux-4.4.1/list_head
- type
- ptr に指定したポインタが指すメンバ、これを含む「構造体名」を指定する。
マクロはここで指定した型のポインタを返す。
- member
- ptr に指定したポインタが指す「メンバ名」を指定する。
- type に指定した型は member に指定した名前のメンバを持っていないとコンパイルエラーになる。
返り値†
- type *
- 例えば list_entry(a, struct hogehoge, b) とすれば、struct hogehoge * が返ってくる。
/**
* 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)
コメント†