Go to the documentation of this file.
62 #define csnip_dlist_Init(head, tail, mprev, mnext) \
64 (head) = (tail) = NULL; \
71 #define csnip_dlist_IsEmpty(head, tail, mprev, mnext) \
75 #define csnip_dlist_PushHead(head, tail, mprev, mnext, el) \
77 assert((el) != NULL); \
78 if ((head) != NULL) { \
79 (head)->mprev = (el); \
81 assert((tail) == NULL); \
84 (el)->mnext = (head); \
95 #define csnip_dlist_PopHead(head, tail, mprev, mnext) \
97 assert((head) != NULL); \
98 (head) = (head)->mnext; \
99 if ((head) != NULL) { \
100 (head)->mprev = NULL; \
107 #define csnip_dlist_PushTail(head, tail, mprev, mnext, el) \
109 if ((head) == NULL) { \
110 assert((tail) == NULL); \
113 (tail)->mnext = (el); \
115 (el)->mprev = (tail); \
116 (el)->mnext = NULL; \
124 #define csnip_dlist_PopTail(head, tail, mprev, mnext) \
126 assert((tail) != NULL); \
127 (tail) = (tail)->mprev; \
128 if ((tail) != NULL) { \
129 (tail)->mnext = NULL; \
146 #define csnip_dlist_InsertAfter(head, tail, mprev, mnext, loc, el) \
148 (el)->mprev = (loc); \
149 (el)->mnext = (loc)->mnext; \
150 if ((loc)->mnext != NULL) { \
151 (loc)->mnext->mprev = (el); \
153 assert((loc) == (tail)); \
156 (loc)->mnext = (el); \
171 #define csnip_dlist_InsertBefore(head, tail, mprev, mnext, loc, el) \
173 (el)->mnext = (loc); \
174 (el)->mprev = (loc)->mprev; \
175 if ((loc)->mprev != NULL) { \
176 (loc)->mprev->mnext = (el); \
178 assert((loc) == (head)); \
181 (loc)->mprev = (el); \
190 #define csnip_dlist_Remove(head, tail, mprev, mnext, el) \
192 if ((el)->mprev != NULL) { \
193 (el)->mprev->mnext = (el)->mnext; \
195 assert((el) == (head)); \
196 (head) = (el)->mnext; \
198 if ((el)->mnext != NULL) { \
199 (el)->mnext->mprev = (el)->mprev; \
201 assert((el) == (tail)); \
202 (tail) = (el)->mprev; \
213 #define CSNIP_DLIST_DECL_FUNCS(scope, prefix, entry_ptr_type, gen_args) \
214 scope void prefix ## init(csnip_pp_list_##gen_args); \
215 scope char prefix ## is_empty(csnip_pp_list_##gen_args); \
216 scope void prefix ## push_head(csnip_pp_prepend_##gen_args \
217 entry_ptr_type csnip_el); \
218 scope void prefix ## pop_head(csnip_pp_list_##gen_args); \
219 scope void prefix ## push_tail(csnip_pp_prepend_##gen_args \
220 entry_ptr_type csnip_el); \
221 scope void prefix ## pop_tail(csnip_pp_list_##gen_args); \
222 scope void prefix ## insert_after(csnip_pp_prepend_##gen_args \
223 entry_ptr_type csnip_loc, \
224 entry_ptr_type csnip_el); \
225 scope void prefix ## insert_before(csnip_pp_prepend_##gen_args \
226 entry_ptr_type csnip_loc, \
227 entry_ptr_type csnip_el); \
228 scope void prefix ## remove(csnip_pp_prepend_##gen_args \
229 entry_ptr_type csnip_el); \
232 scope entry_ptr_type prefix ## head(csnip_pp_list_##gen_args); \
233 scope entry_ptr_type prefix ## tail(csnip_pp_list_##gen_args); \
234 scope entry_ptr_type prefix ## prev(entry_ptr_type csnip_el); \
235 scope entry_ptr_type prefix ## next(entry_ptr_type csnip_el); \
279 #define CSNIP_DLIST_DEF_FUNCS(scope, prefix, entry_ptr_type, gen_args, \
280 phead, ptail, mprev, mnext) \
281 scope void prefix ## init(csnip_pp_list_##gen_args) \
283 csnip_dlist_Init(phead, ptail, mprev, mnext); \
285 scope char prefix ## is_empty(csnip_pp_list_##gen_args) { \
286 return csnip_dlist_IsEmpty(phead, ptail, mprev, mnext); \
288 scope void prefix ## push_head(csnip_pp_prepend_##gen_args \
289 entry_ptr_type csnip_el) \
291 csnip_dlist_PushHead(phead, ptail, mprev, mnext, csnip_el); \
293 scope void prefix ## pop_head(csnip_pp_list_##gen_args) \
295 csnip_dlist_PopHead(phead, ptail, mprev, mnext); \
297 scope void prefix ## push_tail(csnip_pp_prepend_##gen_args \
298 entry_ptr_type csnip_el) \
300 csnip_dlist_PushTail(phead, ptail, mprev, mnext, csnip_el); \
302 scope void prefix ## pop_tail(csnip_pp_list_##gen_args) \
304 csnip_dlist_PopTail(phead, ptail, mprev, mnext); \
306 scope void prefix ## insert_after(csnip_pp_prepend_##gen_args \
307 entry_ptr_type csnip_loc, \
308 entry_ptr_type csnip_el) \
310 csnip_dlist_InsertAfter(phead, ptail, mprev, mnext, \
311 csnip_loc, csnip_el); \
313 scope void prefix ## insert_before(csnip_pp_prepend_##gen_args \
314 entry_ptr_type csnip_loc, \
315 entry_ptr_type csnip_el) \
317 csnip_dlist_InsertBefore(phead, ptail, mprev, mnext, \
318 csnip_loc, csnip_el); \
320 scope void prefix ## remove(csnip_pp_prepend_##gen_args \
321 entry_ptr_type csnip_el) \
323 csnip_dlist_Remove(phead, ptail, mprev, mnext, csnip_el); \
327 scope entry_ptr_type prefix ## head(csnip_pp_list_##gen_args) { \
330 scope entry_ptr_type prefix ## tail(csnip_pp_list_##gen_args) { \
333 scope entry_ptr_type prefix ## prev(entry_ptr_type csnip_el) { \
334 return csnip_el->mprev; \
336 scope entry_ptr_type prefix ## next(entry_ptr_type csnip_el) { \
337 return csnip_el->mnext; \
347 #define csnip_slist_Init(head, tail, mnext) \
349 (head) = (tail) = NULL; \
353 #define csnip_slist_PushHead(head, tail, mnext, el) \
355 (el)->mnext = (head); \
356 if ((tail) == NULL) { \
357 assert((head) == NULL); \
369 #define csnip_slist_PopHead(head, tail, mnext) \
371 assert((head) != NULL); \
372 if ((tail) == (head)) { \
373 (head) = (tail) = NULL; \
375 (head) = (head)->mnext; \
380 #define csnip_slist_PushTail(head, tail, mnext, el) \
382 if ((head) == NULL) { \
383 assert((tail) == NULL); \
384 (head) = (tail) = (el); \
386 (tail)->mnext = (el); \
389 (el)->mnext = NULL; \
403 #define csnip_slist_InsertAfter(head, tail, mnext, loc, el) \
405 (el)->mnext = (loc)->mnext; \
406 (loc)->mnext = (el); \
407 if ((el)->mnext == NULL) { \
420 #define CSNIP_SLIST_DECL_FUNCS(scope, prefix, entry_ptr_type, gen_args) \
421 scope void prefix ## init(csnip_pp_list_##gen_args); \
422 scope void prefix ## push_head(csnip_pp_prepend_##gen_args \
423 entry_ptr_type csnip_el); \
424 scope void prefix ## pop_head(csnip_pp_list_##gen_args); \
425 scope void prefix ## push_tail(csnip_pp_prepend_##gen_args \
426 entry_ptr_type csnip_el); \
427 scope void prefix ## insert_after(csnip_pp_prepend_##gen_args \
428 entry_ptr_type csnip_loc, \
429 entry_ptr_type csnip_el); \
432 scope entry_ptr_type prefix ## head(csnip_pp_list_##gen_args); \
433 scope entry_ptr_type prefix ## tail(csnip_pp_list_##gen_args); \
434 scope entry_ptr_type prefix ## next(entry_ptr_type csnip_el); \
435 scope char prefix ## is_empty(csnip_pp_list_##gen_args); \
474 #define CSNIP_SLIST_DEF_FUNCS(scope, prefix, entry_ptr_type, gen_args, \
475 phead, ptail, mnext) \
476 scope void prefix ## init(csnip_pp_list_##gen_args) \
478 csnip_slist_Init(phead, ptail, mnext); \
480 scope void prefix ## push_head(csnip_pp_prepend_##gen_args \
481 entry_ptr_type csnip_el) \
483 csnip_slist_PushHead(phead, ptail, mnext, csnip_el); \
485 scope void prefix ## pop_head(csnip_pp_list_##gen_args) \
487 csnip_slist_PopHead(phead, ptail, mnext); \
489 scope void prefix ## push_tail(csnip_pp_prepend_##gen_args \
490 entry_ptr_type csnip_el) \
492 csnip_slist_PushTail(phead, ptail, mnext, csnip_el); \
494 scope void prefix ## insert_after(csnip_pp_prepend_##gen_args \
495 entry_ptr_type csnip_loc, \
496 entry_ptr_type csnip_el) \
498 csnip_slist_InsertAfter(phead, ptail, mnext, \
499 csnip_loc, csnip_el); \
503 scope entry_ptr_type prefix ## head(csnip_pp_list_##gen_args) { \
506 scope entry_ptr_type prefix ## tail(csnip_pp_list_##gen_args) { \
509 scope entry_ptr_type prefix ## next(entry_ptr_type csnip_el) { \
510 return csnip_el->mnext; \
512 scope char prefix ## is_empty(csnip_pp_list_##gen_args) { \
513 return phead == NULL; \
521 #if defined(CSNIP_SHORT_NAMES) && !defined(CSNIP_LIST_HAVE_SHORT_NAMES)
522 #define dlist_Init csnip_dlist_Init
523 #define dlist_IsEmpty csnip_dlist_IsEmpty
524 #define dlist_PushHead csnip_dlist_PushHead
525 #define dlist_PopHead csnip_dlist_PopHead
526 #define dlist_PushTail csnip_dlist_PushTail
527 #define dlist_PopTail csnip_dlist_PopTail
528 #define dlist_InsertAfter csnip_dlist_InsertAfter
529 #define dlist_InsertBefore csnip_dlist_InsertBefore
530 #define dlist_Remove csnip_dlist_Remove
531 #define slist_Init csnip_slist_Init
532 #define slist_PushHead csnip_slist_PushHead
533 #define slist_PopHead csnip_slist_PopHead
534 #define slist_PushTail csnip_slist_PushTail
535 #define slist_InsertAfter csnip_slist_InsertAfter
536 #define CSNIP_LIST_HAVE_SHORT_NAMES