arch/ppc-sam440: Don't run INTB_VERTB when interrupts are disabled!
[AROS.git] / test / uae-tmpl / lists.h
blob47020eb331b6a2f2db85061317cdff705669fba5
1 #ifndef EXEC_LISTS_H
2 #define EXEC_LISTS_H
3 /* Copyright © 1995, The AROS Development Team. All rights reserved. */
5 #ifndef EXEC_NODES_H
6 # include "nodes.h"
7 #endif
9 typedef be_ptr<struct List> ListPtr;
10 typedef be_ptr<struct MinList> MinListPtr;
12 /* Normal list */
13 struct List
15 NodePtr lh_Head,
16 lh_Tail,
17 lh_TailPred;
18 UBYTE lh_Type;
19 UBYTE l_pad;
22 /* Minimal list */
23 struct MinList
25 MinNodePtr mlh_Head,
26 mlh_Tail,
27 mlh_TailPred;
30 #define IsListEmpty(l) \
31 ( (((struct List *)l)->lh_TailPred) == (struct Node *)(l) )
32 #define IsMsgPortEmpty(mp) \
33 ( (((struct MsgPort *)mp)->mp_MsgList.lh_TailPred) \
34 == (struct Node *)(&(((struct MsgPort *)mp)->mp_MsgList)) )
36 # define NEWLIST(l) (((struct List *)l)->lh_TailPred \
37 = (NodePtr)(l), \
38 ((struct List *)l)->lh_Tail = 0, \
39 ((struct List *)l)->lh_Head \
40 = (NodePtr)\
41 &(((struct List *)l)->lh_Tail))
43 # define ADDHEAD(l,n) ((void)(\
44 ((struct Node *)n)->ln_Succ = ((struct List *)l)->lh_Head, \
45 ((struct Node *)n)->ln_Pred = (struct Node *)&((struct List *)l)->lh_Head, \
46 ((struct Node *)((struct List *)l)->lh_Head)->ln_Pred = ((struct Node *)n), \
47 ((struct List *)l)->lh_Head = ((struct Node *)n)))
49 # define ADDTAIL(l,n) ((void)(\
50 ((struct Node *)n)->ln_Succ = (struct Node *)&((struct List *)l)->lh_Tail, \
51 ((struct Node *)n)->ln_Pred = ((struct List *)l)->lh_TailPred, \
52 ((struct List *)l)->lh_TailPred->ln_Succ = ((struct Node *)n), \
53 ((struct List *)l)->lh_TailPred = ((struct Node *)n) ))
55 # define REMOVE(n) ((void)(\
56 ((struct Node *)n)->ln_Pred->ln_Succ = ((struct Node *)n)->ln_Succ,\
57 ((struct Node *)n)->ln_Succ->ln_Pred = ((struct Node *)n)->ln_Pred ))
59 # define GetHead(l) (void *)(((struct List *)l)->lh_Head->ln_Succ \
60 ? ((struct List *)l)->lh_Head \
61 : (struct Node *)0)
62 # define GetTail(l) (void *)(((struct List *)l)->lh_TailPred->ln_Pred \
63 ? ((struct List *)l)->lh_TailPred \
64 : (struct Node *)0)
65 # define GetSucc(n) (void *)(((struct Node *)n)->ln_Succ->ln_Succ \
66 ? ((struct Node *)n)->ln_Succ \
67 : (struct Node *)0)
68 # define GetPred(n) (void *)(((struct Node *)n)->ln_Pred->ln_Pred \
69 ? ((struct Node *)n)->ln_Pred \
70 : (struct Node *)0)
71 # define ForeachNode(l,n) \
72 for (n=(void *)(((struct List *)(l))->lh_Head); \
73 ((struct Node *)(n))->ln_Succ; \
74 n=(void *)(((struct Node *)(n))->ln_Succ))
76 # define ForeachNodeSafe(l,n,n2) \
77 for (n=(void *)(((struct List *)(l))->lh_Head); \
78 (n2=(void *)((struct Node *)(n))->ln_Succ); \
79 n=(void *)n2)
81 # define SetNodeName(node,name) \
82 (((struct Node *)(node))->ln_Name = (char *)(name))
83 # define GetNodeName(node) \
84 (((struct Node *)(node))->ln_Name
86 # define ListLength(list,count) \
87 do { \
88 struct Node * n; \
89 count = 0; \
90 ForeachNode (list,n) count ++; \
91 } while (0)
94 #endif /* EXEC_LISTS_H */