]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/queue.c
9a5842450adac24c14ca26a5669034234c960ff3
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
36 * Revision 1.1.1.1 1998/09/22 21:05:33 wsanchez
37 * Import of Mac OS X kernel (~semeria)
39 * Revision 1.1.1.1 1998/03/07 02:25:55 wsanchez
40 * Import of OSF Mach kernel (~mburg)
42 * Revision 1.1.10.3 1995/03/15 17:21:19 bruel
43 * compile only if !__GNUC__.
46 * Revision 1.1.10.2 1995/01/06 19:48:05 devrcs
47 * mk6 CR668 - 1.3b26 merge
48 * * Revision 1.1.3.5 1994/05/06 18:51:43 tmt
49 * Merge in DEC Alpha changes to osc1.3b19.
50 * Merge Alpha changes into osc1.312b source code.
51 * Remove ifdef sun around insque and remque.
53 * [1994/11/04 09:29:15 dwm]
55 * Revision 1.1.10.1 1994/09/23 02:25:00 ezf
56 * change marker to not FREE
57 * [1994/09/22 21:35:34 ezf]
59 * Revision 1.1.3.3 1993/07/28 17:16:26 bernard
60 * CR9523 -- Prototypes.
61 * [1993/07/21 17:00:38 bernard]
63 * Revision 1.1.3.2 1993/06/02 23:39:41 jeffc
64 * Added to OSF/1 R1.3 from NMK15.0.
65 * [1993/06/02 21:13:58 jeffc]
67 * Revision 1.1 1992/09/30 02:09:52 robert
74 * Revision 2.4 91/05/14 16:45:45 mrt
75 * Correcting copyright
77 * Revision 2.3 91/05/08 12:48:22 dbg
78 * Compile queue routines on vax.
81 * Revision 2.2 91/02/05 17:28:38 mrt
82 * Changed to new Mach copyright
83 * [91/02/01 16:16:22 mrt]
85 * Revision 2.1 89/08/03 15:51:47 rwd
88 * 17-Mar-87 David Golub (dbg) at Carnegie-Mellon University
89 * Created from routines written by David L. Black.
94 * Mach Operating System
95 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
96 * All Rights Reserved.
98 * Permission to use, copy, modify and distribute this software and its
99 * documentation is hereby granted, provided that both the copyright
100 * notice and this permission notice appear in all copies of the
101 * software, derivative works or modified versions, and any portions
102 * thereof, and that both notices appear in supporting documentation.
104 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
105 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
106 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
108 * Carnegie Mellon requests users of this software to return to
110 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
111 * School of Computer Science
112 * Carnegie Mellon University
113 * Pittsburgh PA 15213-3890
115 * any improvements or extensions that they make and grant Carnegie Mellon
116 * the rights to redistribute these changes.
122 * Routines to implement queue package.
125 #include <kern/queue.h>
127 #if !defined(__GNUC__)
130 * Insert element at head of queue.
134 register queue_t que
,
135 register queue_entry_t elt
)
137 elt
->next
= que
->next
;
139 elt
->next
->prev
= elt
;
144 * Insert element at tail of queue.
148 register queue_t que
,
149 register queue_entry_t elt
)
152 elt
->prev
= que
->prev
;
153 elt
->prev
->next
= elt
;
158 * Remove and return element at head of queue.
162 register queue_t que
)
164 register queue_entry_t elt
;
166 if (que
->next
== que
)
167 return((queue_entry_t
)0);
170 elt
->next
->prev
= que
;
171 que
->next
= elt
->next
;
176 * Remove and return element at tail of queue.
180 register queue_t que
)
182 register queue_entry_t elt
;
184 if (que
->prev
== que
)
185 return((queue_entry_t
)0);
188 elt
->prev
->next
= que
;
189 que
->prev
= elt
->prev
;
194 * Remove arbitrary element from queue.
195 * Does not check whether element is on queue - the world
196 * will go haywire if it isn't.
203 register queue_entry_t elt
)
205 elt
->next
->prev
= elt
->prev
;
206 elt
->prev
->next
= elt
->next
;
210 * Routines to directly imitate the VAX hardware queue
215 register queue_entry_t entry
,
216 register queue_entry_t pred
)
218 entry
->next
= pred
->next
;
220 (pred
->next
)->prev
= entry
;
226 register queue_entry_t elt
)
228 (elt
->next
)->prev
= elt
->prev
;
229 (elt
->prev
)->next
= elt
->next
;