xref: /onnv-gate/usr/src/uts/intel/io/dktp/hba/ghd/ghd_queue.h (revision 1709:39a1331cb1e3)
1*1709Smlf /*
2*1709Smlf  * CDDL HEADER START
3*1709Smlf  *
4*1709Smlf  * The contents of this file are subject to the terms of the
5*1709Smlf  * Common Development and Distribution License (the "License").
6*1709Smlf  * You may not use this file except in compliance with the License.
7*1709Smlf  *
8*1709Smlf  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1709Smlf  * or http://www.opensolaris.org/os/licensing.
10*1709Smlf  * See the License for the specific language governing permissions
11*1709Smlf  * and limitations under the License.
12*1709Smlf  *
13*1709Smlf  * When distributing Covered Code, include this CDDL HEADER in each
14*1709Smlf  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1709Smlf  * If applicable, add the following below this CDDL HEADER, with the
16*1709Smlf  * fields enclosed by brackets "[]" replaced with your own identifying
17*1709Smlf  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1709Smlf  *
19*1709Smlf  * CDDL HEADER END
20*1709Smlf  */
21*1709Smlf 
22*1709Smlf /*
23*1709Smlf  * Copyright 1999 Sun Microsystems, Inc.  All rights reserved.
24*1709Smlf  * Use is subject to license terms.
25*1709Smlf  */
26*1709Smlf 
27*1709Smlf #ifndef _GHD_QUEUE_H
28*1709Smlf #define	_GHD_QUEUE_H
29*1709Smlf 
30*1709Smlf #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1709Smlf 
32*1709Smlf #ifdef	__cplusplus
33*1709Smlf extern "C" {
34*1709Smlf #endif
35*1709Smlf 
36*1709Smlf 
37*1709Smlf /*
38*1709Smlf  *  A list of singly linked elements
39*1709Smlf  */
40*1709Smlf 
41*1709Smlf typedef struct L1el {
42*1709Smlf 	struct L1el	*le_nextp;
43*1709Smlf 	void		*le_datap;
44*1709Smlf } L1el_t;
45*1709Smlf 
46*1709Smlf #define	L1EL_INIT(lep)	((lep)->le_nextp = NULL, (lep)->le_datap = 0)
47*1709Smlf 
48*1709Smlf typedef struct L1_head {
49*1709Smlf 	L1el_t	*l1_headp;
50*1709Smlf 	L1el_t	*l1_tailp;
51*1709Smlf } L1_t;
52*1709Smlf 
53*1709Smlf #define	L1HEADER_INIT(lp) (((lp)->l1_headp = NULL), ((lp)->l1_tailp = NULL))
54*1709Smlf #define	L1_EMPTY(lp)	((lp)->l1_headp == NULL)
55*1709Smlf 
56*1709Smlf void	 L1_add(L1_t *lp, L1el_t *lep, void *datap);
57*1709Smlf void	 L1_delete(L1_t *lp, L1el_t *lep);
58*1709Smlf void	*L1_remove(L1_t *lp);
59*1709Smlf 
60*1709Smlf 
61*1709Smlf /*
62*1709Smlf  * A list of doubly linked elements
63*1709Smlf  */
64*1709Smlf 
65*1709Smlf typedef struct L2el {
66*1709Smlf 	struct	L2el	*l2_nextp;
67*1709Smlf 	struct	L2el	*l2_prevp;
68*1709Smlf 	void		*l2_private;
69*1709Smlf } L2el_t;
70*1709Smlf 
71*1709Smlf #define	L2_INIT(headp)	\
72*1709Smlf 	(((headp)->l2_nextp = (headp)), ((headp)->l2_prevp = (headp)))
73*1709Smlf 
74*1709Smlf #define	L2_EMPTY(headp) ((headp)->l2_nextp == (headp))
75*1709Smlf 
76*1709Smlf void	L2_add(L2el_t *headp, L2el_t *elementp, void *private);
77*1709Smlf void	L2_delete(L2el_t *elementp);
78*1709Smlf void	L2_add_head(L2el_t *headp, L2el_t *elementp, void *private);
79*1709Smlf void	*L2_remove_head(L2el_t *headp);
80*1709Smlf void	*L2_next(L2el_t *elementp);
81*1709Smlf 
82*1709Smlf 
83*1709Smlf #ifdef	__cplusplus
84*1709Smlf }
85*1709Smlf #endif
86*1709Smlf #endif  /* _GHD_QUEUE_H */
87