diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2016-05-09 21:40:56 +0200 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2016-05-11 13:25:56 +0300 |
commit | c6c1d7633f5c4ca3ac5f82caf0bffe811307e293 (patch) | |
tree | b818b72c0aa88ca9b8b0b9e0e0c1a893b9b820d7 /accel-pppd/triton/list.h | |
parent | 7ae7712429737afe72068eec6b76f0632f1d8d55 (diff) | |
download | accel-ppp-c6c1d7633f5c4ca3ac5f82caf0bffe811307e293.tar.gz accel-ppp-c6c1d7633f5c4ca3ac5f82caf0bffe811307e293.zip |
triton: implement list_replace*()
Add list_replace() and list_replace_init(), as defined in Linux kernel
sources.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/triton/list.h')
-rw-r--r-- | accel-pppd/triton/list.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/accel-pppd/triton/list.h b/accel-pppd/triton/list.h index a650037f..20b917d4 100644 --- a/accel-pppd/triton/list.h +++ b/accel-pppd/triton/list.h @@ -99,6 +99,29 @@ static inline void list_del(struct list_head *entry) } /** + * list_replace - replace old entry by new one + * @old : the element to be replaced + * @new : the new element to insert + * + * 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_del_init - deletes entry from list and reinitialize it. * @entry: the element to delete from the list. */ |