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