ck_queue: add CK_SLIST_INSERT_PREVPTR and CK_SLIST_REMOVE_PREVPTR

These new macros are very convenient for modifying a SLIST after
using CK_SLIST_FOREACH_PREVPTR to find an element to remove
or a position to insert.

FreeBSD sys/queue.h already has SLIST_REMOVE_PREVPTR.

I would like to use the new macros in a change that I am planning
for FreeBSD kernel:
https://reviews.freebsd.org/D16016
https://reviews.freebsd.org/D15905
awsm
Andriy Gapon 6 years ago committed by Samy Al Bahra
parent 5b74d9f9b0
commit 1c1f9901c2

@ -180,6 +180,12 @@ struct { \
ck_pr_store_ptr(&(head)->cslh_first, elm); \ ck_pr_store_ptr(&(head)->cslh_first, elm); \
} while (0) } while (0)
#define CK_SLIST_INSERT_PREVPTR(prevp, slistelm, elm, field) do { \
(elm)->field.csle_next = (slistelm); \
ck_pr_fence_store(); \
ck_pr_store_ptr(prevp, elm); \
} while (0)
#define CK_SLIST_REMOVE_AFTER(elm, field) do { \ #define CK_SLIST_REMOVE_AFTER(elm, field) do { \
ck_pr_store_ptr(&(elm)->field.csle_next, \ ck_pr_store_ptr(&(elm)->field.csle_next, \
(elm)->field.csle_next->field.csle_next); \ (elm)->field.csle_next->field.csle_next); \
@ -201,6 +207,10 @@ struct { \
(head)->cslh_first->field.csle_next); \ (head)->cslh_first->field.csle_next); \
} while (0) } while (0)
#define CK_SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \
ck_pr_store_ptr(prevptr, (elm)->field.csle_next); \
} while (0)
#define CK_SLIST_MOVE(head1, head2, field) do { \ #define CK_SLIST_MOVE(head1, head2, field) do { \
ck_pr_store_ptr(&(head1)->cslh_first, (head2)->cslh_first); \ ck_pr_store_ptr(&(head1)->cslh_first, (head2)->cslh_first); \
} while (0) } while (0)

Loading…
Cancel
Save