willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 3dd717c | 2014-12-23 13:58:43 +0100 | [diff] [blame] | 2 | * include/common/mini-clist.h |
| 3 | * Circular list manipulation macros and structures. |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 4 | * |
Willy Tarreau | 3dd717c | 2014-12-23 13:58:43 +0100 | [diff] [blame] | 5 | * Copyright (C) 2002-2014 Willy Tarreau - w@1wt.eu |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 20 | */ |
| 21 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 22 | #ifndef _COMMON_MINI_CLIST_H |
| 23 | #define _COMMON_MINI_CLIST_H |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 24 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 25 | #include <common/config.h> |
| 26 | |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 27 | /* these are circular or bidirectionnal lists only. Each list pointer points to |
| 28 | * another list pointer in a structure, and not the structure itself. The |
| 29 | * pointer to the next element MUST be the first one so that the list is easily |
| 30 | * cast as a single linked list or pointer. |
| 31 | */ |
| 32 | struct list { |
| 33 | struct list *n; /* next */ |
| 34 | struct list *p; /* prev */ |
| 35 | }; |
| 36 | |
Willy Tarreau | bc04ce7 | 2008-12-07 20:00:15 +0100 | [diff] [blame] | 37 | /* a back-ref is a pointer to a target list entry. It is used to detect when an |
| 38 | * element being deleted is currently being tracked by another user. The best |
| 39 | * example is a user dumping the session table. The table does not fit in the |
| 40 | * output buffer so we have to set a mark on a session and go on later. But if |
| 41 | * that marked session gets deleted, we don't want the user's pointer to go in |
| 42 | * the wild. So we can simply link this user's request to the list of this |
| 43 | * session's users, and put a pointer to the list element in ref, that will be |
| 44 | * used as the mark for next iteration. |
| 45 | */ |
| 46 | struct bref { |
| 47 | struct list users; |
| 48 | struct list *ref; /* pointer to the target's list entry */ |
| 49 | }; |
| 50 | |
Willy Tarreau | deb9ed8 | 2010-01-03 21:03:22 +0100 | [diff] [blame] | 51 | /* a word list is a generic list with a pointer to a string in each element. */ |
| 52 | struct wordlist { |
| 53 | struct list list; |
| 54 | char *s; |
| 55 | }; |
| 56 | |
Willy Tarreau | f4f0412 | 2010-01-28 18:10:50 +0100 | [diff] [blame] | 57 | /* this is the same as above with an additional pointer to a condition. */ |
| 58 | struct cond_wordlist { |
| 59 | struct list list; |
| 60 | void *cond; |
| 61 | char *s; |
| 62 | }; |
| 63 | |
Willy Tarreau | bd578bb | 2007-10-28 11:41:06 +0100 | [diff] [blame] | 64 | /* First undefine some macros which happen to also be defined on OpenBSD, |
| 65 | * in sys/queue.h, used by sys/event.h |
| 66 | */ |
| 67 | #undef LIST_HEAD |
| 68 | #undef LIST_INIT |
| 69 | #undef LIST_NEXT |
| 70 | |
Willy Tarreau | dc13c11 | 2013-06-21 23:16:39 +0200 | [diff] [blame] | 71 | /* ILH = Initialized List Head : used to prevent gcc from moving an empty |
| 72 | * list to BSS. Some older version tend to trim all the array and cause |
| 73 | * corruption. |
| 74 | */ |
| 75 | #define ILH { .n = (struct list *)1, .p = (struct list *)2 } |
| 76 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 77 | #define LIST_HEAD(a) ((void *)(&(a))) |
| 78 | |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 79 | #define LIST_INIT(l) ((l)->n = (l)->p = (l)) |
| 80 | |
Willy Tarreau | 2b1dccd | 2007-05-07 00:18:32 +0200 | [diff] [blame] | 81 | #define LIST_HEAD_INIT(l) { &l, &l } |
| 82 | |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 83 | /* adds an element at the beginning of a list ; returns the element */ |
| 84 | #define LIST_ADD(lh, el) ({ (el)->n = (lh)->n; (el)->n->p = (lh)->n = (el); (el)->p = (lh); (el); }) |
| 85 | |
| 86 | /* adds an element at the end of a list ; returns the element */ |
| 87 | #define LIST_ADDQ(lh, el) ({ (el)->p = (lh)->p; (el)->p->n = (lh)->p = (el); (el)->n = (lh); (el); }) |
| 88 | |
Willy Tarreau | 9bead8c | 2019-08-16 11:27:50 +0200 | [diff] [blame] | 89 | /* adds the contents of a list <old> at the beginning of another list <new>. The old list head remains untouched. */ |
| 90 | #define LIST_SPLICE(new, old) do { \ |
| 91 | if (!LIST_ISEMPTY(old)) { \ |
| 92 | (old)->p->n = (new)->n; (old)->n->p = (new); \ |
| 93 | (new)->n->p = (old)->p; (new)->n = (old)->n; \ |
| 94 | } \ |
| 95 | } while (0) |
| 96 | |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 97 | /* removes an element from a list and returns it */ |
| 98 | #define LIST_DEL(el) ({ typeof(el) __ret = (el); (el)->n->p = (el)->p; (el)->p->n = (el)->n; (__ret); }) |
| 99 | |
Willy Tarreau | c5bd311 | 2019-03-06 19:32:11 +0100 | [diff] [blame] | 100 | /* removes an element from a list, initializes it and returns it. |
| 101 | * This is faster than LIST_DEL+LIST_INIT as we avoid reloading the pointers. |
| 102 | */ |
| 103 | #define LIST_DEL_INIT(el) ({ \ |
| 104 | typeof(el) __ret = (el); \ |
| 105 | typeof(__ret->n) __n = __ret->n; \ |
| 106 | typeof(__ret->p) __p = __ret->p; \ |
| 107 | __n->p = __p; __p->n = __n; \ |
| 108 | __ret->n = __ret->p = __ret; \ |
| 109 | __ret; \ |
| 110 | }) |
| 111 | |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 112 | /* returns a pointer of type <pt> to a structure containing a list head called |
| 113 | * <el> at address <lh>. Note that <lh> can be the result of a function or macro |
| 114 | * since it's used only once. |
| 115 | * Example: LIST_ELEM(cur_node->args.next, struct node *, args) |
| 116 | */ |
| 117 | #define LIST_ELEM(lh, pt, el) ((pt)(((void *)(lh)) - ((void *)&((pt)NULL)->el))) |
| 118 | |
| 119 | /* checks if the list head <lh> is empty or not */ |
| 120 | #define LIST_ISEMPTY(lh) ((lh)->n == (lh)) |
| 121 | |
Willy Tarreau | 42ccb5a | 2019-05-13 17:48:46 +0200 | [diff] [blame] | 122 | /* checks if the list element <el> was added to a list or not. This only |
| 123 | * works when detached elements are reinitialized (using LIST_DEL_INIT) |
| 124 | */ |
| 125 | #define LIST_ADDED(el) ((el)->n != (el)) |
| 126 | |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 127 | /* returns a pointer of type <pt> to a structure following the element |
| 128 | * which contains list head <lh>, which is known as element <el> in |
| 129 | * struct pt. |
| 130 | * Example: LIST_NEXT(args, struct node *, list) |
| 131 | */ |
| 132 | #define LIST_NEXT(lh, pt, el) (LIST_ELEM((lh)->n, pt, el)) |
| 133 | |
| 134 | |
Joseph Herlant | 41abef7 | 2018-11-25 10:57:13 -0800 | [diff] [blame] | 135 | /* returns a pointer of type <pt> to a structure preceding the element |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 136 | * which contains list head <lh>, which is known as element <el> in |
| 137 | * struct pt. |
| 138 | */ |
Thierry FOURNIER | 1db9667 | 2015-11-03 19:17:37 +0100 | [diff] [blame] | 139 | #undef LIST_PREV |
willy tarreau | 80862a3 | 2006-04-12 19:15:57 +0200 | [diff] [blame] | 140 | #define LIST_PREV(lh, pt, el) (LIST_ELEM((lh)->p, pt, el)) |
| 141 | |
| 142 | /* |
Willy Tarreau | b9c62b9 | 2007-05-02 20:46:49 +0200 | [diff] [blame] | 143 | * Simpler FOREACH_ITEM macro inspired from Linux sources. |
| 144 | * Iterates <item> through a list of items of type "typeof(*item)" which are |
| 145 | * linked via a "struct list" member named <member>. A pointer to the head of |
| 146 | * the list is passed in <list_head>. No temporary variable is needed. Note |
| 147 | * that <item> must not be modified during the loop. |
| 148 | * Example: list_for_each_entry(cur_acl, known_acl, list) { ... }; |
| 149 | */ |
| 150 | #define list_for_each_entry(item, list_head, member) \ |
| 151 | for (item = LIST_ELEM((list_head)->n, typeof(item), member); \ |
| 152 | &item->member != (list_head); \ |
| 153 | item = LIST_ELEM(item->member.n, typeof(item), member)) |
| 154 | |
| 155 | /* |
William Lallemand | 83215a4 | 2017-09-24 11:26:02 +0200 | [diff] [blame] | 156 | * Same as list_for_each_entry but starting from current point |
| 157 | * Iterates <item> through the list starting from <item> |
| 158 | * It's basically the same macro but without initializing item to the head of |
| 159 | * the list. |
| 160 | */ |
| 161 | #define list_for_each_entry_from(item, list_head, member) \ |
| 162 | for ( ; &item->member != (list_head); \ |
| 163 | item = LIST_ELEM(item->member.n, typeof(item), member)) |
| 164 | |
| 165 | /* |
Willy Tarreau | b9c62b9 | 2007-05-02 20:46:49 +0200 | [diff] [blame] | 166 | * Simpler FOREACH_ITEM_SAFE macro inspired from Linux sources. |
| 167 | * Iterates <item> through a list of items of type "typeof(*item)" which are |
| 168 | * linked via a "struct list" member named <member>. A pointer to the head of |
| 169 | * the list is passed in <list_head>. A temporary variable <back> of same type |
| 170 | * as <item> is needed so that <item> may safely be deleted if needed. |
| 171 | * Example: list_for_each_entry_safe(cur_acl, tmp, known_acl, list) { ... }; |
| 172 | */ |
| 173 | #define list_for_each_entry_safe(item, back, list_head, member) \ |
| 174 | for (item = LIST_ELEM((list_head)->n, typeof(item), member), \ |
| 175 | back = LIST_ELEM(item->member.n, typeof(item), member); \ |
| 176 | &item->member != (list_head); \ |
| 177 | item = back, back = LIST_ELEM(back->member.n, typeof(back), member)) |
| 178 | |
| 179 | |
William Lallemand | 83215a4 | 2017-09-24 11:26:02 +0200 | [diff] [blame] | 180 | /* |
| 181 | * Same as list_for_each_entry_safe but starting from current point |
| 182 | * Iterates <item> through the list starting from <item> |
| 183 | * It's basically the same macro but without initializing item to the head of |
| 184 | * the list. |
| 185 | */ |
| 186 | #define list_for_each_entry_safe_from(item, back, list_head, member) \ |
| 187 | for (back = LIST_ELEM(item->member.n, typeof(item), member); \ |
| 188 | &item->member != (list_head); \ |
| 189 | item = back, back = LIST_ELEM(back->member.n, typeof(back), member)) |
| 190 | |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 191 | #include <common/hathreads.h> |
| 192 | #define LLIST_BUSY ((struct list *)1) |
| 193 | |
| 194 | /* |
| 195 | * Locked version of list manipulation macros. |
| 196 | * It is OK to use those concurrently from multiple threads, as long as the |
| 197 | * list is only used with the locked variants. The only "unlocked" macro you |
| 198 | * can use with a locked list is LIST_INIT. |
| 199 | */ |
| 200 | #define LIST_ADD_LOCKED(lh, el) \ |
| 201 | do { \ |
| 202 | while (1) { \ |
| 203 | struct list *n; \ |
| 204 | struct list *p; \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 205 | n = _HA_ATOMIC_XCHG(&(lh)->n, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 206 | if (n == LLIST_BUSY) \ |
| 207 | continue; \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 208 | p = _HA_ATOMIC_XCHG(&n->p, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 209 | if (p == LLIST_BUSY) { \ |
| 210 | (lh)->n = n; \ |
| 211 | __ha_barrier_store(); \ |
| 212 | continue; \ |
| 213 | } \ |
| 214 | (el)->n = n; \ |
| 215 | (el)->p = p; \ |
Willy Tarreau | 690d2ad | 2019-02-28 11:14:22 +0100 | [diff] [blame] | 216 | __ha_barrier_store(); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 217 | n->p = (el); \ |
| 218 | __ha_barrier_store(); \ |
| 219 | p->n = (el); \ |
| 220 | __ha_barrier_store(); \ |
| 221 | break; \ |
| 222 | } \ |
| 223 | } while (0) |
| 224 | |
| 225 | #define LIST_ADDQ_LOCKED(lh, el) \ |
| 226 | do { \ |
| 227 | while (1) { \ |
| 228 | struct list *n; \ |
| 229 | struct list *p; \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 230 | p = _HA_ATOMIC_XCHG(&(lh)->p, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 231 | if (p == LLIST_BUSY) \ |
| 232 | continue; \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 233 | n = _HA_ATOMIC_XCHG(&p->n, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 234 | if (n == LLIST_BUSY) { \ |
Willy Tarreau | bd20ad5 | 2019-02-28 11:09:56 +0100 | [diff] [blame] | 235 | (lh)->p = p; \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 236 | __ha_barrier_store(); \ |
| 237 | continue; \ |
| 238 | } \ |
| 239 | (el)->n = n; \ |
| 240 | (el)->p = p; \ |
Willy Tarreau | 690d2ad | 2019-02-28 11:14:22 +0100 | [diff] [blame] | 241 | __ha_barrier_store(); \ |
Willy Tarreau | 967de20 | 2019-03-04 11:19:49 +0100 | [diff] [blame] | 242 | p->n = (el); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 243 | __ha_barrier_store(); \ |
Willy Tarreau | 967de20 | 2019-03-04 11:19:49 +0100 | [diff] [blame] | 244 | n->p = (el); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 245 | __ha_barrier_store(); \ |
| 246 | break; \ |
| 247 | } \ |
| 248 | } while (0) |
| 249 | |
| 250 | #define LIST_DEL_LOCKED(el) \ |
| 251 | do { \ |
| 252 | while (1) { \ |
| 253 | struct list *n, *n2; \ |
Olivier Houchard | db64489 | 2019-02-26 18:46:07 +0100 | [diff] [blame] | 254 | struct list *p, *p2 = NULL; \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 255 | n = _HA_ATOMIC_XCHG(&(el)->n, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 256 | if (n == LLIST_BUSY) \ |
| 257 | continue; \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 258 | p = _HA_ATOMIC_XCHG(&(el)->p, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 259 | if (p == LLIST_BUSY) { \ |
| 260 | (el)->n = n; \ |
| 261 | __ha_barrier_store(); \ |
| 262 | continue; \ |
| 263 | } \ |
| 264 | if (p != (el)) { \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 265 | p2 = _HA_ATOMIC_XCHG(&p->n, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 266 | if (p2 == LLIST_BUSY) { \ |
| 267 | (el)->p = p; \ |
| 268 | (el)->n = n; \ |
| 269 | __ha_barrier_store(); \ |
| 270 | continue; \ |
| 271 | } \ |
| 272 | } \ |
| 273 | if (n != (el)) { \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 274 | n2 = _HA_ATOMIC_XCHG(&n->p, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 275 | if (n2 == LLIST_BUSY) { \ |
Olivier Houchard | db64489 | 2019-02-26 18:46:07 +0100 | [diff] [blame] | 276 | if (p2 != NULL) \ |
Willy Tarreau | b0cef35 | 2019-03-13 14:03:28 +0100 | [diff] [blame] | 277 | p->n = p2; \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 278 | (el)->p = p; \ |
| 279 | (el)->n = n; \ |
| 280 | __ha_barrier_store(); \ |
| 281 | continue; \ |
| 282 | } \ |
| 283 | } \ |
| 284 | n->p = p; \ |
| 285 | p->n = n; \ |
| 286 | __ha_barrier_store(); \ |
Willy Tarreau | 4c747e8 | 2019-02-28 15:05:53 +0100 | [diff] [blame] | 287 | (el)->p = (el); \ |
| 288 | (el)->n = (el); \ |
| 289 | __ha_barrier_store(); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 290 | break; \ |
| 291 | } \ |
| 292 | } while (0) |
| 293 | |
| 294 | |
| 295 | /* Remove the first element from the list, and return it */ |
| 296 | #define LIST_POP_LOCKED(lh, pt, el) \ |
| 297 | ({ \ |
| 298 | void *_ret; \ |
| 299 | while (1) { \ |
| 300 | struct list *n, *n2; \ |
| 301 | struct list *p, *p2; \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 302 | n = _HA_ATOMIC_XCHG(&(lh)->n, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 303 | if (n == LLIST_BUSY) \ |
| 304 | continue; \ |
| 305 | if (n == (lh)) { \ |
| 306 | (lh)->n = lh; \ |
Willy Tarreau | 690d2ad | 2019-02-28 11:14:22 +0100 | [diff] [blame] | 307 | __ha_barrier_store(); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 308 | _ret = NULL; \ |
| 309 | break; \ |
| 310 | } \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 311 | p = _HA_ATOMIC_XCHG(&n->p, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 312 | if (p == LLIST_BUSY) { \ |
| 313 | (lh)->n = n; \ |
| 314 | __ha_barrier_store(); \ |
| 315 | continue; \ |
| 316 | } \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 317 | n2 = _HA_ATOMIC_XCHG(&n->n, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 318 | if (n2 == LLIST_BUSY) { \ |
| 319 | n->p = p; \ |
Willy Tarreau | 690d2ad | 2019-02-28 11:14:22 +0100 | [diff] [blame] | 320 | __ha_barrier_store(); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 321 | (lh)->n = n; \ |
| 322 | __ha_barrier_store(); \ |
| 323 | continue; \ |
| 324 | } \ |
Olivier Houchard | 9f8d821 | 2019-03-13 18:50:33 +0100 | [diff] [blame] | 325 | p2 = _HA_ATOMIC_XCHG(&n2->p, LLIST_BUSY); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 326 | if (p2 == LLIST_BUSY) { \ |
| 327 | n->n = n2; \ |
| 328 | n->p = p; \ |
Willy Tarreau | 690d2ad | 2019-02-28 11:14:22 +0100 | [diff] [blame] | 329 | __ha_barrier_store(); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 330 | (lh)->n = n; \ |
| 331 | __ha_barrier_store(); \ |
| 332 | continue; \ |
| 333 | } \ |
| 334 | (lh)->n = n2; \ |
| 335 | (n2)->p = (lh); \ |
| 336 | __ha_barrier_store(); \ |
Willy Tarreau | 4c747e8 | 2019-02-28 15:05:53 +0100 | [diff] [blame] | 337 | (n)->p = (n); \ |
| 338 | (n)->n = (n); \ |
| 339 | __ha_barrier_store(); \ |
Olivier Houchard | a8434ec | 2019-01-18 17:26:26 +0100 | [diff] [blame] | 340 | _ret = LIST_ELEM(n, pt, el); \ |
| 341 | break; \ |
| 342 | } \ |
| 343 | (_ret); \ |
| 344 | }) |
William Lallemand | 83215a4 | 2017-09-24 11:26:02 +0200 | [diff] [blame] | 345 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 346 | #endif /* _COMMON_MINI_CLIST_H */ |