Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / .unmaintained / morphos / Include / exec / lists.h
blob8e662e3f7dba90bb404f2ffdce4a50ba5825b065
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef EXEC_LISTS_H
7 #define EXEC_LISTS_H
9 /******************************************************************************
11 FILE
12 $Id$
14 DESCRIPTION
15 Prototypes and macros for exec-lists.
17 ******************************************************************************/
19 /**************************************
20 Includes
21 **************************************/
22 #ifndef EXEC_NODES_H
23 # include <exec/nodes.h>
24 #endif
26 #pragma pack(2)
28 /**************************************
29 Structures
30 **************************************/
31 /* Normal list */
32 struct List
34 struct Node * lh_Head,
35 * lh_Tail,
36 * lh_TailPred;
37 UBYTE lh_Type;
38 UBYTE l_pad;
41 /* Minimal list */
42 struct MinList
44 struct MinNode * mlh_Head,
45 * mlh_Tail,
46 * mlh_TailPred;
49 #pragma pack()
51 /**************************************
52 Makros
53 **************************************/
54 #define IsListEmpty(l) \
55 ( (((struct List *)l)->lh_TailPred) == (struct Node *)(l) )
57 #define IsMsgPortEmpty(mp) \
58 ( (((struct MsgPort *)mp)->mp_MsgList.lh_TailPred) \
59 == (struct Node *)(&(((struct MsgPort *)mp)->mp_MsgList)) )
61 # define NEWLIST(l) (((struct List *)l)->lh_TailPred \
62 = (struct Node *)(l), \
63 ((struct List *)l)->lh_Tail = 0, \
64 ((struct List *)l)->lh_Head \
65 = (struct Node *)\
66 &(((struct List *)l)->lh_Tail))
68 # define ADDHEAD(l,n) ((void)(\
69 ((struct Node *)n)->ln_Succ = ((struct List *)l)->lh_Head, \
70 ((struct Node *)n)->ln_Pred = (struct Node *)&((struct List *)l)->lh_Head, \
71 ((struct List *)l)->lh_Head->ln_Pred = ((struct Node *)n), \
72 ((struct List *)l)->lh_Head = ((struct Node *)n)))
74 # define ADDTAIL(l,n) ((void)(\
75 ((struct Node *)n)->ln_Succ = (struct Node *)&((struct List *)l)->lh_Tail, \
76 ((struct Node *)n)->ln_Pred = ((struct List *)l)->lh_TailPred, \
77 ((struct List *)l)->lh_TailPred->ln_Succ = ((struct Node *)n), \
78 ((struct List *)l)->lh_TailPred = ((struct Node *)n) ))
80 # define REMOVE(n) ((void)(\
81 ((struct Node *)n)->ln_Pred->ln_Succ = ((struct Node *)n)->ln_Succ,\
82 ((struct Node *)n)->ln_Succ->ln_Pred = ((struct Node *)n)->ln_Pred ))
84 # define GetHead(l) (void *)(((struct List *)l)->lh_Head->ln_Succ \
85 ? ((struct List *)l)->lh_Head \
86 : (struct Node *)0)
87 # define GetTail(l) (void *)(((struct List *)l)->lh_TailPred->ln_Pred \
88 ? ((struct List *)l)->lh_TailPred \
89 : (struct Node *)0)
90 # define GetSucc(n) (void *)(((struct Node *)n)->ln_Succ->ln_Succ \
91 ? ((struct Node *)n)->ln_Succ \
92 : (struct Node *)0)
93 # define GetPred(n) (void *)(((struct Node *)n)->ln_Pred->ln_Pred \
94 ? ((struct Node *)n)->ln_Pred \
95 : (struct Node *)0)
96 # define ForeachNode(l,n) \
97 for (n=(void *)(((struct List *)(l))->lh_Head); \
98 ((struct Node *)(n))->ln_Succ; \
99 n=(void *)(((struct Node *)(n))->ln_Succ))
101 # define ForeachNodeSafe(l,n,n2) \
102 for (n=(void *)(((struct List *)(l))->lh_Head); \
103 (n2=(void *)((struct Node *)(n))->ln_Succ); \
104 n=(void *)n2)
106 # define SetNodeName(node,name) \
107 (((struct Node *)(node))->ln_Name = (char *)(name))
108 # define GetNodeName(node) \
109 (((struct Node *)(node))->ln_Name)
111 # define ListLength(list,count) \
112 do { \
113 struct Node * n; \
114 count = 0; \
115 ForeachNode (list,n) count ++; \
116 } while (0)
120 /******************************************************************************
121 ***** ENDE exec/lists.h
122 ******************************************************************************/
124 #endif /* EXEC_LISTS_H */