]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/queue.c
44cb30dafb7a115a64d4748676f66dba83814704
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
29 * Revision 1.1.1.1 1998/09/22 21:05:33 wsanchez
30 * Import of Mac OS X kernel (~semeria)
32 * Revision 1.1.1.1 1998/03/07 02:25:55 wsanchez
33 * Import of OSF Mach kernel (~mburg)
35 * Revision 1.1.10.3 1995/03/15 17:21:19 bruel
36 * compile only if !__GNUC__.
39 * Revision 1.1.10.2 1995/01/06 19:48:05 devrcs
40 * mk6 CR668 - 1.3b26 merge
41 * * Revision 1.1.3.5 1994/05/06 18:51:43 tmt
42 * Merge in DEC Alpha changes to osc1.3b19.
43 * Merge Alpha changes into osc1.312b source code.
44 * Remove ifdef sun around insque and remque.
46 * [1994/11/04 09:29:15 dwm]
48 * Revision 1.1.10.1 1994/09/23 02:25:00 ezf
49 * change marker to not FREE
50 * [1994/09/22 21:35:34 ezf]
52 * Revision 1.1.3.3 1993/07/28 17:16:26 bernard
53 * CR9523 -- Prototypes.
54 * [1993/07/21 17:00:38 bernard]
56 * Revision 1.1.3.2 1993/06/02 23:39:41 jeffc
57 * Added to OSF/1 R1.3 from NMK15.0.
58 * [1993/06/02 21:13:58 jeffc]
60 * Revision 1.1 1992/09/30 02:09:52 robert
67 * Revision 2.4 91/05/14 16:45:45 mrt
68 * Correcting copyright
70 * Revision 2.3 91/05/08 12:48:22 dbg
71 * Compile queue routines on vax.
74 * Revision 2.2 91/02/05 17:28:38 mrt
75 * Changed to new Mach copyright
76 * [91/02/01 16:16:22 mrt]
78 * Revision 2.1 89/08/03 15:51:47 rwd
81 * 17-Mar-87 David Golub (dbg) at Carnegie-Mellon University
82 * Created from routines written by David L. Black.
87 * Mach Operating System
88 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
89 * All Rights Reserved.
91 * Permission to use, copy, modify and distribute this software and its
92 * documentation is hereby granted, provided that both the copyright
93 * notice and this permission notice appear in all copies of the
94 * software, derivative works or modified versions, and any portions
95 * thereof, and that both notices appear in supporting documentation.
97 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
98 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
99 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
101 * Carnegie Mellon requests users of this software to return to
103 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
104 * School of Computer Science
105 * Carnegie Mellon University
106 * Pittsburgh PA 15213-3890
108 * any improvements or extensions that they make and grant Carnegie Mellon
109 * the rights to redistribute these changes.
115 * Routines to implement queue package.
118 #include <kern/queue.h>
120 #if !defined(__GNUC__)
123 * Insert element at head of queue.
127 register queue_t que
,
128 register queue_entry_t elt
)
130 elt
->next
= que
->next
;
132 elt
->next
->prev
= elt
;
137 * Insert element at tail of queue.
141 register queue_t que
,
142 register queue_entry_t elt
)
145 elt
->prev
= que
->prev
;
146 elt
->prev
->next
= elt
;
151 * Remove and return element at head of queue.
155 register queue_t que
)
157 register queue_entry_t elt
;
159 if (que
->next
== que
)
160 return((queue_entry_t
)0);
163 elt
->next
->prev
= que
;
164 que
->next
= elt
->next
;
169 * Remove and return element at tail of queue.
173 register queue_t que
)
175 register queue_entry_t elt
;
177 if (que
->prev
== que
)
178 return((queue_entry_t
)0);
181 elt
->prev
->next
= que
;
182 que
->prev
= elt
->prev
;
187 * Remove arbitrary element from queue.
188 * Does not check whether element is on queue - the world
189 * will go haywire if it isn't.
196 register queue_entry_t elt
)
198 elt
->next
->prev
= elt
->prev
;
199 elt
->prev
->next
= elt
->next
;
203 * Routines to directly imitate the VAX hardware queue
208 register queue_entry_t entry
,
209 register queue_entry_t pred
)
211 entry
->next
= pred
->next
;
213 (pred
->next
)->prev
= entry
;
219 register queue_entry_t elt
)
221 (elt
->next
)->prev
= elt
->prev
;
222 (elt
->prev
)->next
= elt
->next
;