Changeset View
Changeset View
Standalone View
Standalone View
head/sys/sys/queue.h
Show First 20 Lines • Show All 466 Lines • ▼ Show 20 Lines | struct { \ | ||||
class type **le_prev; /* address of previous next element */ \ | class type **le_prev; /* address of previous next element */ \ | ||||
} | } | ||||
/* | /* | ||||
* List functions. | * List functions. | ||||
*/ | */ | ||||
#if (defined(_KERNEL) && defined(INVARIANTS)) | #if (defined(_KERNEL) && defined(INVARIANTS)) | ||||
/* | |||||
* QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME) | |||||
* | |||||
* If the list is non-empty, validates that the first element of the list | |||||
* points back at 'head.' | |||||
*/ | |||||
#define QMD_LIST_CHECK_HEAD(head, field) do { \ | #define QMD_LIST_CHECK_HEAD(head, field) do { \ | ||||
if (LIST_FIRST((head)) != NULL && \ | if (LIST_FIRST((head)) != NULL && \ | ||||
LIST_FIRST((head))->field.le_prev != \ | LIST_FIRST((head))->field.le_prev != \ | ||||
&LIST_FIRST((head))) \ | &LIST_FIRST((head))) \ | ||||
panic("Bad list head %p first->prev != head", (head)); \ | panic("Bad list head %p first->prev != head", (head)); \ | ||||
} while (0) | } while (0) | ||||
/* | |||||
* QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME) | |||||
* | |||||
* If an element follows 'elm' in the list, validates that the next element | |||||
* points back at 'elm.' | |||||
*/ | |||||
#define QMD_LIST_CHECK_NEXT(elm, field) do { \ | #define QMD_LIST_CHECK_NEXT(elm, field) do { \ | ||||
if (LIST_NEXT((elm), field) != NULL && \ | if (LIST_NEXT((elm), field) != NULL && \ | ||||
LIST_NEXT((elm), field)->field.le_prev != \ | LIST_NEXT((elm), field)->field.le_prev != \ | ||||
&((elm)->field.le_next)) \ | &((elm)->field.le_next)) \ | ||||
panic("Bad link elm %p next->prev != elm", (elm)); \ | panic("Bad link elm %p next->prev != elm", (elm)); \ | ||||
} while (0) | } while (0) | ||||
/* | |||||
* QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME) | |||||
* | |||||
* Validates that the previous element (or head of the list) points to 'elm.' | |||||
*/ | |||||
#define QMD_LIST_CHECK_PREV(elm, field) do { \ | #define QMD_LIST_CHECK_PREV(elm, field) do { \ | ||||
if (*(elm)->field.le_prev != (elm)) \ | if (*(elm)->field.le_prev != (elm)) \ | ||||
panic("Bad link elm %p prev->next != elm", (elm)); \ | panic("Bad link elm %p prev->next != elm", (elm)); \ | ||||
} while (0) | } while (0) | ||||
#else | #else | ||||
#define QMD_LIST_CHECK_HEAD(head, field) | #define QMD_LIST_CHECK_HEAD(head, field) | ||||
#define QMD_LIST_CHECK_NEXT(elm, field) | #define QMD_LIST_CHECK_NEXT(elm, field) | ||||
#define QMD_LIST_CHECK_PREV(elm, field) | #define QMD_LIST_CHECK_PREV(elm, field) | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | struct { \ | ||||
class type **tqe_prev; /* address of previous next element */ \ | class type **tqe_prev; /* address of previous next element */ \ | ||||
TRACEBUF \ | TRACEBUF \ | ||||
} | } | ||||
/* | /* | ||||
* Tail queue functions. | * Tail queue functions. | ||||
*/ | */ | ||||
#if (defined(_KERNEL) && defined(INVARIANTS)) | #if (defined(_KERNEL) && defined(INVARIANTS)) | ||||
/* | |||||
* QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME) | |||||
* | |||||
* If the tailq is non-empty, validates that the first element of the tailq | |||||
* points back at 'head.' | |||||
*/ | |||||
#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ | #define QMD_TAILQ_CHECK_HEAD(head, field) do { \ | ||||
if (!TAILQ_EMPTY(head) && \ | if (!TAILQ_EMPTY(head) && \ | ||||
TAILQ_FIRST((head))->field.tqe_prev != \ | TAILQ_FIRST((head))->field.tqe_prev != \ | ||||
&TAILQ_FIRST((head))) \ | &TAILQ_FIRST((head))) \ | ||||
panic("Bad tailq head %p first->prev != head", (head)); \ | panic("Bad tailq head %p first->prev != head", (head)); \ | ||||
} while (0) | } while (0) | ||||
/* | |||||
* QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME) | |||||
* | |||||
* Validates that the tail of the tailq is a pointer to pointer to NULL. | |||||
*/ | |||||
#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ | #define QMD_TAILQ_CHECK_TAIL(head, field) do { \ | ||||
if (*(head)->tqh_last != NULL) \ | if (*(head)->tqh_last != NULL) \ | ||||
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ | panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ | ||||
} while (0) | } while (0) | ||||
/* | |||||
* QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME) | |||||
* | |||||
* If an element follows 'elm' in the tailq, validates that the next element | |||||
* points back at 'elm.' | |||||
*/ | |||||
#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ | #define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ | ||||
if (TAILQ_NEXT((elm), field) != NULL && \ | if (TAILQ_NEXT((elm), field) != NULL && \ | ||||
TAILQ_NEXT((elm), field)->field.tqe_prev != \ | TAILQ_NEXT((elm), field)->field.tqe_prev != \ | ||||
&((elm)->field.tqe_next)) \ | &((elm)->field.tqe_next)) \ | ||||
panic("Bad link elm %p next->prev != elm", (elm)); \ | panic("Bad link elm %p next->prev != elm", (elm)); \ | ||||
} while (0) | } while (0) | ||||
/* | |||||
* QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME) | |||||
* | |||||
* Validates that the previous element (or head of the tailq) points to 'elm.' | |||||
*/ | |||||
#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ | #define QMD_TAILQ_CHECK_PREV(elm, field) do { \ | ||||
if (*(elm)->field.tqe_prev != (elm)) \ | if (*(elm)->field.tqe_prev != (elm)) \ | ||||
panic("Bad link elm %p prev->next != elm", (elm)); \ | panic("Bad link elm %p prev->next != elm", (elm)); \ | ||||
} while (0) | } while (0) | ||||
#else | #else | ||||
#define QMD_TAILQ_CHECK_HEAD(head, field) | #define QMD_TAILQ_CHECK_HEAD(head, field) | ||||
#define QMD_TAILQ_CHECK_TAIL(head, headname) | #define QMD_TAILQ_CHECK_TAIL(head, headname) | ||||
#define QMD_TAILQ_CHECK_NEXT(elm, field) | #define QMD_TAILQ_CHECK_NEXT(elm, field) | ||||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |