3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
34 * General queueing/linking definitions
38 #ifndef _NETATM_QUEUE_H
39 #define _NETATM_QUEUE_H
42 * Structure defining the queue controls for a doubly linked queue
45 caddr_t q_head; /* Head of queue */
46 caddr_t q_tail; /* Tail of queue */
48 typedef struct q_queue Queue_t;
51 * Structure defining the queue elements of a doubly linked queue
54 caddr_t q_forw; /* Forward link */
55 caddr_t q_back; /* Backward link */
57 typedef struct q_elem Qelem_t;
60 * Macro to add a control block onto the tail of a doubly linked queue
61 * e = control block to add
62 * t = control block structure type
63 * el = name of control block's q_elem field
64 * q = pointer to queue controls
66 #define ENQUEUE(e,t,el,q) \
68 (e)->el.q_forw = NULL; \
69 (e)->el.q_back = (q).q_tail; \
70 if ((q).q_head == NULL) { \
71 (q).q_head = (caddr_t)(e); \
72 (q).q_tail = (caddr_t)(e); \
74 ((t *)(q).q_tail)->el.q_forw = (caddr_t)(e); \
75 (q).q_tail = (caddr_t)(e); \
80 * Macro to remove a control block from a doubly linked queue
81 * e = control block to remove
82 * t = control block structure type
83 * el = name of control block's q_elem field
84 * q = pointer to queue controls
86 #define DEQUEUE(e,t,el,q) \
88 /* Ensure control block is on queue */ \
89 if ((e)->el.q_forw || (q).q_tail == (caddr_t)(e)) { \
91 ((t *)(e)->el.q_forw)->el.q_back = (e)->el.q_back;\
93 (q).q_tail = (e)->el.q_back; \
95 ((t *)(e)->el.q_back)->el.q_forw = (e)->el.q_forw;\
97 (q).q_head = (e)->el.q_forw; \
99 (e)->el.q_back = (e)->el.q_forw = NULL; \
103 * Macro to return the head of a doubly linked queue
104 * q = pointer to queue controls
105 * t = control block structure type
107 #define Q_HEAD(q,t) ((t *)(q).q_head)
110 * Macro to return the next control block of a doubly linked queue
111 * e = current control block
112 * t = control block structure type
113 * el = name of control block's q_elem field
115 #define Q_NEXT(e,t,el) ((t *)(e)->el.q_forw)
119 * Macro to add a control block onto the head of a singly linked chain
120 * u = control block to add
123 * l = name of link field
125 #define LINK2HEAD(u,t,h,l) \
132 * Macro to add a control block onto the tail of a singly linked chain
133 * u = control block to add
136 * l = name of link field
138 #define LINK2TAIL(u,t,h,l) \
140 (u)->l = (t *)NULL; \
141 /* Check for empty chain */ \
142 if ((h) == (t *)NULL) { \
146 /* Loop until we find the end of chain */ \
147 for (tp = (h); tp->l != (t *)NULL; tp = tp->l) \
154 * Macro to remove a control block from a singly linked chain
155 * u = control block to unlink
158 * l = name of link field
160 #define UNLINK(u,t,h,l) \
162 /* Check for control block at head of chain */ \
167 /* Loop until we find the control block */ \
168 for (tp = (h); tp != (t *)NULL; tp = tp->l) { \
173 /* Remove it from chain */ \
177 (u)->l = (t *)NULL; \
181 * Macro to remove a control block from a singly linked chain and return
182 * an indication of whether the block was found
183 * u = control block to unlink
186 * l = name of link field
187 * f = flag; 1 => control block found on chain; else 0
189 #define UNLINKF(u,t,h,l,f) \
191 /* Check for control block at head of chain */ \
197 /* Loop until we find the control block */ \
198 for (tp = (h); tp != (t *)NULL; tp = tp->l) { \
203 /* Remove it from chain */ \
207 /* It wasn't on the chain */ \
210 (u)->l = (t *)NULL; \
213 #endif /* _NETATM_QUEUE_H */