Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/queue.h
Context not available. | |||||
* | * | ||||
* SLIST LIST STAILQ TAILQ | * SLIST LIST STAILQ TAILQ | ||||
* _HEAD + + + + | * _HEAD + + + + | ||||
* _CLASS_HEAD + + + + | |||||
* _HEAD_INITIALIZER + + + + | * _HEAD_INITIALIZER + + + + | ||||
* _ENTRY + + + + | * _ENTRY + + + + | ||||
* _CLASS_ENTRY + + + + | |||||
* _INIT + + + + | * _INIT + + + + | ||||
* _EMPTY + + + + | * _EMPTY + + + + | ||||
* _FIRST + + + + | * _FIRST + + + + | ||||
Context not available. | |||||
struct type *slh_first; /* first element */ \ | struct type *slh_first; /* first element */ \ | ||||
} | } | ||||
#define SLIST_CLASS_HEAD(name, type) \ | |||||
imp: Why is this needed? Class and struct are the same thing in C++, with the definition controlling… | |||||
Not Done Inline ActionsTechnically it is not needed, except these macros should only be used with classes, and that makes the compiler warn. hselasky: Technically it is not needed, except these macros should only be used with classes, and that… | |||||
struct name { \ | |||||
class type *slh_first; /* first element */ \ | |||||
} | |||||
#define SLIST_HEAD_INITIALIZER(head) \ | #define SLIST_HEAD_INITIALIZER(head) \ | ||||
{ NULL } | { NULL } | ||||
Context not available. | |||||
struct type *sle_next; /* next element */ \ | struct type *sle_next; /* next element */ \ | ||||
} | } | ||||
Not Done Inline ActionsAlmost every occurrence of "struct type" needs to be changed to use QUEUE_TYPEOF. See D2767. vangyzen: Almost every occurrence of "struct type" needs to be changed to use QUEUE_TYPEOF. See [[ https… | |||||
Not Done Inline ActionsRight - fixed. hselasky: Right - fixed. | |||||
#define SLIST_CLASS_ENTRY(type) \ | |||||
struct { \ | |||||
class type *sle_next; /* next element */ \ | |||||
} | |||||
/* | /* | ||||
* Singly-linked List functions. | * Singly-linked List functions. | ||||
*/ | */ | ||||
Context not available. | |||||
SLIST_REMOVE_HEAD((head), field); \ | SLIST_REMOVE_HEAD((head), field); \ | ||||
} \ | } \ | ||||
else { \ | else { \ | ||||
struct type *curelm = SLIST_FIRST((head)); \ | __typeof(SLIST_FIRST(head)) curelm = SLIST_FIRST(head); \ | ||||
Not Done Inline Actions__typeof doesn't work on older compilers. Bde will give you 10k words on this if you commit it. imp: __typeof doesn't work on older compilers. Bde will give you 10k words on this if you commit it. | |||||
Not Done Inline ActionsI see. I'll update the patch to not use typeof, but instead inline the missing structure parts. Else it won't work with extern "C" like said before. hselasky: I see. I'll update the patch to not use typeof, but instead inline the missing structure parts. | |||||
while (SLIST_NEXT(curelm, field) != (elm)) \ | while (SLIST_NEXT(curelm, field) != (elm)) \ | ||||
curelm = SLIST_NEXT(curelm, field); \ | curelm = SLIST_NEXT(curelm, field); \ | ||||
SLIST_REMOVE_AFTER(curelm, field); \ | SLIST_REMOVE_AFTER(curelm, field); \ | ||||
Context not available. | |||||
} while (0) | } while (0) | ||||
#define SLIST_SWAP(head1, head2, type) do { \ | #define SLIST_SWAP(head1, head2, type) do { \ | ||||
struct type *swap_first = SLIST_FIRST(head1); \ | __typeof(SLIST_FIRST(head1)) swap_first = SLIST_FIRST(head1); \ | ||||
SLIST_FIRST(head1) = SLIST_FIRST(head2); \ | SLIST_FIRST(head1) = SLIST_FIRST(head2); \ | ||||
SLIST_FIRST(head2) = swap_first; \ | SLIST_FIRST(head2) = swap_first; \ | ||||
} while (0) | } while (0) | ||||
Context not available. | |||||
struct type **stqh_last;/* addr of last next element */ \ | struct type **stqh_last;/* addr of last next element */ \ | ||||
} | } | ||||
#define STAILQ_CLASS_HEAD(name, type) \ | |||||
struct name { \ | |||||
class type *stqh_first;/* first element */ \ | |||||
class type **stqh_last;/* addr of last next element */ \ | |||||
} | |||||
#define STAILQ_HEAD_INITIALIZER(head) \ | #define STAILQ_HEAD_INITIALIZER(head) \ | ||||
{ NULL, &(head).stqh_first } | { NULL, &(head).stqh_first } | ||||
Context not available. | |||||
struct type *stqe_next; /* next element */ \ | struct type *stqe_next; /* next element */ \ | ||||
} | } | ||||
#define STAILQ_CLASS_ENTRY(type) \ | |||||
struct { \ | |||||
class type *stqe_next; /* next element */ \ | |||||
} | |||||
/* | /* | ||||
* Singly-linked Tail queue functions. | * Singly-linked Tail queue functions. | ||||
*/ | */ | ||||
Context not available. | |||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ | (head)->stqh_last = &STAILQ_NEXT((elm), field); \ | ||||
} while (0) | } while (0) | ||||
#define STAILQ_LAST(head, type, field) \ | #define STAILQ_LAST(head, type, field) \ | ||||
(STAILQ_EMPTY((head)) ? NULL : \ | (STAILQ_EMPTY((head)) ? NULL : \ | ||||
__containerof((head)->stqh_last, struct type, field.stqe_next)) | __containerof((head)->stqh_last, \ | ||||
__typeof(*STAILQ_FIRST(head)), field.stqe_next)) | |||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) | #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) | ||||
Context not available. | |||||
STAILQ_REMOVE_HEAD((head), field); \ | STAILQ_REMOVE_HEAD((head), field); \ | ||||
} \ | } \ | ||||
else { \ | else { \ | ||||
struct type *curelm = STAILQ_FIRST((head)); \ | __typeof(STAILQ_FIRST(head)) curelm = \ | ||||
STAILQ_FIRST(head); \ | |||||
while (STAILQ_NEXT(curelm, field) != (elm)) \ | while (STAILQ_NEXT(curelm, field) != (elm)) \ | ||||
curelm = STAILQ_NEXT(curelm, field); \ | curelm = STAILQ_NEXT(curelm, field); \ | ||||
STAILQ_REMOVE_AFTER(head, curelm, field); \ | STAILQ_REMOVE_AFTER(head, curelm, field); \ | ||||
Context not available. | |||||
} while (0) | } while (0) | ||||
#define STAILQ_SWAP(head1, head2, type) do { \ | #define STAILQ_SWAP(head1, head2, type) do { \ | ||||
struct type *swap_first = STAILQ_FIRST(head1); \ | __typeof(STAILQ_FIRST(head1)) swap_first = STAILQ_FIRST(head1); \ | ||||
struct type **swap_last = (head1)->stqh_last; \ | __typeof((head1)->stqh_last) swap_last = (head1)->stqh_last; \ | ||||
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ | STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ | ||||
(head1)->stqh_last = (head2)->stqh_last; \ | (head1)->stqh_last = (head2)->stqh_last; \ | ||||
STAILQ_FIRST(head2) = swap_first; \ | STAILQ_FIRST(head2) = swap_first; \ | ||||
Context not available. | |||||
struct type *lh_first; /* first element */ \ | struct type *lh_first; /* first element */ \ | ||||
} | } | ||||
#define LIST_CLASS_HEAD(name, type) \ | |||||
struct name { \ | |||||
class type *lh_first; /* first element */ \ | |||||
} | |||||
#define LIST_HEAD_INITIALIZER(head) \ | #define LIST_HEAD_INITIALIZER(head) \ | ||||
{ NULL } | { NULL } | ||||
Context not available. | |||||
struct type **le_prev; /* address of previous next element */ \ | struct type **le_prev; /* address of previous next element */ \ | ||||
} | } | ||||
#define LIST_CLASS_ENTRY(type) \ | |||||
struct { \ | |||||
class type *le_next; /* next element */ \ | |||||
class type **le_prev; /* address of previous next element */ \ | |||||
} | |||||
/* | /* | ||||
* List functions. | * List functions. | ||||
*/ | */ | ||||
Context not available. | |||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next) | #define LIST_NEXT(elm, field) ((elm)->field.le_next) | ||||
#define LIST_PREV(elm, head, type, field) \ | #define LIST_PREV(elm, head, type, field) \ | ||||
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ | ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ | ||||
__containerof((elm)->field.le_prev, struct type, field.le_next)) | __containerof((elm)->field.le_prev, \ | ||||
__typeof(*LIST_FIRST(head)), field.le_next)) | |||||
#define LIST_REMOVE(elm, field) do { \ | #define LIST_REMOVE(elm, field) do { \ | ||||
QMD_SAVELINK(oldnext, (elm)->field.le_next); \ | QMD_SAVELINK(oldnext, (elm)->field.le_next); \ | ||||
Context not available. | |||||
} while (0) | } while (0) | ||||
#define LIST_SWAP(head1, head2, type, field) do { \ | #define LIST_SWAP(head1, head2, type, field) do { \ | ||||
struct type *swap_tmp = LIST_FIRST((head1)); \ | __typeof(LIST_FIRST(head1)) swap_tmp = LIST_FIRST(head1); \ | ||||
LIST_FIRST((head1)) = LIST_FIRST((head2)); \ | LIST_FIRST((head1)) = LIST_FIRST((head2)); \ | ||||
LIST_FIRST((head2)) = swap_tmp; \ | LIST_FIRST((head2)) = swap_tmp; \ | ||||
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ | if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ | ||||
Context not available. | |||||
TRACEBUF \ | TRACEBUF \ | ||||
} | } | ||||
#define TAILQ_CLASS_HEAD(name, type) \ | |||||
struct name { \ | |||||
class type *tqh_first; /* first element */ \ | |||||
class type **tqh_last; /* addr of last next element */ \ | |||||
TRACEBUF \ | |||||
} | |||||
#define TAILQ_HEAD_INITIALIZER(head) \ | #define TAILQ_HEAD_INITIALIZER(head) \ | ||||
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } | { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } | ||||
Context not available. | |||||
TRACEBUF \ | TRACEBUF \ | ||||
} | } | ||||
#define TAILQ_CLASS_ENTRY(type) \ | |||||
struct { \ | |||||
class type *tqe_next; /* next element */ \ | |||||
class type **tqe_prev; /* address of previous next element */ \ | |||||
TRACEBUF \ | |||||
} | |||||
/* | /* | ||||
* Tail queue functions. | * Tail queue functions. | ||||
*/ | */ | ||||
Not Done Inline Actions#undef QUEUE_TYPEOF to avoid namespace pollution. vangyzen: ```
#undef QUEUE_TYPEOF
```
to avoid namespace pollution. | |||||
Not Done Inline ActionsIt needs to be there, else the code won't compile when the macros refer QUEUE_TYPEOF(). hselasky: It needs to be there, else the code won't compile when the macros refer QUEUE_TYPEOF(). | |||||
Context not available. | |||||
} while (0) | } while (0) | ||||
#define TAILQ_SWAP(head1, head2, type, field) do { \ | #define TAILQ_SWAP(head1, head2, type, field) do { \ | ||||
struct type *swap_first = (head1)->tqh_first; \ | __typeof((head1)->tqh_first) swap_first = (head1)->tqh_first; \ | ||||
struct type **swap_last = (head1)->tqh_last; \ | __typeof((head1)->tqh_last) swap_last = (head1)->tqh_last; \ | ||||
(head1)->tqh_first = (head2)->tqh_first; \ | (head1)->tqh_first = (head2)->tqh_first; \ | ||||
(head1)->tqh_last = (head2)->tqh_last; \ | (head1)->tqh_last = (head2)->tqh_last; \ | ||||
(head2)->tqh_first = swap_first; \ | (head2)->tqh_first = swap_first; \ | ||||
Context not available. |
Why is this needed? Class and struct are the same thing in C++, with the definition controlling whether the members are public by default or not.