1 /* A queue definition based on sys/queue.h TAILQ definitions
3 * Blame any implementation mistakes on Peter Hunnisett
4 * <hunnise@nortelnetworks.com>
7 #ifndef __WINE_DPLAYX_QUEUE_H
8 #define __WINE_DPLAYX_QUEUE_H
10 #define DPQ_INSERT(a,b,c) DPQ_INSERT_IN_TAIL(a,b,c)
13 * Tail queue definitions.
15 #define DPQ_HEAD(type) \
17 struct type *lpQHFirst; /* first element */ \
18 struct type **lpQHLast; /* addr of last next element */ \
21 #define DPQ_ENTRY(type) \
23 struct type *lpQNext; /* next element */ \
24 struct type **lpQPrev; /* address of previous next element */ \
28 * Tail queue functions.
30 #define DPQ_INIT(head) \
32 (head).lpQHFirst = NULL; \
33 (head).lpQHLast = &(head).lpQHFirst; \
36 #define DPQ_INSERT_IN_TAIL(head, elm, field) \
38 (elm)->field.lpQNext = NULL; \
39 (elm)->field.lpQPrev = (head).lpQHLast; \
40 *(head).lpQHLast = (elm); \
41 (head).lpQHLast = &(elm)->field.lpQNext; \
44 #define DPQ_REMOVE(head, elm, field) \
46 if (((elm)->field.lpQNext) != NULL) \
47 (elm)->field.lpQNext->field.lpQPrev = \
48 (elm)->field.lpQPrev; \
50 (head).lpQHLast = (elm)->field.lpQPrev; \
51 *(elm)->field.lpQPrev = (elm)->field.lpQNext; \
54 /* head - pointer to DPQ_HEAD struct
55 * elm - how to find the next element
56 * field - to be concatenated to rc to compare with fieldToEqual
57 * fieldToEqual - The value that we're looking for
58 * rc - Variable to put the return code. Same type as (head).lpQHFirst
60 #define DPQ_FIND_ENTRY( head, elm, field, fieldToEqual, rc ) \
62 (rc) = (head).lpQHFirst; /* NULL head? */ \
66 /* What we're searching for? */ \
67 if( (rc)->field == (fieldToEqual) ) \
69 break; /* rc == correct element */ \
72 /* End of list check */ \
73 if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst ) \
81 /* head - pointer to DPQ_HEAD struct
82 * elm - how to find the next element
83 * field - to be concatenated to rc to compare with fieldToEqual
84 * fieldToEqual - The value that we're looking for
85 * rc - Variable to put the return code. Same type as (head).lpQHFirst
87 #define DPQ_REMOVE_ENTRY( head, elm, field, fieldToEqual, rc ) \
89 DPQ_FIND_ENTRY( head, elm, field, fieldToEqual, rc ); \
91 /* Was the element found? */ \
94 DPQ_REMOVE( head, rc, elm ); \
98 #endif /* __WINE_DPLAYX_QUEUE_H */