Added support for nested exceptions happening inside a catch block.
[wine/multimedia.git] / dlls / dplayx / dplayx_queue.h
blob7e5cbf3bbeafbd2b5487e76a2fb8cb7df167ad42
1 /* A queue definition based on sys/queue.h TAILQ definitions
3 * Copyright 2000 Peter Hunnisett
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef __WINE_DPLAYX_QUEUE_H
21 #define __WINE_DPLAYX_QUEUE_H
23 #include "winbase.h"
25 #define DPQ_INSERT(a,b,c) DPQ_INSERT_IN_TAIL(a,b,c)
28 * Tail queue definitions.
30 #define DPQ_HEAD(type) \
31 struct { \
32 struct type *lpQHFirst; /* first element */ \
33 struct type **lpQHLast; /* addr of last next element */ \
36 #define DPQ_ENTRY(type) \
37 struct { \
38 struct type *lpQNext; /* next element */ \
39 struct type **lpQPrev; /* address of previous next element */ \
43 * Tail queue functions.
45 #define DPQ_INIT(head) \
46 do{ \
47 (head).lpQHFirst = NULL; \
48 (head).lpQHLast = &(head).lpQHFirst; \
49 } while(0)
51 /* Front of the queue */
52 #define DPQ_FIRST( head ) ( (head).lpQHFirst )
54 /* Check if the queue has any elements */
55 #define DPQ_IS_EMPTY( head ) ( DPQ_FIRST(head) == NULL )
57 /* Next entry -- FIXME: Convert everything over to this macro ... */
58 #define DPQ_NEXT( elem ) (elem).lpQNext
60 #define DPQ_IS_ENDOFLIST( elem ) \
61 ( DPQ_NEXT(elem) == NULL )
63 /* Insert element at end of queue */
64 #define DPQ_INSERT_IN_TAIL(head, elm, field) \
65 do { \
66 (elm)->field.lpQNext = NULL; \
67 (elm)->field.lpQPrev = (head).lpQHLast; \
68 *(head).lpQHLast = (elm); \
69 (head).lpQHLast = &(elm)->field.lpQNext; \
70 } while(0)
72 /* Remove element from the queue */
73 #define DPQ_REMOVE(head, elm, field) \
74 do { \
75 if (((elm)->field.lpQNext) != NULL) \
76 (elm)->field.lpQNext->field.lpQPrev = \
77 (elm)->field.lpQPrev; \
78 else \
79 (head).lpQHLast = (elm)->field.lpQPrev; \
80 *(elm)->field.lpQPrev = (elm)->field.lpQNext; \
81 } while(0)
83 /* head - pointer to DPQ_HEAD struct
84 * elm - how to find the next element
85 * field - to be concatenated to rc to compare with fieldToCompare
86 * fieldToCompare - The value that we're comparing against
87 * fieldCompareOperator - The logical operator to compare field and
88 * fieldToCompare.
89 * rc - Variable to put the return code. Same type as (head).lpQHFirst
91 #define DPQ_FIND_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc )\
92 do { \
93 (rc) = DPQ_FIRST(head); /* NULL head? */ \
95 while( rc ) \
96 { \
97 /* What we're searching for? */ \
98 if( (rc)->field fieldCompareOperator (fieldToCompare) ) \
99 { \
100 break; /* rc == correct element */ \
103 /* End of list check */ \
104 if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst ) \
106 rc = NULL; \
107 break; \
110 } while(0)
112 /* head - pointer to DPQ_HEAD struct
113 * elm - how to find the next element
114 * field - to be concatenated to rc to compare with fieldToCompare
115 * fieldToCompare - The value that we're comparing against
116 * compare_cb - Callback to invoke to determine if comparision should continue.
117 * Callback must be defined with DPQ_DECL_COMPARECB.
118 * rc - Variable to put the return code. Same type as (head).lpQHFirst
120 #define DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
121 do { \
122 (rc) = DPQ_FIRST(head); /* NULL head? */ \
124 while( rc ) \
126 /* What we're searching for? */ \
127 if( compare_cb( &((rc)->field), &(fieldToCompare) ) ) \
129 break; /* no more */ \
132 /* End of list check */ \
133 if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst ) \
135 rc = NULL; \
136 break; \
139 } while(0)
141 /* How to define the method to be passed to DPQ_DELETEQ */
142 #define DPQ_DECL_COMPARECB( name, type ) BOOL name( const type* elem1, const type* elem2 )
145 /* head - pointer to DPQ_HEAD struct
146 * elm - how to find the next element
147 * field - to be concatenated to rc to compare with fieldToEqual
148 * fieldToCompare - The value that we're comparing against
149 * fieldCompareOperator - The logical operator to compare field and
150 * fieldToCompare.
151 * rc - Variable to put the return code. Same type as (head).lpQHFirst
153 #define DPQ_REMOVE_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc )\
154 do { \
155 DPQ_FIND_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc );\
157 /* Was the element found? */ \
158 if( rc ) \
160 DPQ_REMOVE( head, rc, elm ); \
162 } while(0)
164 /* head - pointer to DPQ_HEAD struct
165 * elm - how to find the next element
166 * field - to be concatenated to rc to compare with fieldToCompare
167 * fieldToCompare - The value that we're comparing against
168 * compare_cb - Callback to invoke to determine if comparision should continue.
169 * Callback must be defined with DPQ_DECL_COMPARECB.
170 * rc - Variable to put the return code. Same type as (head).lpQHFirst
172 #define DPQ_REMOVE_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
173 do { \
174 DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc );\
176 /* Was the element found? */ \
177 if( rc ) \
179 DPQ_REMOVE( head, rc, elm ); \
181 } while(0)
184 /* Delete the entire queue
185 * head - pointer to the head of the queue
186 * field - field to access the next elements of the queue
187 * type - type of the pointer to the element element
188 * df - a delete function to be called. Declared with DPQ_DECL_DELETECB.
190 #define DPQ_DELETEQ( head, field, type, df ) \
191 do \
193 while( !DPQ_IS_EMPTY(head) ) \
195 type holder = DPQ_FIRST(head); \
196 DPQ_REMOVE( head, holder, field ); \
197 df( holder ); \
199 } while(0)
201 /* How to define the method to be passed to DPQ_DELETEQ */
202 #define DPQ_DECL_DELETECB( name, type ) void name( type elem )
204 /* Prototype of a method which just performs a HeapFree on the elem */
205 DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID );
207 #endif /* __WINE_DPLAYX_QUEUE_H */