]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/queue.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
31 * Revision 1.1.1.1 1998/09/22 21:05:33 wsanchez
32 * Import of Mac OS X kernel (~semeria)
34 * Revision 1.1.1.1 1998/03/07 02:25:55 wsanchez
35 * Import of OSF Mach kernel (~mburg)
37 * Revision 1.1.10.3 1995/03/15 17:21:19 bruel
38 * compile only if !__GNUC__.
41 * Revision 1.1.10.2 1995/01/06 19:48:05 devrcs
42 * mk6 CR668 - 1.3b26 merge
43 * * Revision 1.1.3.5 1994/05/06 18:51:43 tmt
44 * Merge in DEC Alpha changes to osc1.3b19.
45 * Merge Alpha changes into osc1.312b source code.
46 * Remove ifdef sun around insque and remque.
48 * [1994/11/04 09:29:15 dwm]
50 * Revision 1.1.10.1 1994/09/23 02:25:00 ezf
51 * change marker to not FREE
52 * [1994/09/22 21:35:34 ezf]
54 * Revision 1.1.3.3 1993/07/28 17:16:26 bernard
55 * CR9523 -- Prototypes.
56 * [1993/07/21 17:00:38 bernard]
58 * Revision 1.1.3.2 1993/06/02 23:39:41 jeffc
59 * Added to OSF/1 R1.3 from NMK15.0.
60 * [1993/06/02 21:13:58 jeffc]
62 * Revision 1.1 1992/09/30 02:09:52 robert
69 * Revision 2.4 91/05/14 16:45:45 mrt
70 * Correcting copyright
72 * Revision 2.3 91/05/08 12:48:22 dbg
73 * Compile queue routines on vax.
76 * Revision 2.2 91/02/05 17:28:38 mrt
77 * Changed to new Mach copyright
78 * [91/02/01 16:16:22 mrt]
80 * Revision 2.1 89/08/03 15:51:47 rwd
83 * 17-Mar-87 David Golub (dbg) at Carnegie-Mellon University
84 * Created from routines written by David L. Black.
89 * Mach Operating System
90 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
91 * All Rights Reserved.
93 * Permission to use, copy, modify and distribute this software and its
94 * documentation is hereby granted, provided that both the copyright
95 * notice and this permission notice appear in all copies of the
96 * software, derivative works or modified versions, and any portions
97 * thereof, and that both notices appear in supporting documentation.
99 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
100 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
101 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
103 * Carnegie Mellon requests users of this software to return to
105 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
106 * School of Computer Science
107 * Carnegie Mellon University
108 * Pittsburgh PA 15213-3890
110 * any improvements or extensions that they make and grant Carnegie Mellon
111 * the rights to redistribute these changes.
117 * Routines to implement queue package.
120 #include <kern/queue.h>
122 #if !defined(__GNUC__)
125 * Insert element at head of queue.
129 register queue_t que
,
130 register queue_entry_t elt
)
132 elt
->next
= que
->next
;
134 elt
->next
->prev
= elt
;
139 * Insert element at tail of queue.
143 register queue_t que
,
144 register queue_entry_t elt
)
147 elt
->prev
= que
->prev
;
148 elt
->prev
->next
= elt
;
153 * Remove and return element at head of queue.
157 register queue_t que
)
159 register queue_entry_t elt
;
161 if (que
->next
== que
)
162 return((queue_entry_t
)0);
165 elt
->next
->prev
= que
;
166 que
->next
= elt
->next
;
171 * Remove and return element at tail of queue.
175 register queue_t que
)
177 register queue_entry_t elt
;
179 if (que
->prev
== que
)
180 return((queue_entry_t
)0);
183 elt
->prev
->next
= que
;
184 que
->prev
= elt
->prev
;
189 * Remove arbitrary element from queue.
190 * Does not check whether element is on queue - the world
191 * will go haywire if it isn't.
198 register queue_entry_t elt
)
200 elt
->next
->prev
= elt
->prev
;
201 elt
->prev
->next
= elt
->next
;
205 * Routines to directly imitate the VAX hardware queue
210 register queue_entry_t entry
,
211 register queue_entry_t pred
)
213 entry
->next
= pred
->next
;
215 (pred
->next
)->prev
= entry
;
221 register queue_entry_t elt
)
223 (elt
->next
)->prev
= elt
->prev
;
224 (elt
->prev
)->next
= elt
->next
;