diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2006-06-23 02:05:54 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 07:43:07 -0700 |
commit | 54e73770357142e297c916c7865f5fca7499f69c (patch) | |
tree | a37b768005eee1fdf6e0ae3051098c51f918785f /include/linux/list.h | |
parent | cb259f07b1daacafac3b12ecd7f180faf7e506b0 (diff) | |
download | op-kernel-dev-54e73770357142e297c916c7865f5fca7499f69c.zip op-kernel-dev-54e73770357142e297c916c7865f5fca7499f69c.tar.gz |
[PATCH] list: introduce list_replace() helper
list_replace() is similar to list_replace_rcu(), but unlike
list_replace_rcu() it
could be used when list_empty(old) == 1
doesn't use barriers
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/list.h')
-rw-r--r-- | include/linux/list.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h index 76f0571..a02642e 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -197,12 +197,35 @@ static inline void list_del_rcu(struct list_head *entry) entry->prev = LIST_POISON2; } +/** + * list_replace - replace old entry by new one + * @old : the element to be replaced + * @new : the new element to insert + * Note: if 'old' was empty, it will be overwritten. + */ +static inline void list_replace(struct list_head *old, + struct list_head *new) +{ + new->next = old->next; + new->next->prev = new; + new->prev = old->prev; + new->prev->next = new; +} + +static inline void list_replace_init(struct list_head *old, + struct list_head *new) +{ + list_replace(old, new); + INIT_LIST_HEAD(old); +} + /* * list_replace_rcu - replace old entry by new one * @old : the element to be replaced * @new : the new element to insert * * The old entry will be replaced with the new entry atomically. + * Note: 'old' should not be empty. */ static inline void list_replace_rcu(struct list_head *old, struct list_head *new) |