5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
8 Structures and macros for exec lists.
12 /**************************************
14 **************************************/
16 # include <exec/nodes.h>
20 /**************************************
22 **************************************/
27 struct Node
* lh_Head
,
37 struct MinNode
* mlh_Head
,
43 struct __mayalias List
;
46 struct Node
* lh_Head
,
50 struct Node
* lh_TailPred
;
51 struct List
* lh_TailPred_
;
58 struct __mayalias MinList
;
61 struct MinNode
* mlh_Head
,
65 struct MinNode
* mlh_TailPred
;
66 struct MinList
* mlh_TailPred_
;
71 /**************************************
73 **************************************/
74 #define IsListEmpty(l) \
75 ( (((struct List *)l)->lh_TailPred) == (struct Node *)(l) )
77 #define IsMinListEmpty(l) \
78 ( (((struct MinList *)l)->mlh_TailPred) == (struct MinNode *)(l) )
80 #define IsMsgPortEmpty(mp) \
81 ( (((struct MsgPort *)(mp))->mp_MsgList.lh_TailPred) \
82 == (struct Node *)(&(((struct MsgPort *)(mp))->mp_MsgList)) )
88 struct List *__aros_list_tmp = (struct List *)(_l), \
89 *l = __aros_list_tmp; \
91 l->lh_TailPred = (struct Node *)l; \
93 l->lh_Head = (struct Node *)&l->lh_Tail; \
99 struct List *__aros_list_tmp = (struct List *)(_l), \
100 *l = __aros_list_tmp; \
102 l->lh_TailPred_= l; \
104 l->lh_Head = (struct Node *)&l->lh_Tail; \
106 #endif /* __GNUC__ */
108 #define ADDHEAD(_l,_n) \
111 struct Node *__aros_node_tmp = (struct Node *)(_n), \
112 *n = __aros_node_tmp; \
113 struct List *__aros_list_tmp = (struct List *)(_l), \
114 *l = __aros_list_tmp; \
116 n->ln_Succ = l->lh_Head; \
117 n->ln_Pred = (struct Node *)&l->lh_Head; \
118 l->lh_Head->ln_Pred = n; \
122 #define ADDTAIL(_l,_n) \
125 struct Node *__aros_node_tmp = (struct Node *)(_n), \
126 *n = __aros_node_tmp; \
127 struct List *__aros_list_tmp = (struct List *)(_l), \
128 *l = __aros_list_tmp; \
130 n->ln_Succ = (struct Node *)&l->lh_Tail; \
131 n->ln_Pred = l->lh_TailPred; \
132 l->lh_TailPred->ln_Succ = n; \
133 l->lh_TailPred = n; \
138 struct Node *__aros_node_tmp = (struct Node *)(_n), \
139 *n = __aros_node_tmp; \
141 n->ln_Pred->ln_Succ = n->ln_Succ; \
142 n->ln_Succ->ln_Pred = n->ln_Pred; \
147 #define GetHead(_l) \
149 struct List *__aros_list_tmp = (struct List *)(_l), \
150 *l = __aros_list_tmp; \
152 l->lh_Head->ln_Succ ? l->lh_Head : (struct Node *)0; \
155 #define GetTail(_l) \
157 struct List *__aros_list_tmp = (struct List *)(_l), \
158 *l = __aros_list_tmp; \
160 l->lh_TailPred->ln_Pred ? l->lh_TailPred : (struct Node *)0; \
163 #define GetSucc(_n) \
165 struct Node *__aros_node_tmp = (struct Node *)(_n), \
166 *n = __aros_node_tmp; \
168 (n && n->ln_Succ && n->ln_Succ->ln_Succ) ? n->ln_Succ : (struct Node *)0; \
171 #define GetPred(_n) \
173 struct Node *__aros_node_tmp = (struct Node *)(_n), \
174 *n = __aros_node_tmp; \
176 (n && n->ln_Pred && n->ln_Pred->ln_Pred) ? n->ln_Pred : (struct Node *)0; \
179 #define REMHEAD(_l) \
181 struct List *__aros_list_tmp = (struct List *)(_l), \
182 *l = __aros_list_tmp; \
184 l->lh_Head->ln_Succ ? REMOVE(l->lh_Head) : (struct Node *)0; \
187 #define REMTAIL(_l) \
189 struct List *__aros_list_tmp = (struct List *)(_l), \
190 *l = __aros_list_tmp; \
192 l->lh_TailPred->ln_Pred ? REMOVE(l->lh_TailPred) : (struct Node *)0; \
195 #define ForeachNode(list, node) \
198 node = (void *)(((struct List *)(list))->lh_Head); \
199 ((struct Node *)(node))->ln_Succ; \
200 node = (void *)(((struct Node *)(node))->ln_Succ) \
203 #define ForeachNodeSafe(list, current, next) \
206 current = (void *)(((struct List *)(list))->lh_Head); \
207 (next = (void *)((struct Node *)(current))->ln_Succ); \
208 current = (void *)next \
211 #define ListLength(list,count) \
215 ForeachNode (list,__n) count ++; \
218 #endif /* EXEC_LISTS_H */