4 #include <linux/stddef.h>
5 #include <linux/poison.h>
6 #include <linux/prefetch.h>
7 #include <asm/system.h>
10 struct xlist_head *next;
14 * XLIST_PTR_TAIL can be used to prevent double insertion. See
17 #define XLIST_PTR_TAIL ((struct xlist_head *)0x1)
19 static inline void xlist_add(struct xlist_head *new, struct xlist_head *tail, struct xlist_head *head)
21 struct xlist_head *cur;
22 struct xlist_head *check;
27 check = cmpxchg(&head->next, cur, new);
34 * To avoid duplicate insertion by two CPUs of the same xlist item
35 * you can call xlist_protect. It will stuff XLIST_PTR_TAIL
36 * into the entry->next pointer with xchg, and only return 1
37 * if there was a NULL there before.
39 * if xlist_protect returns zero, someone else is busy working
40 * on this entry. Getting a NULL into the entry in a race
41 * free manner is the caller's job.
43 static inline int xlist_protect(struct xlist_head *entry)
45 struct xlist_head *val;
47 val = xchg(&entry->next, XLIST_PTR_TAIL);
53 static inline struct xlist_head *xlist_del_head(struct xlist_head *head)
55 struct xlist_head *cur;
56 struct xlist_head *check;
57 struct xlist_head *next;
64 if (cur == XLIST_PTR_TAIL) {
70 check = cmpxchg(&head->next, cur, next);
78 static inline struct xlist_head *xlist_del_head_fast(struct xlist_head *head)
80 struct xlist_head *cur;
83 if (!cur || cur == XLIST_PTR_TAIL)
86 head->next = cur->next;
90 static inline void xlist_splice(struct xlist_head *list,
91 struct xlist_head *head)
93 struct xlist_head *cur;
96 cur = xchg(&list->next, NULL);
100 static inline void INIT_XLIST_HEAD(struct xlist_head *list)
105 static inline int xlist_empty(struct xlist_head *head)
107 return head->next == NULL || head->next == XLIST_PTR_TAIL;