参照元†
- 双方向リンクリストの隣り合う要素 next と prev の間に、
新たな要素 new を追加する。
- デバッグオプションが有効の時は next と prev が隣り合っているかどうか確かめ、
隣り合っていないときは警告する。
before
------
(n) --, (n) --,
other1 prev next other2
`-- (p) `-- (p)
after
-----
(n) --, (n) --, (n) --,
other1 prev new next other2
`-- (p) `-- (p) `-- (p)
なお、
(n) は next メンバ
(p) は prev メンバ
new(n) --> next なら new->next = next となっていることを表す。
- struct list_head *new
- struct list_head *prev
- struct list_head *next
返り値†
CONFIG_DEBUG_LIST が無効のとき(include/linux/list.h)†
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
#ifndef CONFIG_DEBUG_LIST
- コンフィグが無効の場合は prev と next が隣り合っていなくても気にしない。
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
#else
extern void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next);
#endif
CONFIG_DEBUG_LIST が有効のとき(lib/list_debug.c)†
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
WARN(next->prev != prev,
"list_add corruption. next->prev should be "
"prev (%p), but was %p. (next=%p).\n",
prev, next->prev, next);
WARN(prev->next != next,
"list_add corruption. prev->next should be "
"next (%p), but was %p. (prev=%p).\n",
next, prev->next, prev);
- next と prev が隣り合っていない場合に警告する。
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
EXPORT_SYMBOL(__list_add);
- モジュールのライセンスに関係なくシンボルを公開する。
コメント†