X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Flist.h;h=888e776fd3b9309470aa5c552e77745744aedda5;hp=7ccb76aeee760f0686155c0de34e568fc49fc50b;hb=3d02c34dba0edc4a3554a3862a2ae96d77b3b4e8;hpb=7a50dcf71c2134c4755ceee9cdaa865a07be27ad diff --git a/urcu/list.h b/urcu/list.h index 7ccb76a..888e776 100644 --- a/urcu/list.h +++ b/urcu/list.h @@ -65,14 +65,39 @@ list_add_tail (list_t *newp, list_t *head) } +/* Remove element from list. */ +static inline void +__list_del (list_t *prev, list_t *next) +{ + next->prev = prev; + prev->next = next; +} + /* Remove element from list. */ static inline void list_del (list_t *elem) { - elem->next->prev = elem->prev; - elem->prev->next = elem->next; + __list_del (elem->prev, elem->next); +} + +/* delete from list, add to another list as head */ +static inline void +list_move (list_t *elem, list_t *head) +{ + __list_del (elem->prev, elem->next); + list_add (elem, head); } +/* replace an old entry. + */ +static inline void +list_replace(list_t *old, list_t *_new) +{ + _new->next = old->next; + _new->prev = old->prev; + _new->prev->next = _new; + _new->next->prev = _new; +} /* Join two lists. */ static inline void @@ -134,11 +159,11 @@ static inline int list_empty(list_t *head) } static inline void list_replace_init(list_t *old, - list_t *new) + list_t *_new) { list_t *head = old->next; list_del(old); - list_add_tail(new, head); + list_add_tail(_new, head); INIT_LIST_HEAD(old); }