diff --git a/m-i-list.h b/m-i-list.h index 30ac6270..3e3ad013 100644 --- a/m-i-list.h +++ b/m-i-list.h @@ -91,6 +91,7 @@ typedef struct ilist_head_s { OPLIST(oplist), \ PUSH(M_C(name,_push_back)), \ POP(M_C(name,_pop_back)) \ + SPLICE_BACK(M_C(name,_splice_back)) \ ,M_IF_METHOD(NEW, oplist)(NEW(M_GET_NEW oplist),) \ ,M_IF_METHOD(DEL, oplist)(DEL(M_GET_DEL oplist),) \ ) diff --git a/m-list.h b/m-list.h index 31cfe3b3..797948a3 100644 --- a/m-list.h +++ b/m-list.h @@ -792,6 +792,22 @@ } \ \ static inline void \ + M_C(name, _push_back_move)(list_t v, type *x) \ + { \ + assert (x != NULL); \ + type *data = M_C(name, _push_back_raw)(v); \ + if (M_UNLIKELY (data == NULL)) \ + return; \ + M_DO_INIT_MOVE (oplist, *data, *x); \ + } \ + \ + static inline void \ + M_C(name, _push_move)(list_t v, type *x) \ + { \ + M_C(name, _push_move)(v, x); \ + } \ + \ + static inline void \ M_C(name, _pop_back)(type *data, list_t v) \ { \ LISTI_DUAL_PUSH_CONTRACT(v); \ @@ -811,6 +827,24 @@ LISTI_DUAL_PUSH_CONTRACT(v); \ } \ \ + static inline void \ + M_C(name, _pop_move)(type *data, list_t v) \ + { \ + LISTI_DUAL_PUSH_CONTRACT(v); \ + assert (v->back != NULL); \ + assert (data != NULL); \ + struct M_C(name, _s) *tofree = v->back; \ + M_DO_INIT_MOVE (oplist, *data, tofree->data); \ + v->back = tofree->next; \ + M_C(name,_int_del)(tofree); \ + /* Update front too if the list became empty */ \ + /* This C code shall generate branchless code */ \ + struct M_C(name, _s) *front = v->front; \ + front = (front == tofree) ? NULL : front; \ + v->front = front; \ + LISTI_DUAL_PUSH_CONTRACT(v); \ + } \ + \ static inline const type * \ M_C(name, _front)(list_t v) \ { \ @@ -850,6 +884,16 @@ M_GET_INIT_SET oplist(*data, x); \ } \ \ + static inline void \ + M_C(name, _push_front_move)(list_t v, type *x) \ + { \ + assert (x != NULL); \ + type *data = M_C(name, _push_front_raw)(v); \ + if (M_UNLIKELY (data == NULL)) \ + return; \ + M_DO_INIT_MOVE (oplist, *data, *x); \ + } \ + \ static inline type * \ M_C(name, _push_front_new)(list_t v) \ { \