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.
26 * @(#) $FreeBSD: src/sys/netatm/queue.h,v 1.2 1999/08/28 00:48:41 peter Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/queue.h,v 1.2 2003/06/17 04:28:49 dillon Exp $
35 * General queueing/linking definitions
39 #ifndef _NETATM_QUEUE_H
40 #define _NETATM_QUEUE_H
43 * Structure defining the queue controls for a doubly linked queue
46 caddr_t q_head; /* Head of queue */
47 caddr_t q_tail; /* Tail of queue */
49 typedef struct q_queue Queue_t;
52 * Structure defining the queue elements of a doubly linked queue
55 caddr_t q_forw; /* Forward link */
56 caddr_t q_back; /* Backward link */
58 typedef struct q_elem Qelem_t;
61 * Macro to add a control block onto the tail of a doubly linked queue
62 * e = control block to add
63 * t = control block structure type
64 * el = name of control block's q_elem field
65 * q = pointer to queue controls
67 #define ENQUEUE(e,t,el,q) \
69 (e)->el.q_forw = NULL; \
70 (e)->el.q_back = (q).q_tail; \
71 if ((q).q_head == NULL) { \
72 (q).q_head = (caddr_t)(e); \
73 (q).q_tail = (caddr_t)(e); \
75 ((t *)(q).q_tail)->el.q_forw = (caddr_t)(e); \
76 (q).q_tail = (caddr_t)(e); \
81 * Macro to remove a control block from a doubly linked queue
82 * e = control block to remove
83 * t = control block structure type
84 * el = name of control block's q_elem field
85 * q = pointer to queue controls
87 #define DEQUEUE(e,t,el,q) \
89 /* Ensure control block is on queue */ \
90 if ((e)->el.q_forw || (q).q_tail == (caddr_t)(e)) { \
92 ((t *)(e)->el.q_forw)->el.q_back = (e)->el.q_back;\
94 (q).q_tail = (e)->el.q_back; \
96 ((t *)(e)->el.q_back)->el.q_forw = (e)->el.q_forw;\
98 (q).q_head = (e)->el.q_forw; \
100 (e)->el.q_back = (e)->el.q_forw = NULL; \
104 * Macro to return the head of a doubly linked queue
105 * q = pointer to queue controls
106 * t = control block structure type
108 #define Q_HEAD(q,t) ((t *)(q).q_head)
111 * Macro to return the next control block of a doubly linked queue
112 * e = current control block
113 * t = control block structure type
114 * el = name of control block's q_elem field
116 #define Q_NEXT(e,t,el) ((t *)(e)->el.q_forw)
120 * Macro to add a control block onto the head of a singly linked chain
121 * u = control block to add
124 * l = name of link field
126 #define LINK2HEAD(u,t,h,l) \
133 * Macro to add a control block onto the tail of a singly linked chain
134 * u = control block to add
137 * l = name of link field
139 #define LINK2TAIL(u,t,h,l) \
141 (u)->l = (t *)NULL; \
142 /* Check for empty chain */ \
143 if ((h) == (t *)NULL) { \
147 /* Loop until we find the end of chain */ \
148 for (tp = (h); tp->l != (t *)NULL; tp = tp->l) \
155 * Macro to remove a control block from a singly linked chain
156 * u = control block to unlink
159 * l = name of link field
161 #define UNLINK(u,t,h,l) \
163 /* Check for control block at head of chain */ \
168 /* Loop until we find the control block */ \
169 for (tp = (h); tp != (t *)NULL; tp = tp->l) { \
174 /* Remove it from chain */ \
178 (u)->l = (t *)NULL; \
182 * Macro to remove a control block from a singly linked chain and return
183 * an indication of whether the block was found
184 * u = control block to unlink
187 * l = name of link field
188 * f = flag; 1 => control block found on chain; else 0
190 #define UNLINKF(u,t,h,l,f) \
192 /* Check for control block at head of chain */ \
198 /* Loop until we find the control block */ \
199 for (tp = (h); tp != (t *)NULL; tp = tp->l) { \
204 /* Remove it from chain */ \
208 /* It wasn't on the chain */ \
211 (u)->l = (t *)NULL; \
214 #endif /* _NETATM_QUEUE_H */