source: doc/theses/mike_brooks_MMath/benchmarks/list/fx-lq-tailq.h @ 6740533e

Last change on this file since 6740533e was 0b66ef9, checked in by Michael Brooks <mlbrooks@…>, 21 months ago

Add linked list performance experiment

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#include <sys/queue.h>
2
3#define HEADNAME_(S)                             S ## Head
4
5#define BFX_INTRUSION(S)                         TAILQ_ENTRY(S) xx;
6#define BFX_EXTRUSION_DECL(S)
7#define BFX_EXTRUSION_FOLLOWUP(S)                TAILQ_HEAD(HEADNAME_(S), S);
8#define BFX_LIST_HEAD_T(S)                       struct HEADNAME_(S)
9#define BFX_LISTED_ELEM_T(S)                     S*
10
11#define BFX_INSERT_FIRST(S, lst, item)           ({TAILQ_INSERT_HEAD(&lst, &item, xx); &item;})
12#define BFX_INSERT_LAST(S, lst, item)            ({TAILQ_INSERT_TAIL(&lst, &item, xx); &item;})
13#define BFX_INSERT_BEFORE(S, lst, item, refIter) ({TAILQ_INSERT_BEFORE(refIter, &item, xx); &item;})
14#define BFX_INSERT_AFTER(S, lst, item, refIter)  ({TAILQ_INSERT_AFTER(&lst, refIter, &item, xx); &item;})
15#define BFX_REMOVE_FIRST(S, lst)                 ({ S * first=TAILQ_FIRST( &lst );               TAILQ_REMOVE( &lst, first, xx ); })   // about two steps: see tailq-bug.c
16#define BFX_REMOVE_LAST(S, lst)                  ({ S * last =TAILQ_LAST ( &lst, HEADNAME_(S) ); TAILQ_REMOVE( &lst, last , xx ); })
17#define BFX_REMOVE_HERE(S, lst, refIter)         TAILQ_REMOVE( &lst, refIter, xx )
18#define BFX_INIT(S, lst)                         TAILQ_INIT(&lst);
19
20#define BFX_GET_AFTER(S, lst, iter)              TAILQ_NEXT(iter, xx)
21#define BFX_GET_BEFORE(S, lst, iter)             TAILQ_PREV(iter, HEADNAME_(S), xx)
22#define BFX_IS_VALID_POS(S, lst, iter)           ((iter)!=NULL)
23#define BFX_DEREF_POS(S, lst, iter)              (iter)
Note: See TracBrowser for help on using the repository browser.