3 /* Copyright © 1995, The AROS Development Team. All rights reserved. */
5 /******************************************************************************
11 Prototypes and macros for exec-lists.
13 ******************************************************************************/
15 /**************************************
17 **************************************/
23 class ListPtr
: public APTR
26 inline struct List
* operator -> ()
28 return (struct List
*) ntohl (data
);
31 inline operator struct List
* ()
33 return (struct List
*) ntohl (data
);
36 inline operator struct MinList
* ()
38 return (struct MinList
*) ntohl (data
);
41 inline operator void * ()
43 return (void *) ntohl (data
);
46 inline operator struct Node
* ()
48 return (struct Node
*) ntohl (data
);
51 inline ListPtr (struct List
* v
)
53 data
= htonl ((long)v
);
62 class MinListPtr
: public APTR
65 inline struct MinList
* operator -> ()
67 return (struct MinList
*) ntohl (data
);
70 inline operator struct MinList
* ()
72 return (struct MinList
*) ntohl (data
);
75 inline MinListPtr (struct MinList
* v
)
77 data
= htonl ((long)v
);
81 /**************************************
83 **************************************/
93 inline List () { return; }
103 inline MinList () { return; }
107 /**************************************
109 **************************************/
110 #define IsListEmpty(l) \
111 ( (((struct List *)l)->lh_TailPred) == (struct Node *)(l) )
113 #define IsMsgPortEmpty(mp) \
114 ( (((struct MsgPort *)mp)->mp_MsgList.lh_TailPred) \
115 == (struct Node *)(&(((struct MsgPort *)mp)->mp_MsgList)) )
117 # define NEWLIST(l) (((struct List *)l)->lh_TailPred \
118 = (struct Node *)(l), \
119 ((struct List *)l)->lh_Tail = 0, \
120 ((struct List *)l)->lh_Head \
122 &(((struct List *)l)->lh_Tail))
124 # define ADDHEAD(l,n) ((void)(\
125 ((struct Node *)n)->ln_Succ = ((struct List *)l)->lh_Head, \
126 ((struct Node *)n)->ln_Pred = (struct Node *)&((struct List *)l)->lh_Head, \
127 ((struct Node *)((struct List *)l)->lh_Head)->ln_Pred = ((struct Node *)n), \
128 ((struct List *)l)->lh_Head = ((struct Node *)n)))
130 # define ADDTAIL(l,n) ((void)(\
131 ((struct Node *)n)->ln_Succ = (struct Node *)&((struct List *)l)->lh_Tail, \
132 ((struct Node *)n)->ln_Pred = ((struct List *)l)->lh_TailPred, \
133 ((struct List *)l)->lh_TailPred->ln_Succ = ((struct Node *)n), \
134 ((struct List *)l)->lh_TailPred = ((struct Node *)n) ))
136 # define REMOVE(n) ((void)(\
137 ((struct Node *)n)->ln_Pred->ln_Succ = ((struct Node *)n)->ln_Succ,\
138 ((struct Node *)n)->ln_Succ->ln_Pred = ((struct Node *)n)->ln_Pred ))
140 # define GetHead(l) (void *)(((struct List *)l)->lh_Head->ln_Succ \
141 ? ((struct List *)l)->lh_Head \
143 # define GetTail(l) (void *)(((struct List *)l)->lh_TailPred->ln_Pred \
144 ? ((struct List *)l)->lh_TailPred \
146 # define GetSucc(n) (void *)(((struct Node *)n)->ln_Succ->ln_Succ \
147 ? ((struct Node *)n)->ln_Succ \
149 # define GetPred(n) (void *)(((struct Node *)n)->ln_Pred->ln_Pred \
150 ? ((struct Node *)n)->ln_Pred \
152 # define ForeachNode(l,n) \
153 for (n=(void *)(((struct List *)(l))->lh_Head); \
154 ((struct Node *)(n))->ln_Succ; \
155 n=(void *)(((struct Node *)(n))->ln_Succ))
157 # define ForeachNodeSafe(l,n,n2) \
158 for (n=(void *)(((struct List *)(l))->lh_Head); \
159 (n2=(void *)((struct Node *)(n))->ln_Succ); \
162 # define SetNodeName(node,name) \
163 (((struct Node *)(node))->ln_Name = (char *)(name))
164 # define GetNodeName(node) \
165 (((struct Node *)(node))->ln_Name
167 # define ListLength(list,count) \
171 ForeachNode (list,n) count ++; \
176 /******************************************************************************
177 ***** ENDE exec/lists.h
178 ******************************************************************************/
180 #endif /* EXEC_LISTS_H */