\doxysection{linuxlist.\+h}
\label{linuxlist_8h_source}\index{include/osmocom/core/linuxlist.h@{include/osmocom/core/linuxlist.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{12 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{13 }
\DoxyCodeLine{18 \textcolor{preprocessor}{\#include <stddef.h>}}
\DoxyCodeLine{19 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{20 }
\DoxyCodeLine{21 \textcolor{preprocessor}{\#ifndef inline}}
\DoxyCodeLine{22 \textcolor{preprocessor}{\#define inline \_\_inline\_\_}}
\DoxyCodeLine{23 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} prefetch(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *x) \{;\}}
\DoxyCodeLine{26 }
\DoxyCodeLine{32 \textcolor{preprocessor}{\#define container\_of(ptr, type, member) (\{                      \(\backslash\)}}
\DoxyCodeLine{33 \textcolor{preprocessor}{        const typeof( ((type *)0)-\/>member ) *\_\_mptr = (ptr);    \(\backslash\)}}
\DoxyCodeLine{34 \textcolor{preprocessor}{        (type *)( (char *)\_\_mptr -\/ offsetof(type, member) );\})}}
\DoxyCodeLine{35 }
\DoxyCodeLine{36 }
\DoxyCodeLine{42 \textcolor{preprocessor}{\#define LLIST\_POISON1  ((void *) 0x00100100)}}
\DoxyCodeLine{43 \textcolor{preprocessor}{\#define LLIST\_POISON2  ((void *) 0x00200200)}}
\DoxyCodeLine{44 }
\DoxyCodeLine{46 \textcolor{keyword}{struct }llist\_head \{}
\DoxyCodeLine{48         \textcolor{keyword}{struct }llist\_head *next, *prev;}
\DoxyCodeLine{49 \};}
\DoxyCodeLine{50 }
\DoxyCodeLine{54 \textcolor{preprocessor}{\#define LLIST\_HEAD\_INIT(name) \{ \&(name), \&(name) \}}}
\DoxyCodeLine{55 }
\DoxyCodeLine{59 \textcolor{preprocessor}{\#define LLIST\_HEAD(name) \(\backslash\)}}
\DoxyCodeLine{60 \textcolor{preprocessor}{        struct llist\_head name = LLIST\_HEAD\_INIT(name)}}
\DoxyCodeLine{61 }
\DoxyCodeLine{65 \textcolor{preprocessor}{\#define INIT\_LLIST\_HEAD(ptr) do \{ \(\backslash\)}}
\DoxyCodeLine{66 \textcolor{preprocessor}{        (ptr)-\/>next = (ptr); (ptr)-\/>prev = (ptr); \(\backslash\)}}
\DoxyCodeLine{67 \textcolor{preprocessor}{\} while (0)}}
\DoxyCodeLine{68 }
\DoxyCodeLine{69 \textcolor{comment}{/*}}
\DoxyCodeLine{70 \textcolor{comment}{ * Insert a new entry between two known consecutive entries.}}
\DoxyCodeLine{71 \textcolor{comment}{ *}}
\DoxyCodeLine{72 \textcolor{comment}{ * This is only for internal llist manipulation where we know}}
\DoxyCodeLine{73 \textcolor{comment}{ * the prev/next entries already!}}
\DoxyCodeLine{74 \textcolor{comment}{ */}}
\DoxyCodeLine{75 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} \_\_llist\_add(\textcolor{keyword}{struct} llist\_head *\_new,}
\DoxyCodeLine{76                                \textcolor{keyword}{struct} llist\_head *prev,}
\DoxyCodeLine{77                                \textcolor{keyword}{struct} llist\_head *next)}
\DoxyCodeLine{78 \{}
\DoxyCodeLine{79         next-\/>prev = \_new;}
\DoxyCodeLine{80         \_new-\/>next = next;}
\DoxyCodeLine{81         \_new-\/>prev = prev;}
\DoxyCodeLine{82         prev-\/>next = \_new;}
\DoxyCodeLine{83 \}}
\DoxyCodeLine{84 }
\DoxyCodeLine{92 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_add(\textcolor{keyword}{struct} llist\_head *\_new, \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{93 \{}
\DoxyCodeLine{94         \_\_llist\_add(\_new, head, head-\/>next);}
\DoxyCodeLine{95 \}}
\DoxyCodeLine{96 }
\DoxyCodeLine{104 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_add\_tail(\textcolor{keyword}{struct} llist\_head *\_new, \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{105 \{}
\DoxyCodeLine{106         \_\_llist\_add(\_new, head-\/>prev, head);}
\DoxyCodeLine{107 \}}
\DoxyCodeLine{108 }
\DoxyCodeLine{109 \textcolor{comment}{/*}}
\DoxyCodeLine{110 \textcolor{comment}{ * Delete a llist entry by making the prev/next entries}}
\DoxyCodeLine{111 \textcolor{comment}{ * point to each other.}}
\DoxyCodeLine{112 \textcolor{comment}{ *}}
\DoxyCodeLine{113 \textcolor{comment}{ * This is only for internal llist manipulation where we know}}
\DoxyCodeLine{114 \textcolor{comment}{ * the prev/next entries already!}}
\DoxyCodeLine{115 \textcolor{comment}{ */}}
\DoxyCodeLine{116 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} \_\_llist\_del(\textcolor{keyword}{struct} llist\_head * prev, \textcolor{keyword}{struct} llist\_head * next)}
\DoxyCodeLine{117 \{}
\DoxyCodeLine{118         next-\/>prev = prev;}
\DoxyCodeLine{119         prev-\/>next = next;}
\DoxyCodeLine{120 \}}
\DoxyCodeLine{121 }
\DoxyCodeLine{128 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_del(\textcolor{keyword}{struct} llist\_head *entry)}
\DoxyCodeLine{129 \{}
\DoxyCodeLine{130         \_\_llist\_del(entry-\/>prev, entry-\/>next);}
\DoxyCodeLine{131         entry-\/>next = (\textcolor{keyword}{struct }llist\_head *)LLIST\_POISON1;}
\DoxyCodeLine{132         entry-\/>prev = (\textcolor{keyword}{struct }llist\_head *)LLIST\_POISON2;}
\DoxyCodeLine{133 \}}
\DoxyCodeLine{134 }
\DoxyCodeLine{138 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_del\_init(\textcolor{keyword}{struct} llist\_head *entry)}
\DoxyCodeLine{139 \{}
\DoxyCodeLine{140         \_\_llist\_del(entry-\/>prev, entry-\/>next);}
\DoxyCodeLine{141         INIT\_LLIST\_HEAD(entry);}
\DoxyCodeLine{142 \}}
\DoxyCodeLine{143 }
\DoxyCodeLine{148 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_move(\textcolor{keyword}{struct} llist\_head *llist, \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{149 \{}
\DoxyCodeLine{150         \_\_llist\_del(llist-\/>prev, llist-\/>next);}
\DoxyCodeLine{151         llist\_add(llist, head);}
\DoxyCodeLine{152 \}}
\DoxyCodeLine{153 }
\DoxyCodeLine{158 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_move\_tail(\textcolor{keyword}{struct} llist\_head *llist,}
\DoxyCodeLine{159                                    \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{160 \{}
\DoxyCodeLine{161         \_\_llist\_del(llist-\/>prev, llist-\/>next);}
\DoxyCodeLine{162         llist\_add\_tail(llist, head);}
\DoxyCodeLine{163 \}}
\DoxyCodeLine{164 }
\DoxyCodeLine{169 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} llist\_empty(\textcolor{keyword}{const} \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{170 \{}
\DoxyCodeLine{171         \textcolor{keywordflow}{return} head-\/>next == head;}
\DoxyCodeLine{172 \}}
\DoxyCodeLine{173 }
\DoxyCodeLine{174 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} \_\_llist\_splice(\textcolor{keyword}{struct} llist\_head *llist,}
\DoxyCodeLine{175                                   \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{176 \{}
\DoxyCodeLine{177         \textcolor{keyword}{struct }llist\_head *first = llist-\/>next;}
\DoxyCodeLine{178         \textcolor{keyword}{struct }llist\_head *last = llist-\/>prev;}
\DoxyCodeLine{179         \textcolor{keyword}{struct }llist\_head *at = head-\/>next;}
\DoxyCodeLine{180 }
\DoxyCodeLine{181         first-\/>prev = head;}
\DoxyCodeLine{182         head-\/>next = first;}
\DoxyCodeLine{183 }
\DoxyCodeLine{184         last-\/>next = at;}
\DoxyCodeLine{185         at-\/>prev = last;}
\DoxyCodeLine{186 \}}
\DoxyCodeLine{187 }
\DoxyCodeLine{192 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_splice(\textcolor{keyword}{struct} llist\_head *llist, \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{193 \{}
\DoxyCodeLine{194         \textcolor{keywordflow}{if} (!llist\_empty(llist))}
\DoxyCodeLine{195                 \_\_llist\_splice(llist, head);}
\DoxyCodeLine{196 \}}
\DoxyCodeLine{197 }
\DoxyCodeLine{204 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} llist\_splice\_init(\textcolor{keyword}{struct} llist\_head *llist,}
\DoxyCodeLine{205                                      \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{206 \{}
\DoxyCodeLine{207         \textcolor{keywordflow}{if} (!llist\_empty(llist)) \{}
\DoxyCodeLine{208                 \_\_llist\_splice(llist, head);}
\DoxyCodeLine{209                 INIT\_LLIST\_HEAD(llist);}
\DoxyCodeLine{210         \}}
\DoxyCodeLine{211 \}}
\DoxyCodeLine{212 }
\DoxyCodeLine{218 \textcolor{preprocessor}{\#define llist\_entry(ptr, type, member) \(\backslash\)}}
\DoxyCodeLine{219 \textcolor{preprocessor}{        container\_of(ptr, type, member)}}
\DoxyCodeLine{220 }
\DoxyCodeLine{228 \textcolor{preprocessor}{\#define llist\_first\_entry(ptr, type, member) \(\backslash\)}}
\DoxyCodeLine{229 \textcolor{preprocessor}{        llist\_entry((ptr)-\/>next, type, member)}}
\DoxyCodeLine{230 }
\DoxyCodeLine{238 \textcolor{preprocessor}{\#define llist\_last\_entry(ptr, type, member) \(\backslash\)}}
\DoxyCodeLine{239 \textcolor{preprocessor}{        llist\_entry((ptr)-\/>prev, type, member)}}
\DoxyCodeLine{240 }
\DoxyCodeLine{245 \textcolor{preprocessor}{\#define llist\_last(head) (head)-\/>prev}}
\DoxyCodeLine{246 }
\DoxyCodeLine{254 \textcolor{preprocessor}{\#define llist\_first\_entry\_or\_null(ptr, type, member) \(\backslash\)}}
\DoxyCodeLine{255 \textcolor{preprocessor}{        (!llist\_empty(ptr) ? llist\_first\_entry(ptr, type, member) : NULL)}}
\DoxyCodeLine{256 }
\DoxyCodeLine{264 \textcolor{preprocessor}{\#define llist\_last\_entry\_or\_null(ptr, type, member) \(\backslash\)}}
\DoxyCodeLine{265 \textcolor{preprocessor}{        (!llist\_empty(ptr) ? llist\_last\_entry(ptr, type, member) : NULL)}}
\DoxyCodeLine{266 }
\DoxyCodeLine{271 \textcolor{preprocessor}{\#define llist\_for\_each(pos, head) \(\backslash\)}}
\DoxyCodeLine{272 \textcolor{preprocessor}{        for (pos = (head)-\/>next, prefetch(pos-\/>next); pos != (head); \(\backslash\)}}
\DoxyCodeLine{273 \textcolor{preprocessor}{                pos = pos-\/>next, prefetch(pos-\/>next))}}
\DoxyCodeLine{274 }
\DoxyCodeLine{284 \textcolor{preprocessor}{\#define \_\_llist\_for\_each(pos, head) \(\backslash\)}}
\DoxyCodeLine{285 \textcolor{preprocessor}{        for (pos = (head)-\/>next; pos != (head); pos = pos-\/>next)}}
\DoxyCodeLine{286 }
\DoxyCodeLine{291 \textcolor{preprocessor}{\#define llist\_for\_each\_prev(pos, head) \(\backslash\)}}
\DoxyCodeLine{292 \textcolor{preprocessor}{        for (pos = (head)-\/>prev, prefetch(pos-\/>prev); pos != (head); \(\backslash\)}}
\DoxyCodeLine{293 \textcolor{preprocessor}{                pos = pos-\/>prev, prefetch(pos-\/>prev))}}
\DoxyCodeLine{294 }
\DoxyCodeLine{300 \textcolor{preprocessor}{\#define llist\_for\_each\_safe(pos, n, head) \(\backslash\)}}
\DoxyCodeLine{301 \textcolor{preprocessor}{        for (pos = (head)-\/>next, n = pos-\/>next; pos != (head); \(\backslash\)}}
\DoxyCodeLine{302 \textcolor{preprocessor}{                pos = n, n = pos-\/>next)}}
\DoxyCodeLine{303 }
\DoxyCodeLine{309 \textcolor{preprocessor}{\#define llist\_for\_each\_entry(pos, head, member)                         \(\backslash\)}}
\DoxyCodeLine{310 \textcolor{preprocessor}{        for (pos = llist\_entry((head)-\/>next, typeof(*pos), member),     \(\backslash\)}}
\DoxyCodeLine{311 \textcolor{preprocessor}{                     prefetch(pos-\/>member.next);                        \(\backslash\)}}
\DoxyCodeLine{312 \textcolor{preprocessor}{             \&pos-\/>member != (head);                                    \(\backslash\)}}
\DoxyCodeLine{313 \textcolor{preprocessor}{             pos = llist\_entry(pos-\/>member.next, typeof(*pos), member), \(\backslash\)}}
\DoxyCodeLine{314 \textcolor{preprocessor}{                     prefetch(pos-\/>member.next))}}
\DoxyCodeLine{315 }
\DoxyCodeLine{321 \textcolor{preprocessor}{\#define llist\_for\_each\_entry\_reverse(pos, head, member)                 \(\backslash\)}}
\DoxyCodeLine{322 \textcolor{preprocessor}{        for (pos = llist\_entry((head)-\/>prev, typeof(*pos), member),     \(\backslash\)}}
\DoxyCodeLine{323 \textcolor{preprocessor}{                     prefetch(pos-\/>member.prev);                        \(\backslash\)}}
\DoxyCodeLine{324 \textcolor{preprocessor}{             \&pos-\/>member != (head);                                    \(\backslash\)}}
\DoxyCodeLine{325 \textcolor{preprocessor}{             pos = llist\_entry(pos-\/>member.prev, typeof(*pos), member), \(\backslash\)}}
\DoxyCodeLine{326 \textcolor{preprocessor}{                     prefetch(pos-\/>member.prev))}}
\DoxyCodeLine{327 }
\DoxyCodeLine{334 \textcolor{preprocessor}{\#define llist\_for\_each\_entry\_continue(pos, head, member)                \(\backslash\)}}
\DoxyCodeLine{335 \textcolor{preprocessor}{        for (pos = llist\_entry(pos-\/>member.next, typeof(*pos), member), \(\backslash\)}}
\DoxyCodeLine{336 \textcolor{preprocessor}{                     prefetch(pos-\/>member.next);                        \(\backslash\)}}
\DoxyCodeLine{337 \textcolor{preprocessor}{             \&pos-\/>member != (head);                                    \(\backslash\)}}
\DoxyCodeLine{338 \textcolor{preprocessor}{             pos = llist\_entry(pos-\/>member.next, typeof(*pos), member), \(\backslash\)}}
\DoxyCodeLine{339 \textcolor{preprocessor}{                     prefetch(pos-\/>member.next))}}
\DoxyCodeLine{340 }
\DoxyCodeLine{347 \textcolor{preprocessor}{\#define llist\_for\_each\_entry\_safe(pos, n, head, member)                 \(\backslash\)}}
\DoxyCodeLine{348 \textcolor{preprocessor}{        for (pos = llist\_entry((head)-\/>next, typeof(*pos), member),     \(\backslash\)}}
\DoxyCodeLine{349 \textcolor{preprocessor}{                n = llist\_entry(pos-\/>member.next, typeof(*pos), member);        \(\backslash\)}}
\DoxyCodeLine{350 \textcolor{preprocessor}{             \&pos-\/>member != (head);                                    \(\backslash\)}}
\DoxyCodeLine{351 \textcolor{preprocessor}{             pos = n, n = llist\_entry(n-\/>member.next, typeof(*n), member))}}
\DoxyCodeLine{352 }
\DoxyCodeLine{357 \textcolor{preprocessor}{\#define llist\_for\_each\_rcu(pos, head) \(\backslash\)}}
\DoxyCodeLine{358 \textcolor{preprocessor}{        for (pos = (head)-\/>next, prefetch(pos-\/>next); pos != (head); \(\backslash\)}}
\DoxyCodeLine{359 \textcolor{preprocessor}{                pos = pos-\/>next, (\{ smp\_read\_barrier\_depends(); 0;\}), prefetch(pos-\/>next))}}
\DoxyCodeLine{360 }
\DoxyCodeLine{361 \textcolor{preprocessor}{\#define \_\_llist\_for\_each\_rcu(pos, head) \(\backslash\)}}
\DoxyCodeLine{362 \textcolor{preprocessor}{        for (pos = (head)-\/>next; pos != (head); \(\backslash\)}}
\DoxyCodeLine{363 \textcolor{preprocessor}{                pos = pos-\/>next, (\{ smp\_read\_barrier\_depends(); 0;\}))}}
\DoxyCodeLine{364 }
\DoxyCodeLine{370 \textcolor{preprocessor}{\#define llist\_for\_each\_safe\_rcu(pos, n, head) \(\backslash\)}}
\DoxyCodeLine{371 \textcolor{preprocessor}{        for (pos = (head)-\/>next, n = pos-\/>next; pos != (head); \(\backslash\)}}
\DoxyCodeLine{372 \textcolor{preprocessor}{                pos = n, (\{ smp\_read\_barrier\_depends(); 0;\}), n = pos-\/>next)}}
\DoxyCodeLine{373 }
\DoxyCodeLine{379 \textcolor{preprocessor}{\#define llist\_for\_each\_entry\_rcu(pos, head, member)                     \(\backslash\)}}
\DoxyCodeLine{380 \textcolor{preprocessor}{        for (pos = llist\_entry((head)-\/>next, typeof(*pos), member),     \(\backslash\)}}
\DoxyCodeLine{381 \textcolor{preprocessor}{                     prefetch(pos-\/>member.next);                        \(\backslash\)}}
\DoxyCodeLine{382 \textcolor{preprocessor}{             \&pos-\/>member != (head);                                    \(\backslash\)}}
\DoxyCodeLine{383 \textcolor{preprocessor}{             pos = llist\_entry(pos-\/>member.next, typeof(*pos), member), \(\backslash\)}}
\DoxyCodeLine{384 \textcolor{preprocessor}{                     (\{ smp\_read\_barrier\_depends(); 0;\}),               \(\backslash\)}}
\DoxyCodeLine{385 \textcolor{preprocessor}{                     prefetch(pos-\/>member.next))}}
\DoxyCodeLine{386 }
\DoxyCodeLine{387 }
\DoxyCodeLine{392 \textcolor{preprocessor}{\#define llist\_for\_each\_continue\_rcu(pos, head) \(\backslash\)}}
\DoxyCodeLine{393 \textcolor{preprocessor}{        for ((pos) = (pos)-\/>next, prefetch((pos)-\/>next); (pos) != (head); \(\backslash\)}}
\DoxyCodeLine{394 \textcolor{preprocessor}{                (pos) = (pos)-\/>next, (\{ smp\_read\_barrier\_depends(); 0;\}), prefetch((pos)-\/>next))}}
\DoxyCodeLine{395 }
\DoxyCodeLine{403 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} llist\_count(\textcolor{keyword}{const} \textcolor{keyword}{struct} llist\_head *head)}
\DoxyCodeLine{404 \{}
\DoxyCodeLine{405         \textcolor{keyword}{struct }llist\_head *entry;}
\DoxyCodeLine{406         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i = 0;}
\DoxyCodeLine{407         llist\_for\_each(entry, head)}
\DoxyCodeLine{408                 i++;}
\DoxyCodeLine{409         \textcolor{keywordflow}{return} i;}
\DoxyCodeLine{410 \}}
\DoxyCodeLine{411 }
\DoxyCodeLine{412 }
\DoxyCodeLine{413 }
\DoxyCodeLine{420 \textcolor{keyword}{struct }hlist\_head \{}
\DoxyCodeLine{421         \textcolor{keyword}{struct }hlist\_node *first;}
\DoxyCodeLine{422 \};}
\DoxyCodeLine{423 }
\DoxyCodeLine{424 \textcolor{keyword}{struct }hlist\_node \{}
\DoxyCodeLine{425         \textcolor{keyword}{struct }hlist\_node *next, **pprev;}
\DoxyCodeLine{426 \};}
\DoxyCodeLine{427 }
\DoxyCodeLine{428 \textcolor{preprocessor}{\#define HLIST\_HEAD\_INIT \{ .first = NULL \}}}
\DoxyCodeLine{429 \textcolor{preprocessor}{\#define HLIST\_HEAD(name) struct hlist\_head name = \{  .first = NULL \}}}
\DoxyCodeLine{430 \textcolor{preprocessor}{\#define INIT\_HLIST\_HEAD(ptr) ((ptr)-\/>first = NULL)}}
\DoxyCodeLine{431 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} INIT\_HLIST\_NODE(\textcolor{keyword}{struct} hlist\_node *h)}
\DoxyCodeLine{432 \{}
\DoxyCodeLine{433         h-\/>next = NULL;}
\DoxyCodeLine{434         h-\/>pprev = NULL;}
\DoxyCodeLine{435 \}}
\DoxyCodeLine{436 }
\DoxyCodeLine{437 \textcolor{preprocessor}{\#define READ\_ONCE(x)    x}}
\DoxyCodeLine{438 \textcolor{preprocessor}{\#define WRITE\_ONCE(a, b) a = b}}
\DoxyCodeLine{439 }
\DoxyCodeLine{448 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} hlist\_unhashed(\textcolor{keyword}{const} \textcolor{keyword}{struct} hlist\_node *h)}
\DoxyCodeLine{449 \{}
\DoxyCodeLine{450         \textcolor{keywordflow}{return} !h-\/>pprev;}
\DoxyCodeLine{451 \}}
\DoxyCodeLine{452 }
\DoxyCodeLine{461 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} hlist\_unhashed\_lockless(\textcolor{keyword}{const} \textcolor{keyword}{struct} hlist\_node *h)}
\DoxyCodeLine{462 \{}
\DoxyCodeLine{463         \textcolor{keywordflow}{return} !READ\_ONCE(h-\/>pprev);}
\DoxyCodeLine{464 \}}
\DoxyCodeLine{465 }
\DoxyCodeLine{470 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} hlist\_empty(\textcolor{keyword}{const} \textcolor{keyword}{struct} hlist\_head *h)}
\DoxyCodeLine{471 \{}
\DoxyCodeLine{472         \textcolor{keywordflow}{return} !READ\_ONCE(h-\/>first);}
\DoxyCodeLine{473 \}}
\DoxyCodeLine{474 }
\DoxyCodeLine{475 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} \_\_hlist\_del(\textcolor{keyword}{struct} hlist\_node *n)}
\DoxyCodeLine{476 \{}
\DoxyCodeLine{477         \textcolor{keyword}{struct }hlist\_node *next = n-\/>next;}
\DoxyCodeLine{478         \textcolor{keyword}{struct }hlist\_node **pprev = n-\/>pprev;}
\DoxyCodeLine{479 }
\DoxyCodeLine{480         WRITE\_ONCE(*pprev, next);}
\DoxyCodeLine{481         \textcolor{keywordflow}{if} (next)}
\DoxyCodeLine{482                 WRITE\_ONCE(next-\/>pprev, pprev);}
\DoxyCodeLine{483 \}}
\DoxyCodeLine{484 }
\DoxyCodeLine{491 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} hlist\_del(\textcolor{keyword}{struct} hlist\_node *n)}
\DoxyCodeLine{492 \{}
\DoxyCodeLine{493         \_\_hlist\_del(n);}
\DoxyCodeLine{494         n-\/>next = (\textcolor{keyword}{struct }hlist\_node *)LLIST\_POISON1;}
\DoxyCodeLine{495         n-\/>pprev = (\textcolor{keyword}{struct }hlist\_node **)LLIST\_POISON2;}
\DoxyCodeLine{496 \}}
\DoxyCodeLine{497 }
\DoxyCodeLine{503 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} hlist\_del\_init(\textcolor{keyword}{struct} hlist\_node *n)}
\DoxyCodeLine{504 \{}
\DoxyCodeLine{505         \textcolor{keywordflow}{if} (!hlist\_unhashed(n)) \{}
\DoxyCodeLine{506                 \_\_hlist\_del(n);}
\DoxyCodeLine{507                 INIT\_HLIST\_NODE(n);}
\DoxyCodeLine{508         \}}
\DoxyCodeLine{509 \}}
\DoxyCodeLine{510 }
\DoxyCodeLine{518 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} hlist\_add\_head(\textcolor{keyword}{struct} hlist\_node *n, \textcolor{keyword}{struct} hlist\_head *h)}
\DoxyCodeLine{519 \{}
\DoxyCodeLine{520         \textcolor{keyword}{struct }hlist\_node *first = h-\/>first;}
\DoxyCodeLine{521         WRITE\_ONCE(n-\/>next, first);}
\DoxyCodeLine{522         \textcolor{keywordflow}{if} (first)}
\DoxyCodeLine{523                 WRITE\_ONCE(first-\/>pprev, \&n-\/>next);}
\DoxyCodeLine{524         WRITE\_ONCE(h-\/>first, n);}
\DoxyCodeLine{525         WRITE\_ONCE(n-\/>pprev, \&h-\/>first);}
\DoxyCodeLine{526 \}}
\DoxyCodeLine{527 }
\DoxyCodeLine{532 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} hlist\_add\_before(\textcolor{keyword}{struct} hlist\_node *n,}
\DoxyCodeLine{533                                     \textcolor{keyword}{struct} hlist\_node *next)}
\DoxyCodeLine{534 \{}
\DoxyCodeLine{535         WRITE\_ONCE(n-\/>pprev, next-\/>pprev);}
\DoxyCodeLine{536         WRITE\_ONCE(n-\/>next, next);}
\DoxyCodeLine{537         WRITE\_ONCE(next-\/>pprev, \&n-\/>next);}
\DoxyCodeLine{538         WRITE\_ONCE(*(n-\/>pprev), n);}
\DoxyCodeLine{539 \}}
\DoxyCodeLine{540 }
\DoxyCodeLine{545 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} hlist\_add\_behind(\textcolor{keyword}{struct} hlist\_node *n,}
\DoxyCodeLine{546                                     \textcolor{keyword}{struct} hlist\_node *prev)}
\DoxyCodeLine{547 \{}
\DoxyCodeLine{548         WRITE\_ONCE(n-\/>next, prev-\/>next);}
\DoxyCodeLine{549         WRITE\_ONCE(prev-\/>next, n);}
\DoxyCodeLine{550         WRITE\_ONCE(n-\/>pprev, \&prev-\/>next);}
\DoxyCodeLine{551 }
\DoxyCodeLine{552         \textcolor{keywordflow}{if} (n-\/>next)}
\DoxyCodeLine{553                 WRITE\_ONCE(n-\/>next-\/>pprev, \&n-\/>next);}
\DoxyCodeLine{554 \}}
\DoxyCodeLine{555 }
\DoxyCodeLine{563 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} hlist\_add\_fake(\textcolor{keyword}{struct} hlist\_node *n)}
\DoxyCodeLine{564 \{}
\DoxyCodeLine{565         n-\/>pprev = \&n-\/>next;}
\DoxyCodeLine{566 \}}
\DoxyCodeLine{567 }
\DoxyCodeLine{571 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{bool} hlist\_fake(\textcolor{keyword}{struct} hlist\_node *h)}
\DoxyCodeLine{572 \{}
\DoxyCodeLine{573         \textcolor{keywordflow}{return} h-\/>pprev == \&h-\/>next;}
\DoxyCodeLine{574 \}}
\DoxyCodeLine{575 }
\DoxyCodeLine{583 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{bool}}
\DoxyCodeLine{584 hlist\_is\_singular\_node(\textcolor{keyword}{struct} hlist\_node *n, \textcolor{keyword}{struct} hlist\_head *h)}
\DoxyCodeLine{585 \{}
\DoxyCodeLine{586         \textcolor{keywordflow}{return} !n-\/>next \&\& n-\/>pprev == \&h-\/>first;}
\DoxyCodeLine{587 \}}
\DoxyCodeLine{588 }
\DoxyCodeLine{596 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} hlist\_move\_list(\textcolor{keyword}{struct} hlist\_head *old,}
\DoxyCodeLine{597                                    \textcolor{keyword}{struct} hlist\_head *\_new)}
\DoxyCodeLine{598 \{}
\DoxyCodeLine{599         \_new-\/>first = old-\/>first;}
\DoxyCodeLine{600         \textcolor{keywordflow}{if} (\_new-\/>first)}
\DoxyCodeLine{601                 \_new-\/>first-\/>pprev = \&\_new-\/>first;}
\DoxyCodeLine{602         old-\/>first = NULL;}
\DoxyCodeLine{603 \}}
\DoxyCodeLine{604 }
\DoxyCodeLine{605 \textcolor{preprocessor}{\#define hlist\_entry(ptr, type, member) container\_of(ptr,type,member)}}
\DoxyCodeLine{606 }
\DoxyCodeLine{607 \textcolor{preprocessor}{\#define hlist\_for\_each(pos, head) \(\backslash\)}}
\DoxyCodeLine{608 \textcolor{preprocessor}{        for (pos = (head)-\/>first; pos ; pos = pos-\/>next)}}
\DoxyCodeLine{609 }
\DoxyCodeLine{610 \textcolor{preprocessor}{\#define hlist\_for\_each\_safe(pos, n, head) \(\backslash\)}}
\DoxyCodeLine{611 \textcolor{preprocessor}{        for (pos = (head)-\/>first; pos \&\& (\{ n = pos-\/>next; 1; \}); \(\backslash\)}}
\DoxyCodeLine{612 \textcolor{preprocessor}{             pos = n)}}
\DoxyCodeLine{613 }
\DoxyCodeLine{614 \textcolor{preprocessor}{\#define hlist\_entry\_safe(ptr, type, member) \(\backslash\)}}
\DoxyCodeLine{615 \textcolor{preprocessor}{        (\{ typeof(ptr) \_\_\_\_ptr = (ptr); \(\backslash\)}}
\DoxyCodeLine{616 \textcolor{preprocessor}{           \_\_\_\_ptr ? hlist\_entry(\_\_\_\_ptr, type, member) : NULL; \(\backslash\)}}
\DoxyCodeLine{617 \textcolor{preprocessor}{        \})}}
\DoxyCodeLine{618 }
\DoxyCodeLine{624 \textcolor{preprocessor}{\#define hlist\_for\_each\_entry(pos, head, member)                         \(\backslash\)}}
\DoxyCodeLine{625 \textcolor{preprocessor}{        for (pos = hlist\_entry\_safe((head)-\/>first, typeof(*(pos)), member);\(\backslash\)}}
\DoxyCodeLine{626 \textcolor{preprocessor}{             pos;                                                       \(\backslash\)}}
\DoxyCodeLine{627 \textcolor{preprocessor}{             pos = hlist\_entry\_safe((pos)-\/>member.next, typeof(*(pos)), member))}}
\DoxyCodeLine{628 }
\DoxyCodeLine{633 \textcolor{preprocessor}{\#define hlist\_for\_each\_entry\_continue(pos, member)                      \(\backslash\)}}
\DoxyCodeLine{634 \textcolor{preprocessor}{        for (pos = hlist\_entry\_safe((pos)-\/>member.next, typeof(*(pos)), member);\(\backslash\)}}
\DoxyCodeLine{635 \textcolor{preprocessor}{             pos;                                                       \(\backslash\)}}
\DoxyCodeLine{636 \textcolor{preprocessor}{             pos = hlist\_entry\_safe((pos)-\/>member.next, typeof(*(pos)), member))}}
\DoxyCodeLine{637 }
\DoxyCodeLine{642 \textcolor{preprocessor}{\#define hlist\_for\_each\_entry\_from(pos, member)                          \(\backslash\)}}
\DoxyCodeLine{643 \textcolor{preprocessor}{        for (; pos;                                                     \(\backslash\)}}
\DoxyCodeLine{644 \textcolor{preprocessor}{             pos = hlist\_entry\_safe((pos)-\/>member.next, typeof(*(pos)), member))}}
\DoxyCodeLine{645 }
\DoxyCodeLine{652 \textcolor{preprocessor}{\#define hlist\_for\_each\_entry\_safe(pos, n, head, member)                 \(\backslash\)}}
\DoxyCodeLine{653 \textcolor{preprocessor}{        for (pos = hlist\_entry\_safe((head)-\/>first, typeof(*pos), member);\(\backslash\)}}
\DoxyCodeLine{654 \textcolor{preprocessor}{             pos \&\& (\{ n = pos-\/>member.next; 1; \});                     \(\backslash\)}}
\DoxyCodeLine{655 \textcolor{preprocessor}{             pos = hlist\_entry\_safe(n, typeof(*pos), member))}}
\DoxyCodeLine{656 }
\DoxyCodeLine{657 }

\end{DoxyCode}
