]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/queue.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
34 * Revision 1.1.1.1 1998/09/22 21:05:33 wsanchez
35 * Import of Mac OS X kernel (~semeria)
37 * Revision 1.1.1.1 1998/03/07 02:25:55 wsanchez
38 * Import of OSF Mach kernel (~mburg)
40 * Revision 1.1.10.3 1995/03/15 17:21:19 bruel
41 * compile only if !__GNUC__.
44 * Revision 1.1.10.2 1995/01/06 19:48:05 devrcs
45 * mk6 CR668 - 1.3b26 merge
46 * * Revision 1.1.3.5 1994/05/06 18:51:43 tmt
47 * Merge in DEC Alpha changes to osc1.3b19.
48 * Merge Alpha changes into osc1.312b source code.
49 * Remove ifdef sun around insque and remque.
51 * [1994/11/04 09:29:15 dwm]
53 * Revision 1.1.10.1 1994/09/23 02:25:00 ezf
54 * change marker to not FREE
55 * [1994/09/22 21:35:34 ezf]
57 * Revision 1.1.3.3 1993/07/28 17:16:26 bernard
58 * CR9523 -- Prototypes.
59 * [1993/07/21 17:00:38 bernard]
61 * Revision 1.1.3.2 1993/06/02 23:39:41 jeffc
62 * Added to OSF/1 R1.3 from NMK15.0.
63 * [1993/06/02 21:13:58 jeffc]
65 * Revision 1.1 1992/09/30 02:09:52 robert
72 * Revision 2.4 91/05/14 16:45:45 mrt
73 * Correcting copyright
75 * Revision 2.3 91/05/08 12:48:22 dbg
76 * Compile queue routines on vax.
79 * Revision 2.2 91/02/05 17:28:38 mrt
80 * Changed to new Mach copyright
81 * [91/02/01 16:16:22 mrt]
83 * Revision 2.1 89/08/03 15:51:47 rwd
86 * 17-Mar-87 David Golub (dbg) at Carnegie-Mellon University
87 * Created from routines written by David L. Black.
92 * Mach Operating System
93 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
94 * All Rights Reserved.
96 * Permission to use, copy, modify and distribute this software and its
97 * documentation is hereby granted, provided that both the copyright
98 * notice and this permission notice appear in all copies of the
99 * software, derivative works or modified versions, and any portions
100 * thereof, and that both notices appear in supporting documentation.
102 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
103 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
104 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
106 * Carnegie Mellon requests users of this software to return to
108 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
109 * School of Computer Science
110 * Carnegie Mellon University
111 * Pittsburgh PA 15213-3890
113 * any improvements or extensions that they make and grant Carnegie Mellon
114 * the rights to redistribute these changes.
120 * Routines to implement queue package.
123 #include <kern/queue.h>
125 #if !defined(__GNUC__)
128 * Insert element at head of queue.
132 register queue_t que
,
133 register queue_entry_t elt
)
135 elt
->next
= que
->next
;
137 elt
->next
->prev
= elt
;
142 * Insert element at tail of queue.
146 register queue_t que
,
147 register queue_entry_t elt
)
150 elt
->prev
= que
->prev
;
151 elt
->prev
->next
= elt
;
156 * Remove and return element at head of queue.
160 register queue_t que
)
162 register queue_entry_t elt
;
164 if (que
->next
== que
)
165 return((queue_entry_t
)0);
168 elt
->next
->prev
= que
;
169 que
->next
= elt
->next
;
174 * Remove and return element at tail of queue.
178 register queue_t que
)
180 register queue_entry_t elt
;
182 if (que
->prev
== que
)
183 return((queue_entry_t
)0);
186 elt
->prev
->next
= que
;
187 que
->prev
= elt
->prev
;
192 * Remove arbitrary element from queue.
193 * Does not check whether element is on queue - the world
194 * will go haywire if it isn't.
201 register queue_entry_t elt
)
203 elt
->next
->prev
= elt
->prev
;
204 elt
->prev
->next
= elt
->next
;
208 * Routines to directly imitate the VAX hardware queue
213 register queue_entry_t entry
,
214 register queue_entry_t pred
)
216 entry
->next
= pred
->next
;
218 (pred
->next
)->prev
= entry
;
224 register queue_entry_t elt
)
226 (elt
->next
)->prev
= elt
->prev
;
227 (elt
->prev
)->next
= elt
->next
;