#author("2025-10-28T10:26:37+09:00","default:guest","guest") #author("2025-10-28T10:27:36+09:00","default:guest","guest") *参照元 [#v6f6bcbe] #backlinks *説明 [#g9785666] -パス: [[linux-5.15/include/linux/list.h]] -FIXME: これは何? --説明 -リストを含む構造体のポインタを取得するマクロ。 --container_of() も参照のこと。 --[[linux-5.15/container_of()]] **引数 [#od493f7a] -struct list_head *ptr --構造体内のリスト先頭へのポインタを指定する。 --struct list_head *以外の型を指定してもコンパイルエラーにはならないが、struct list_head *以外の型のポインタから構造体のポインタを求めたい場合はcontainer_of()を使った方が良い。 --[[linux-5.15/list_head]] -type --ptr に指定したポインタが指すメンバ、これを含む「構造体名」を指定する。マクロはここで指定した型のポインタを返す。 -member --ptr に指定したポインタが指す「メンバ名」を指定する。 --type に指定した型は member に指定した名前のメンバを持っていないとコンパイルエラーになる。 **返り値 [#icb199b8] -type * --例えばlist_entry(a, struct hogehoge, b)とすれば、struct hogehoge *が返ってくる。 **参考 [#ldaf87bc] *実装 [#q51f3057] /** * 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-5.15/container_of()]] *コメント [#pfc01476]