- 追加された行はこの色です。
- 削除された行はこの色です。
*参照元 [#z3763011]
#backlinks
*説明 [#wc2ee26a]
-パス:
--CONFIG_DEBUG_LIST が無効のとき: [[linux-2.6.33/include/linux/list.h]]
--CONFIG_DEBUG_LIST が有効のとき: [[linux-2.6.33/lib/list_debug.c]]
-FIXME: これは何?
--説明
-双方向リンクリストの隣り合う要素 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 となっていることを表す。
**引数 [#id6cee4a]
-struct list_head *new
--
--追加する要素
--[[linux-2.6.33/list_head]]
struct list_head *prev
--
struct list_head *next
--
-struct list_head *prev
--前の要素
-struct list_head *next
--後の要素
**返り値 [#w67b7b3e]
-なし
**参考 [#d64ef9a2]
*実装 [#o4e11728]
**CONFIG_DEBUG_LIST が有効のとき(include/linux/list.h) [#s88067c5]
**CONFIG_DEBUG_LIST が無効のとき(include/linux/list.h) [#s88067c5]
/*
* 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 が隣り合っていなくても気にしない。
--[[linux-2.6.33/CONFIG_DEBUG_LIST]]
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) [#b445e8d1]
**CONFIG_DEBUG_LIST が有効のとき(lib/list_debug.c) [#b445e8d1]
/*
* 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 が隣り合っていない場合に警告する。
--[[linux-2.6.33/WARN()]]
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
EXPORT_SYMBOL(__list_add);
-モジュールのライセンスに関係なくシンボルを公開する。
--[[linux-2.6.33/EXPORT_SYMBOL()]]
*コメント [#a16303db]