xref: /titanic_50/usr/src/uts/common/avs/ns/solaris/nsc_list.c (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * Generic lists
28  * Lists are circular, doubly-linked, with headers.
29  * When a list is empty, both pointers in the header
30  * point to the header itself.
31  */
32 
33 #include "nsc_list.h"
34 /*
35  * void
36  * ls_remove(ls_elt_t *)
37  *	Unlink donated element for list.
38  *
39  * Calling/Exit State:
40  *	Resets elements pointers to empty list state.
41  */
42 void
ls_remove(ls_elt_t * p)43 ls_remove(ls_elt_t *p)
44 {
45 	p->ls_prev->ls_next = p->ls_next;
46 	p->ls_next->ls_prev = p->ls_prev;
47 	LS_INIT(p);
48 }
49 /*
50  * void
51  * ls_ins_after(ls_elt_t *, ls_elt_t *)
52  *
53  *	Link new into list after old.
54  *
55  * Calling/Exit State:
56  *
57  *	None.
58  */
59 void
ls_ins_after(ls_elt_t * old,ls_elt_t * new)60 ls_ins_after(ls_elt_t *old, ls_elt_t *new)
61 {
62 	new->ls_next = old->ls_next;
63 	new->ls_prev = old;
64 	new->ls_next->ls_prev = new;
65 	new->ls_prev->ls_next = new;
66 }
67 
68 
69 /*
70  * void
71  * ls_ins_before(ls_elt_t *, ls_elt_t *)
72  *	Link new into list after old.
73  *
74  * Calling/Exit State:
75  *
76  *	None.
77  */
78 void
ls_ins_before(ls_elt_t * old,ls_elt_t * new)79 ls_ins_before(ls_elt_t *old, ls_elt_t *new)
80 {
81 	new->ls_prev = old->ls_prev;
82 	new->ls_next = old;
83 	new->ls_prev->ls_next = new;
84 	new->ls_next->ls_prev = new;
85 }
86