5 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
7 Structures and macros for exec lists.
11 /**************************************
13 **************************************/
15 # include <exec/nodes.h>
19 /**************************************
21 **************************************/
25 struct Node
* lh_Head
,
35 struct MinNode
* mlh_Head
,
41 /**************************************
43 **************************************/
44 #define IsListEmpty(l) \
45 ( (((struct List *)l)->lh_TailPred) == (struct Node *)(l) )
47 #define IsMsgPortEmpty(mp) \
48 ( (((struct MsgPort *)(mp))->mp_MsgList.lh_TailPred) \
49 == (struct Node *)(&(((struct MsgPort *)(mp))->mp_MsgList)) )
54 struct List *__aros_list_tmp = (struct List *)(_l), \
55 *l = __aros_list_tmp; \
57 l->lh_TailPred = (struct Node *)l; \
59 l->lh_Head = (struct Node *)&l->lh_Tail; \
62 #define ADDHEAD(_l,_n) \
65 struct Node *__aros_node_tmp = (struct Node *)(_n), \
66 *n = __aros_node_tmp; \
67 struct List *__aros_list_tmp = (struct List *)(_l), \
68 *l = __aros_list_tmp; \
70 n->ln_Succ = l->lh_Head; \
71 n->ln_Pred = (struct Node *)&l->lh_Head; \
72 l->lh_Head->ln_Pred = n; \
76 #define ADDTAIL(_l,_n) \
79 struct Node *__aros_node_tmp = (struct Node *)(_n), \
80 *n = __aros_node_tmp; \
81 struct List *__aros_list_tmp = (struct List *)(_l), \
82 *l = __aros_list_tmp; \
84 n->ln_Succ = (struct Node *)&l->lh_Tail; \
85 n->ln_Pred = l->lh_TailPred; \
86 l->lh_TailPred->ln_Succ = n; \
92 struct Node *__aros_node_tmp = (struct Node *)(_n), \
93 *n = __aros_node_tmp; \
95 n->ln_Pred->ln_Succ = n->ln_Succ; \
96 n->ln_Succ->ln_Pred = n->ln_Pred; \
101 #define GetHead(_l) \
103 struct List *__aros_list_tmp = (struct List *)(_l), \
104 *l = __aros_list_tmp; \
106 l->lh_Head->ln_Succ ? l->lh_Head : (struct Node *)0; \
109 #define GetTail(_l) \
111 struct List *__aros_list_tmp = (struct List *)(_l), \
112 *l = __aros_list_tmp; \
114 l->lh_TailPred->ln_Pred ? l->lh_TailPred : (struct Node *)0; \
117 #define GetSucc(_n) \
119 struct Node *__aros_node_tmp = (struct Node *)(_n), \
120 *n = __aros_node_tmp; \
122 n->ln_Succ->ln_Succ ? n->ln_Succ : (struct Node *)0; \
125 #define GetPred(_n) \
127 struct Node *__aros_node_tmp = (struct Node *)(_n), \
128 *n = __aros_node_tmp; \
130 n->ln_Pred->ln_Pred ? n->ln_Pred : (struct Node *)0; \
133 #define REMHEAD(_l) \
135 struct List *__aros_list_tmp = (struct List *)(_l), \
136 *l = __aros_list_tmp; \
138 l->lh_Head->ln_Succ ? REMOVE(l->lh_Head) : (struct Node *)0; \
141 #define REMTAIL(_l) \
143 struct List *__aros_list_tmp = (struct List *)(_l), \
144 *l = __aros_list_tmp; \
146 l->lh_TailPred->ln_Pred ? REMOVE(l->lh_TailPred) : (struct Node *)0; \
149 #define ForeachNode(list, node) \
152 node = (void *)(((struct List *)(list))->lh_Head); \
153 ((struct Node *)(node))->ln_Succ; \
154 node = (void *)(((struct Node *)(node))->ln_Succ) \
157 #define ForeachNodeSafe(list, current, next) \
160 current = (void *)(((struct List *)(list))->lh_Head); \
161 (next = (void *)((struct Node *)(current))->ln_Succ); \
162 current = (void *)next \
165 #define ListLength(list,count) \
169 ForeachNode (list,__n) count ++; \
172 #endif /* EXEC_LISTS_H */