genmodule: Add <exec/devices.h> to the device proto includes
[AROS.git] / test / uae / lists.h
blob52f759780efe6908a32fff7630682eb2c601f4b2
1 #ifndef EXEC_LISTS_H
2 #define EXEC_LISTS_H
3 /* Copyright © 1995, The AROS Development Team. All rights reserved. */
5 /******************************************************************************
7 FILE
8 $Id$
10 DESCRIPTION
11 Prototypes and macros for exec-lists.
13 ******************************************************************************/
15 /**************************************
16 Includes
17 **************************************/
18 #ifndef EXEC_NODES_H
19 # include "nodes.h"
20 #endif
23 class ListPtr : public APTR
25 public:
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);
56 inline ListPtr ()
58 return;
62 class MinListPtr : public APTR
64 public:
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 /**************************************
82 Structures
83 **************************************/
84 /* Normal list */
85 struct List
87 NodePtr lh_Head,
88 lh_Tail,
89 lh_TailPred;
90 UBYTE lh_Type;
91 UBYTE l_pad;
93 inline List () { return; }
96 /* Minimal list */
97 struct MinList
99 MinNodePtr mlh_Head,
100 mlh_Tail,
101 mlh_TailPred;
103 inline MinList () { return; }
107 /**************************************
108 Makros
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 \
121 = (struct Node *)\
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 \
142 : (struct Node *)0)
143 # define GetTail(l) (void *)(((struct List *)l)->lh_TailPred->ln_Pred \
144 ? ((struct List *)l)->lh_TailPred \
145 : (struct Node *)0)
146 # define GetSucc(n) (void *)(((struct Node *)n)->ln_Succ->ln_Succ \
147 ? ((struct Node *)n)->ln_Succ \
148 : (struct Node *)0)
149 # define GetPred(n) (void *)(((struct Node *)n)->ln_Pred->ln_Pred \
150 ? ((struct Node *)n)->ln_Pred \
151 : (struct Node *)0)
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); \
160 n=(void *)n2)
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) \
168 do { \
169 struct Node * n; \
170 count = 0; \
171 ForeachNode (list,n) count ++; \
172 } while (0)
176 /******************************************************************************
177 ***** ENDE exec/lists.h
178 ******************************************************************************/
180 #endif /* EXEC_LISTS_H */