diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2006-06-23 05:05:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 10:43:07 -0400 |
commit | 54e73770357142e297c916c7865f5fca7499f69c (patch) | |
tree | a37b768005eee1fdf6e0ae3051098c51f918785f /include | |
parent | cb259f07b1daacafac3b12ecd7f180faf7e506b0 (diff) |
[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')
-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 76f05718342c..a02642e4710a 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) | |||
197 | entry->prev = LIST_POISON2; | 197 | entry->prev = LIST_POISON2; |
198 | } | 198 | } |
199 | 199 | ||
200 | /** | ||
201 | * list_replace - replace old entry by new one | ||
202 | * @old : the element to be replaced | ||
203 | * @new : the new element to insert | ||
204 | * Note: if 'old' was empty, it will be overwritten. | ||
205 | */ | ||
206 | static inline void list_replace(struct list_head *old, | ||
207 | struct list_head *new) | ||
208 | { | ||
209 | new->next = old->next; | ||
210 | new->next->prev = new; | ||
211 | new->prev = old->prev; | ||
212 | new->prev->next = new; | ||
213 | } | ||
214 | |||
215 | static inline void list_replace_init(struct list_head *old, | ||
216 | struct list_head *new) | ||
217 | { | ||
218 | list_replace(old, new); | ||
219 | INIT_LIST_HEAD(old); | ||
220 | } | ||
221 | |||
200 | /* | 222 | /* |
201 | * list_replace_rcu - replace old entry by new one | 223 | * list_replace_rcu - replace old entry by new one |
202 | * @old : the element to be replaced | 224 | * @old : the element to be replaced |
203 | * @new : the new element to insert | 225 | * @new : the new element to insert |
204 | * | 226 | * |
205 | * The old entry will be replaced with the new entry atomically. | 227 | * The old entry will be replaced with the new entry atomically. |
228 | * Note: 'old' should not be empty. | ||
206 | */ | 229 | */ |
207 | static inline void list_replace_rcu(struct list_head *old, | 230 | static inline void list_replace_rcu(struct list_head *old, |
208 | struct list_head *new) | 231 | struct list_head *new) |