]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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 | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
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. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * @OSF_COPYRIGHT@ | |
32 | */ | |
33 | /* | |
34 | * HISTORY | |
35 | * | |
36 | * Revision 1.1.1.1 1998/09/22 21:05:33 wsanchez | |
37 | * Import of Mac OS X kernel (~semeria) | |
38 | * | |
39 | * Revision 1.1.1.1 1998/03/07 02:25:55 wsanchez | |
40 | * Import of OSF Mach kernel (~mburg) | |
41 | * | |
42 | * Revision 1.1.10.3 1995/03/15 17:21:19 bruel | |
43 | * compile only if !__GNUC__. | |
44 | * [95/03/09 bruel] | |
45 | * | |
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. | |
52 | * * End1.3merge | |
53 | * [1994/11/04 09:29:15 dwm] | |
54 | * | |
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] | |
58 | * | |
59 | * Revision 1.1.3.3 1993/07/28 17:16:26 bernard | |
60 | * CR9523 -- Prototypes. | |
61 | * [1993/07/21 17:00:38 bernard] | |
62 | * | |
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] | |
66 | * | |
67 | * Revision 1.1 1992/09/30 02:09:52 robert | |
68 | * Initial revision | |
69 | * | |
70 | * $EndLog$ | |
71 | */ | |
72 | /* CMU_HIST */ | |
73 | /* | |
74 | * Revision 2.4 91/05/14 16:45:45 mrt | |
75 | * Correcting copyright | |
76 | * | |
77 | * Revision 2.3 91/05/08 12:48:22 dbg | |
78 | * Compile queue routines on vax. | |
79 | * [91/03/26 dbg] | |
80 | * | |
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] | |
84 | * | |
85 | * Revision 2.1 89/08/03 15:51:47 rwd | |
86 | * Created. | |
87 | * | |
88 | * 17-Mar-87 David Golub (dbg) at Carnegie-Mellon University | |
89 | * Created from routines written by David L. Black. | |
90 | * | |
91 | */ | |
92 | /* CMU_ENDHIST */ | |
93 | /* | |
94 | * Mach Operating System | |
95 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University | |
96 | * All Rights Reserved. | |
97 | * | |
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. | |
103 | * | |
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. | |
107 | * | |
108 | * Carnegie Mellon requests users of this software to return to | |
109 | * | |
110 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
111 | * School of Computer Science | |
112 | * Carnegie Mellon University | |
113 | * Pittsburgh PA 15213-3890 | |
114 | * | |
115 | * any improvements or extensions that they make and grant Carnegie Mellon | |
116 | * the rights to redistribute these changes. | |
117 | */ | |
118 | /* | |
119 | */ | |
120 | ||
121 | /* | |
122 | * Routines to implement queue package. | |
123 | */ | |
124 | ||
125 | #include <kern/queue.h> | |
126 | ||
127 | #if !defined(__GNUC__) | |
128 | ||
129 | /* | |
130 | * Insert element at head of queue. | |
131 | */ | |
132 | void | |
133 | enqueue_head( | |
134 | register queue_t que, | |
135 | register queue_entry_t elt) | |
136 | { | |
137 | elt->next = que->next; | |
138 | elt->prev = que; | |
139 | elt->next->prev = elt; | |
140 | que->next = elt; | |
141 | } | |
142 | ||
143 | /* | |
144 | * Insert element at tail of queue. | |
145 | */ | |
146 | void | |
147 | enqueue_tail( | |
148 | register queue_t que, | |
149 | register queue_entry_t elt) | |
150 | { | |
151 | elt->next = que; | |
152 | elt->prev = que->prev; | |
153 | elt->prev->next = elt; | |
154 | que->prev = elt; | |
155 | } | |
156 | ||
157 | /* | |
158 | * Remove and return element at head of queue. | |
159 | */ | |
160 | queue_entry_t | |
161 | dequeue_head( | |
162 | register queue_t que) | |
163 | { | |
164 | register queue_entry_t elt; | |
165 | ||
166 | if (que->next == que) | |
167 | return((queue_entry_t)0); | |
168 | ||
169 | elt = que->next; | |
170 | elt->next->prev = que; | |
171 | que->next = elt->next; | |
172 | return(elt); | |
173 | } | |
174 | ||
175 | /* | |
176 | * Remove and return element at tail of queue. | |
177 | */ | |
178 | queue_entry_t | |
179 | dequeue_tail( | |
180 | register queue_t que) | |
181 | { | |
182 | register queue_entry_t elt; | |
183 | ||
184 | if (que->prev == que) | |
185 | return((queue_entry_t)0); | |
186 | ||
187 | elt = que->prev; | |
188 | elt->prev->next = que; | |
189 | que->prev = elt->prev; | |
190 | return(elt); | |
191 | } | |
192 | ||
193 | /* | |
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. | |
197 | */ | |
198 | ||
199 | /*ARGSUSED*/ | |
200 | void | |
201 | remqueue( | |
202 | queue_t que, | |
203 | register queue_entry_t elt) | |
204 | { | |
205 | elt->next->prev = elt->prev; | |
206 | elt->prev->next = elt->next; | |
207 | } | |
208 | ||
209 | /* | |
210 | * Routines to directly imitate the VAX hardware queue | |
211 | * package. | |
212 | */ | |
213 | void | |
214 | insque( | |
215 | register queue_entry_t entry, | |
216 | register queue_entry_t pred) | |
217 | { | |
218 | entry->next = pred->next; | |
219 | entry->prev = pred; | |
220 | (pred->next)->prev = entry; | |
221 | pred->next = entry; | |
222 | } | |
223 | ||
224 | int | |
225 | remque( | |
226 | register queue_entry_t elt) | |
227 | { | |
228 | (elt->next)->prev = elt->prev; | |
229 | (elt->prev)->next = elt->next; | |
230 | return((int)elt); | |
231 | } | |
232 | ||
233 | #endif |