Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/queue.h
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* SLIST LIST STAILQ TAILQ | * SLIST LIST STAILQ TAILQ | ||||
* _HEAD + + + + | * _HEAD + + + + | ||||
* _CLASS_HEAD + + + + | * _CLASS_HEAD + + + + | ||||
* _HEAD_INITIALIZER + + + + | * _HEAD_INITIALIZER + + + + | ||||
* _ENTRY + + + + | * _ENTRY + + + + | ||||
* _CLASS_ENTRY + + + + | * _CLASS_ENTRY + + + + | ||||
* _INIT + + + + | * _INIT + + + + | ||||
* _EMPTY + + + + | * _EMPTY + + + + | ||||
jhb: Should perhaps add an _END entry into this table? | |||||
* _FIRST + + + + | * _FIRST + + + + | ||||
* _NEXT + + + + | * _NEXT + + + + | ||||
* _PREV - + - + | * _PREV - + - + | ||||
* _LAST - - + + | * _LAST - - + + | ||||
* _LAST_FAST - - - + | * _LAST_FAST - - - + | ||||
* _FOREACH + + + + | * _FOREACH + + + + | ||||
* _FOREACH_FROM + + + + | * _FOREACH_FROM + + + + | ||||
* _FOREACH_SAFE + + + + | * _FOREACH_SAFE + + + + | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | |||||
} while (0) | } while (0) | ||||
#define SLIST_SWAP(head1, head2, type) do { \ | #define SLIST_SWAP(head1, head2, type) do { \ | ||||
QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \ | QUEUE_TYPEOF(type) *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) | ||||
#define SLIST_END(head) NULL | |||||
/* | /* | ||||
* Singly-linked Tail queue declarations. | * Singly-linked Tail queue declarations. | ||||
*/ | */ | ||||
#define STAILQ_HEAD(name, type) \ | #define STAILQ_HEAD(name, type) \ | ||||
struct name { \ | struct name { \ | ||||
struct type *stqh_first;/* first element */ \ | struct type *stqh_first;/* first element */ \ | ||||
struct type **stqh_last;/* addr of last next element */ \ | struct type **stqh_last;/* addr of last next element */ \ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | #define STAILQ_SWAP(head1, head2, type) do { \ | ||||
STAILQ_FIRST(head2) = swap_first; \ | STAILQ_FIRST(head2) = swap_first; \ | ||||
(head2)->stqh_last = swap_last; \ | (head2)->stqh_last = swap_last; \ | ||||
if (STAILQ_EMPTY(head1)) \ | if (STAILQ_EMPTY(head1)) \ | ||||
(head1)->stqh_last = &STAILQ_FIRST(head1); \ | (head1)->stqh_last = &STAILQ_FIRST(head1); \ | ||||
if (STAILQ_EMPTY(head2)) \ | if (STAILQ_EMPTY(head2)) \ | ||||
(head2)->stqh_last = &STAILQ_FIRST(head2); \ | (head2)->stqh_last = &STAILQ_FIRST(head2); \ | ||||
} while (0) | } while (0) | ||||
#define STAILQ_END(head) NULL | |||||
/* | /* | ||||
* List declarations. | * List declarations. | ||||
*/ | */ | ||||
#define LIST_HEAD(name, type) \ | #define LIST_HEAD(name, type) \ | ||||
struct name { \ | struct name { \ | ||||
struct type *lh_first; /* first element */ \ | struct type *lh_first; /* first element */ \ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | #define LIST_SWAP(head1, head2, type, field) do { \ | ||||
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) \ | ||||
swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ | swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ | ||||
if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ | if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ | ||||
swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ | swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ | ||||
} while (0) | } while (0) | ||||
#define LIST_END(head) NULL | |||||
/* | /* | ||||
* Tail queue declarations. | * Tail queue declarations. | ||||
*/ | */ | ||||
#define TAILQ_HEAD(name, type) \ | #define TAILQ_HEAD(name, type) \ | ||||
struct name { \ | struct name { \ | ||||
struct type *tqh_first; /* first element */ \ | struct type *tqh_first; /* first element */ \ | ||||
struct type **tqh_last; /* addr of last next element */ \ | struct type **tqh_last; /* addr of last next element */ \ | ||||
TRACEBUF \ | TRACEBUF \ | ||||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | if ((swap_first = (head1)->tqh_first) != NULL) \ | ||||
swap_first->field.tqe_prev = &(head1)->tqh_first; \ | swap_first->field.tqe_prev = &(head1)->tqh_first; \ | ||||
else \ | else \ | ||||
(head1)->tqh_last = &(head1)->tqh_first; \ | (head1)->tqh_last = &(head1)->tqh_first; \ | ||||
if ((swap_first = (head2)->tqh_first) != NULL) \ | if ((swap_first = (head2)->tqh_first) != NULL) \ | ||||
swap_first->field.tqe_prev = &(head2)->tqh_first; \ | swap_first->field.tqe_prev = &(head2)->tqh_first; \ | ||||
else \ | else \ | ||||
(head2)->tqh_last = &(head2)->tqh_first; \ | (head2)->tqh_last = &(head2)->tqh_first; \ | ||||
} while (0) | } while (0) | ||||
#define TAILQ_END(head) NULL | |||||
#endif /* !_SYS_QUEUE_H_ */ | #endif /* !_SYS_QUEUE_H_ */ |
Should perhaps add an _END entry into this table?