1 |
commit: 03c401b573029575f6cf59d709a562f719ad50b1 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 29 15:37:37 2018 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Dec 29 15:37:37 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03c401b5 |
7 |
|
8 |
sys-libs/queue-standalone: initial commit |
9 |
|
10 |
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org> |
11 |
|
12 |
sys-libs/queue-standalone/files/queue.h | 574 +++++++++++++++++++++ |
13 |
sys-libs/queue-standalone/metadata.xml | 8 + |
14 |
.../queue-standalone/queue-standalone-0.1.ebuild | 22 + |
15 |
3 files changed, 604 insertions(+) |
16 |
|
17 |
diff --git a/sys-libs/queue-standalone/files/queue.h b/sys-libs/queue-standalone/files/queue.h |
18 |
new file mode 100644 |
19 |
index 00000000000..daf4553d33e |
20 |
--- /dev/null |
21 |
+++ b/sys-libs/queue-standalone/files/queue.h |
22 |
@@ -0,0 +1,574 @@ |
23 |
+/* |
24 |
+ * Copyright (c) 1991, 1993 |
25 |
+ * The Regents of the University of California. All rights reserved. |
26 |
+ * |
27 |
+ * Redistribution and use in source and binary forms, with or without |
28 |
+ * modification, are permitted provided that the following conditions |
29 |
+ * are met: |
30 |
+ * 1. Redistributions of source code must retain the above copyright |
31 |
+ * notice, this list of conditions and the following disclaimer. |
32 |
+ * 2. Redistributions in binary form must reproduce the above copyright |
33 |
+ * notice, this list of conditions and the following disclaimer in the |
34 |
+ * documentation and/or other materials provided with the distribution. |
35 |
+ * 3. Neither the name of the University nor the names of its contributors |
36 |
+ * may be used to endorse or promote products derived from this software |
37 |
+ * without specific prior written permission. |
38 |
+ * |
39 |
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
40 |
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
41 |
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
42 |
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
43 |
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
44 |
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
45 |
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
46 |
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
47 |
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
48 |
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
49 |
+ * SUCH DAMAGE. |
50 |
+ * |
51 |
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94 |
52 |
+ */ |
53 |
+ |
54 |
+#ifndef _SYS_QUEUE_H_ |
55 |
+#define _SYS_QUEUE_H_ |
56 |
+ |
57 |
+/* |
58 |
+ * This file defines five types of data structures: singly-linked lists, |
59 |
+ * lists, simple queues, tail queues, and circular queues. |
60 |
+ * |
61 |
+ * A singly-linked list is headed by a single forward pointer. The |
62 |
+ * elements are singly linked for minimum space and pointer manipulation |
63 |
+ * overhead at the expense of O(n) removal for arbitrary elements. New |
64 |
+ * elements can be added to the list after an existing element or at the |
65 |
+ * head of the list. Elements being removed from the head of the list |
66 |
+ * should use the explicit macro for this purpose for optimum |
67 |
+ * efficiency. A singly-linked list may only be traversed in the forward |
68 |
+ * direction. Singly-linked lists are ideal for applications with large |
69 |
+ * datasets and few or no removals or for implementing a LIFO queue. |
70 |
+ * |
71 |
+ * A list is headed by a single forward pointer (or an array of forward |
72 |
+ * pointers for a hash table header). The elements are doubly linked |
73 |
+ * so that an arbitrary element can be removed without a need to |
74 |
+ * traverse the list. New elements can be added to the list before |
75 |
+ * or after an existing element or at the head of the list. A list |
76 |
+ * may only be traversed in the forward direction. |
77 |
+ * |
78 |
+ * A simple queue is headed by a pair of pointers, one the head of the |
79 |
+ * list and the other to the tail of the list. The elements are singly |
80 |
+ * linked to save space, so elements can only be removed from the |
81 |
+ * head of the list. New elements can be added to the list after |
82 |
+ * an existing element, at the head of the list, or at the end of the |
83 |
+ * list. A simple queue may only be traversed in the forward direction. |
84 |
+ * |
85 |
+ * A tail queue is headed by a pair of pointers, one to the head of the |
86 |
+ * list and the other to the tail of the list. The elements are doubly |
87 |
+ * linked so that an arbitrary element can be removed without a need to |
88 |
+ * traverse the list. New elements can be added to the list before or |
89 |
+ * after an existing element, at the head of the list, or at the end of |
90 |
+ * the list. A tail queue may be traversed in either direction. |
91 |
+ * |
92 |
+ * A circle queue is headed by a pair of pointers, one to the head of the |
93 |
+ * list and the other to the tail of the list. The elements are doubly |
94 |
+ * linked so that an arbitrary element can be removed without a need to |
95 |
+ * traverse the list. New elements can be added to the list before or after |
96 |
+ * an existing element, at the head of the list, or at the end of the list. |
97 |
+ * A circle queue may be traversed in either direction, but has a more |
98 |
+ * complex end of list detection. |
99 |
+ * |
100 |
+ * For details on the use of these macros, see the queue(3) manual page. |
101 |
+ */ |
102 |
+ |
103 |
+/* |
104 |
+ * List definitions. |
105 |
+ */ |
106 |
+#define LIST_HEAD(name, type) \ |
107 |
+struct name { \ |
108 |
+ struct type *lh_first; /* first element */ \ |
109 |
+} |
110 |
+ |
111 |
+#define LIST_HEAD_INITIALIZER(head) \ |
112 |
+ { NULL } |
113 |
+ |
114 |
+#define LIST_ENTRY(type) \ |
115 |
+struct { \ |
116 |
+ struct type *le_next; /* next element */ \ |
117 |
+ struct type **le_prev; /* address of previous next element */ \ |
118 |
+} |
119 |
+ |
120 |
+/* |
121 |
+ * List functions. |
122 |
+ */ |
123 |
+#define LIST_INIT(head) do { \ |
124 |
+ (head)->lh_first = NULL; \ |
125 |
+} while (/*CONSTCOND*/0) |
126 |
+ |
127 |
+#define LIST_INSERT_AFTER(listelm, elm, field) do { \ |
128 |
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ |
129 |
+ (listelm)->field.le_next->field.le_prev = \ |
130 |
+ &(elm)->field.le_next; \ |
131 |
+ (listelm)->field.le_next = (elm); \ |
132 |
+ (elm)->field.le_prev = &(listelm)->field.le_next; \ |
133 |
+} while (/*CONSTCOND*/0) |
134 |
+ |
135 |
+#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ |
136 |
+ (elm)->field.le_prev = (listelm)->field.le_prev; \ |
137 |
+ (elm)->field.le_next = (listelm); \ |
138 |
+ *(listelm)->field.le_prev = (elm); \ |
139 |
+ (listelm)->field.le_prev = &(elm)->field.le_next; \ |
140 |
+} while (/*CONSTCOND*/0) |
141 |
+ |
142 |
+#define LIST_INSERT_HEAD(head, elm, field) do { \ |
143 |
+ if (((elm)->field.le_next = (head)->lh_first) != NULL) \ |
144 |
+ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ |
145 |
+ (head)->lh_first = (elm); \ |
146 |
+ (elm)->field.le_prev = &(head)->lh_first; \ |
147 |
+} while (/*CONSTCOND*/0) |
148 |
+ |
149 |
+#define LIST_REMOVE(elm, field) do { \ |
150 |
+ if ((elm)->field.le_next != NULL) \ |
151 |
+ (elm)->field.le_next->field.le_prev = \ |
152 |
+ (elm)->field.le_prev; \ |
153 |
+ *(elm)->field.le_prev = (elm)->field.le_next; \ |
154 |
+} while (/*CONSTCOND*/0) |
155 |
+ |
156 |
+#define LIST_FOREACH(var, head, field) \ |
157 |
+ for ((var) = ((head)->lh_first); \ |
158 |
+ (var); \ |
159 |
+ (var) = ((var)->field.le_next)) |
160 |
+ |
161 |
+/* |
162 |
+ * List access methods. |
163 |
+ */ |
164 |
+#define LIST_EMPTY(head) ((head)->lh_first == NULL) |
165 |
+#define LIST_FIRST(head) ((head)->lh_first) |
166 |
+#define LIST_NEXT(elm, field) ((elm)->field.le_next) |
167 |
+ |
168 |
+ |
169 |
+/* |
170 |
+ * Singly-linked List definitions. |
171 |
+ */ |
172 |
+#define SLIST_HEAD(name, type) \ |
173 |
+struct name { \ |
174 |
+ struct type *slh_first; /* first element */ \ |
175 |
+} |
176 |
+ |
177 |
+#define SLIST_HEAD_INITIALIZER(head) \ |
178 |
+ { NULL } |
179 |
+ |
180 |
+#define SLIST_ENTRY(type) \ |
181 |
+struct { \ |
182 |
+ struct type *sle_next; /* next element */ \ |
183 |
+} |
184 |
+ |
185 |
+/* |
186 |
+ * Singly-linked List functions. |
187 |
+ */ |
188 |
+#define SLIST_INIT(head) do { \ |
189 |
+ (head)->slh_first = NULL; \ |
190 |
+} while (/*CONSTCOND*/0) |
191 |
+ |
192 |
+#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ |
193 |
+ (elm)->field.sle_next = (slistelm)->field.sle_next; \ |
194 |
+ (slistelm)->field.sle_next = (elm); \ |
195 |
+} while (/*CONSTCOND*/0) |
196 |
+ |
197 |
+#define SLIST_INSERT_HEAD(head, elm, field) do { \ |
198 |
+ (elm)->field.sle_next = (head)->slh_first; \ |
199 |
+ (head)->slh_first = (elm); \ |
200 |
+} while (/*CONSTCOND*/0) |
201 |
+ |
202 |
+#define SLIST_REMOVE_HEAD(head, field) do { \ |
203 |
+ (head)->slh_first = (head)->slh_first->field.sle_next; \ |
204 |
+} while (/*CONSTCOND*/0) |
205 |
+ |
206 |
+#define SLIST_REMOVE(head, elm, type, field) do { \ |
207 |
+ if ((head)->slh_first == (elm)) { \ |
208 |
+ SLIST_REMOVE_HEAD((head), field); \ |
209 |
+ } \ |
210 |
+ else { \ |
211 |
+ struct type *curelm = (head)->slh_first; \ |
212 |
+ while(curelm->field.sle_next != (elm)) \ |
213 |
+ curelm = curelm->field.sle_next; \ |
214 |
+ curelm->field.sle_next = \ |
215 |
+ curelm->field.sle_next->field.sle_next; \ |
216 |
+ } \ |
217 |
+} while (/*CONSTCOND*/0) |
218 |
+ |
219 |
+#define SLIST_FOREACH(var, head, field) \ |
220 |
+ for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) |
221 |
+ |
222 |
+/* |
223 |
+ * Singly-linked List access methods. |
224 |
+ */ |
225 |
+#define SLIST_EMPTY(head) ((head)->slh_first == NULL) |
226 |
+#define SLIST_FIRST(head) ((head)->slh_first) |
227 |
+#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) |
228 |
+ |
229 |
+ |
230 |
+/* |
231 |
+ * Singly-linked Tail queue declarations. |
232 |
+ */ |
233 |
+#define STAILQ_HEAD(name, type) \ |
234 |
+struct name { \ |
235 |
+ struct type *stqh_first; /* first element */ \ |
236 |
+ struct type **stqh_last; /* addr of last next element */ \ |
237 |
+} |
238 |
+ |
239 |
+#define STAILQ_HEAD_INITIALIZER(head) \ |
240 |
+ { NULL, &(head).stqh_first } |
241 |
+ |
242 |
+#define STAILQ_ENTRY(type) \ |
243 |
+struct { \ |
244 |
+ struct type *stqe_next; /* next element */ \ |
245 |
+} |
246 |
+ |
247 |
+/* |
248 |
+ * Singly-linked Tail queue functions. |
249 |
+ */ |
250 |
+#define STAILQ_INIT(head) do { \ |
251 |
+ (head)->stqh_first = NULL; \ |
252 |
+ (head)->stqh_last = &(head)->stqh_first; \ |
253 |
+} while (/*CONSTCOND*/0) |
254 |
+ |
255 |
+#define STAILQ_INSERT_HEAD(head, elm, field) do { \ |
256 |
+ if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ |
257 |
+ (head)->stqh_last = &(elm)->field.stqe_next; \ |
258 |
+ (head)->stqh_first = (elm); \ |
259 |
+} while (/*CONSTCOND*/0) |
260 |
+ |
261 |
+#define STAILQ_INSERT_TAIL(head, elm, field) do { \ |
262 |
+ (elm)->field.stqe_next = NULL; \ |
263 |
+ *(head)->stqh_last = (elm); \ |
264 |
+ (head)->stqh_last = &(elm)->field.stqe_next; \ |
265 |
+} while (/*CONSTCOND*/0) |
266 |
+ |
267 |
+#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
268 |
+ if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ |
269 |
+ (head)->stqh_last = &(elm)->field.stqe_next; \ |
270 |
+ (listelm)->field.stqe_next = (elm); \ |
271 |
+} while (/*CONSTCOND*/0) |
272 |
+ |
273 |
+#define STAILQ_REMOVE_HEAD(head, field) do { \ |
274 |
+ if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ |
275 |
+ (head)->stqh_last = &(head)->stqh_first; \ |
276 |
+} while (/*CONSTCOND*/0) |
277 |
+ |
278 |
+#define STAILQ_REMOVE(head, elm, type, field) do { \ |
279 |
+ if ((head)->stqh_first == (elm)) { \ |
280 |
+ STAILQ_REMOVE_HEAD((head), field); \ |
281 |
+ } else { \ |
282 |
+ struct type *curelm = (head)->stqh_first; \ |
283 |
+ while (curelm->field.stqe_next != (elm)) \ |
284 |
+ curelm = curelm->field.stqe_next; \ |
285 |
+ if ((curelm->field.stqe_next = \ |
286 |
+ curelm->field.stqe_next->field.stqe_next) == NULL) \ |
287 |
+ (head)->stqh_last = &(curelm)->field.stqe_next; \ |
288 |
+ } \ |
289 |
+} while (/*CONSTCOND*/0) |
290 |
+ |
291 |
+#define STAILQ_FOREACH(var, head, field) \ |
292 |
+ for ((var) = ((head)->stqh_first); \ |
293 |
+ (var); \ |
294 |
+ (var) = ((var)->field.stqe_next)) |
295 |
+ |
296 |
+#define STAILQ_CONCAT(head1, head2) do { \ |
297 |
+ if (!STAILQ_EMPTY((head2))) { \ |
298 |
+ *(head1)->stqh_last = (head2)->stqh_first; \ |
299 |
+ (head1)->stqh_last = (head2)->stqh_last; \ |
300 |
+ STAILQ_INIT((head2)); \ |
301 |
+ } \ |
302 |
+} while (/*CONSTCOND*/0) |
303 |
+ |
304 |
+/* |
305 |
+ * Singly-linked Tail queue access methods. |
306 |
+ */ |
307 |
+#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) |
308 |
+#define STAILQ_FIRST(head) ((head)->stqh_first) |
309 |
+#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) |
310 |
+ |
311 |
+ |
312 |
+/* |
313 |
+ * Simple queue definitions. |
314 |
+ */ |
315 |
+#define SIMPLEQ_HEAD(name, type) \ |
316 |
+struct name { \ |
317 |
+ struct type *sqh_first; /* first element */ \ |
318 |
+ struct type **sqh_last; /* addr of last next element */ \ |
319 |
+} |
320 |
+ |
321 |
+#define SIMPLEQ_HEAD_INITIALIZER(head) \ |
322 |
+ { NULL, &(head).sqh_first } |
323 |
+ |
324 |
+#define SIMPLEQ_ENTRY(type) \ |
325 |
+struct { \ |
326 |
+ struct type *sqe_next; /* next element */ \ |
327 |
+} |
328 |
+ |
329 |
+/* |
330 |
+ * Simple queue functions. |
331 |
+ */ |
332 |
+#define SIMPLEQ_INIT(head) do { \ |
333 |
+ (head)->sqh_first = NULL; \ |
334 |
+ (head)->sqh_last = &(head)->sqh_first; \ |
335 |
+} while (/*CONSTCOND*/0) |
336 |
+ |
337 |
+#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ |
338 |
+ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ |
339 |
+ (head)->sqh_last = &(elm)->field.sqe_next; \ |
340 |
+ (head)->sqh_first = (elm); \ |
341 |
+} while (/*CONSTCOND*/0) |
342 |
+ |
343 |
+#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ |
344 |
+ (elm)->field.sqe_next = NULL; \ |
345 |
+ *(head)->sqh_last = (elm); \ |
346 |
+ (head)->sqh_last = &(elm)->field.sqe_next; \ |
347 |
+} while (/*CONSTCOND*/0) |
348 |
+ |
349 |
+#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
350 |
+ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ |
351 |
+ (head)->sqh_last = &(elm)->field.sqe_next; \ |
352 |
+ (listelm)->field.sqe_next = (elm); \ |
353 |
+} while (/*CONSTCOND*/0) |
354 |
+ |
355 |
+#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ |
356 |
+ if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ |
357 |
+ (head)->sqh_last = &(head)->sqh_first; \ |
358 |
+} while (/*CONSTCOND*/0) |
359 |
+ |
360 |
+#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ |
361 |
+ if ((head)->sqh_first == (elm)) { \ |
362 |
+ SIMPLEQ_REMOVE_HEAD((head), field); \ |
363 |
+ } else { \ |
364 |
+ struct type *curelm = (head)->sqh_first; \ |
365 |
+ while (curelm->field.sqe_next != (elm)) \ |
366 |
+ curelm = curelm->field.sqe_next; \ |
367 |
+ if ((curelm->field.sqe_next = \ |
368 |
+ curelm->field.sqe_next->field.sqe_next) == NULL) \ |
369 |
+ (head)->sqh_last = &(curelm)->field.sqe_next; \ |
370 |
+ } \ |
371 |
+} while (/*CONSTCOND*/0) |
372 |
+ |
373 |
+#define SIMPLEQ_FOREACH(var, head, field) \ |
374 |
+ for ((var) = ((head)->sqh_first); \ |
375 |
+ (var); \ |
376 |
+ (var) = ((var)->field.sqe_next)) |
377 |
+ |
378 |
+/* |
379 |
+ * Simple queue access methods. |
380 |
+ */ |
381 |
+#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) |
382 |
+#define SIMPLEQ_FIRST(head) ((head)->sqh_first) |
383 |
+#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) |
384 |
+ |
385 |
+ |
386 |
+/* |
387 |
+ * Tail queue definitions. |
388 |
+ */ |
389 |
+#define _TAILQ_HEAD(name, type, qual) \ |
390 |
+struct name { \ |
391 |
+ qual type *tqh_first; /* first element */ \ |
392 |
+ qual type *qual *tqh_last; /* addr of last next element */ \ |
393 |
+} |
394 |
+#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) |
395 |
+ |
396 |
+#define TAILQ_HEAD_INITIALIZER(head) \ |
397 |
+ { NULL, &(head).tqh_first } |
398 |
+ |
399 |
+#define _TAILQ_ENTRY(type, qual) \ |
400 |
+struct { \ |
401 |
+ qual type *tqe_next; /* next element */ \ |
402 |
+ qual type *qual *tqe_prev; /* address of previous next element */\ |
403 |
+} |
404 |
+#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) |
405 |
+ |
406 |
+/* |
407 |
+ * Tail queue functions. |
408 |
+ */ |
409 |
+#define TAILQ_INIT(head) do { \ |
410 |
+ (head)->tqh_first = NULL; \ |
411 |
+ (head)->tqh_last = &(head)->tqh_first; \ |
412 |
+} while (/*CONSTCOND*/0) |
413 |
+ |
414 |
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \ |
415 |
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ |
416 |
+ (head)->tqh_first->field.tqe_prev = \ |
417 |
+ &(elm)->field.tqe_next; \ |
418 |
+ else \ |
419 |
+ (head)->tqh_last = &(elm)->field.tqe_next; \ |
420 |
+ (head)->tqh_first = (elm); \ |
421 |
+ (elm)->field.tqe_prev = &(head)->tqh_first; \ |
422 |
+} while (/*CONSTCOND*/0) |
423 |
+ |
424 |
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \ |
425 |
+ (elm)->field.tqe_next = NULL; \ |
426 |
+ (elm)->field.tqe_prev = (head)->tqh_last; \ |
427 |
+ *(head)->tqh_last = (elm); \ |
428 |
+ (head)->tqh_last = &(elm)->field.tqe_next; \ |
429 |
+} while (/*CONSTCOND*/0) |
430 |
+ |
431 |
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
432 |
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ |
433 |
+ (elm)->field.tqe_next->field.tqe_prev = \ |
434 |
+ &(elm)->field.tqe_next; \ |
435 |
+ else \ |
436 |
+ (head)->tqh_last = &(elm)->field.tqe_next; \ |
437 |
+ (listelm)->field.tqe_next = (elm); \ |
438 |
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ |
439 |
+} while (/*CONSTCOND*/0) |
440 |
+ |
441 |
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ |
442 |
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ |
443 |
+ (elm)->field.tqe_next = (listelm); \ |
444 |
+ *(listelm)->field.tqe_prev = (elm); \ |
445 |
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ |
446 |
+} while (/*CONSTCOND*/0) |
447 |
+ |
448 |
+#define TAILQ_REMOVE(head, elm, field) do { \ |
449 |
+ if (((elm)->field.tqe_next) != NULL) \ |
450 |
+ (elm)->field.tqe_next->field.tqe_prev = \ |
451 |
+ (elm)->field.tqe_prev; \ |
452 |
+ else \ |
453 |
+ (head)->tqh_last = (elm)->field.tqe_prev; \ |
454 |
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ |
455 |
+} while (/*CONSTCOND*/0) |
456 |
+ |
457 |
+#define TAILQ_FOREACH(var, head, field) \ |
458 |
+ for ((var) = ((head)->tqh_first); \ |
459 |
+ (var); \ |
460 |
+ (var) = ((var)->field.tqe_next)) |
461 |
+ |
462 |
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ |
463 |
+ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ |
464 |
+ (var); \ |
465 |
+ (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) |
466 |
+ |
467 |
+#define TAILQ_CONCAT(head1, head2, field) do { \ |
468 |
+ if (!TAILQ_EMPTY(head2)) { \ |
469 |
+ *(head1)->tqh_last = (head2)->tqh_first; \ |
470 |
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ |
471 |
+ (head1)->tqh_last = (head2)->tqh_last; \ |
472 |
+ TAILQ_INIT((head2)); \ |
473 |
+ } \ |
474 |
+} while (/*CONSTCOND*/0) |
475 |
+ |
476 |
+/* |
477 |
+ * Tail queue access methods. |
478 |
+ */ |
479 |
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) |
480 |
+#define TAILQ_FIRST(head) ((head)->tqh_first) |
481 |
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) |
482 |
+ |
483 |
+#define TAILQ_LAST(head, headname) \ |
484 |
+ (*(((struct headname *)((head)->tqh_last))->tqh_last)) |
485 |
+#define TAILQ_PREV(elm, headname, field) \ |
486 |
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) |
487 |
+ |
488 |
+ |
489 |
+/* |
490 |
+ * Circular queue definitions. |
491 |
+ */ |
492 |
+#define CIRCLEQ_HEAD(name, type) \ |
493 |
+struct name { \ |
494 |
+ struct type *cqh_first; /* first element */ \ |
495 |
+ struct type *cqh_last; /* last element */ \ |
496 |
+} |
497 |
+ |
498 |
+#define CIRCLEQ_HEAD_INITIALIZER(head) \ |
499 |
+ { (void *)&head, (void *)&head } |
500 |
+ |
501 |
+#define CIRCLEQ_ENTRY(type) \ |
502 |
+struct { \ |
503 |
+ struct type *cqe_next; /* next element */ \ |
504 |
+ struct type *cqe_prev; /* previous element */ \ |
505 |
+} |
506 |
+ |
507 |
+/* |
508 |
+ * Circular queue functions. |
509 |
+ */ |
510 |
+#define CIRCLEQ_INIT(head) do { \ |
511 |
+ (head)->cqh_first = (void *)(head); \ |
512 |
+ (head)->cqh_last = (void *)(head); \ |
513 |
+} while (/*CONSTCOND*/0) |
514 |
+ |
515 |
+#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
516 |
+ (elm)->field.cqe_next = (listelm)->field.cqe_next; \ |
517 |
+ (elm)->field.cqe_prev = (listelm); \ |
518 |
+ if ((listelm)->field.cqe_next == (void *)(head)) \ |
519 |
+ (head)->cqh_last = (elm); \ |
520 |
+ else \ |
521 |
+ (listelm)->field.cqe_next->field.cqe_prev = (elm); \ |
522 |
+ (listelm)->field.cqe_next = (elm); \ |
523 |
+} while (/*CONSTCOND*/0) |
524 |
+ |
525 |
+#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ |
526 |
+ (elm)->field.cqe_next = (listelm); \ |
527 |
+ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ |
528 |
+ if ((listelm)->field.cqe_prev == (void *)(head)) \ |
529 |
+ (head)->cqh_first = (elm); \ |
530 |
+ else \ |
531 |
+ (listelm)->field.cqe_prev->field.cqe_next = (elm); \ |
532 |
+ (listelm)->field.cqe_prev = (elm); \ |
533 |
+} while (/*CONSTCOND*/0) |
534 |
+ |
535 |
+#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ |
536 |
+ (elm)->field.cqe_next = (head)->cqh_first; \ |
537 |
+ (elm)->field.cqe_prev = (void *)(head); \ |
538 |
+ if ((head)->cqh_last == (void *)(head)) \ |
539 |
+ (head)->cqh_last = (elm); \ |
540 |
+ else \ |
541 |
+ (head)->cqh_first->field.cqe_prev = (elm); \ |
542 |
+ (head)->cqh_first = (elm); \ |
543 |
+} while (/*CONSTCOND*/0) |
544 |
+ |
545 |
+#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ |
546 |
+ (elm)->field.cqe_next = (void *)(head); \ |
547 |
+ (elm)->field.cqe_prev = (head)->cqh_last; \ |
548 |
+ if ((head)->cqh_first == (void *)(head)) \ |
549 |
+ (head)->cqh_first = (elm); \ |
550 |
+ else \ |
551 |
+ (head)->cqh_last->field.cqe_next = (elm); \ |
552 |
+ (head)->cqh_last = (elm); \ |
553 |
+} while (/*CONSTCOND*/0) |
554 |
+ |
555 |
+#define CIRCLEQ_REMOVE(head, elm, field) do { \ |
556 |
+ if ((elm)->field.cqe_next == (void *)(head)) \ |
557 |
+ (head)->cqh_last = (elm)->field.cqe_prev; \ |
558 |
+ else \ |
559 |
+ (elm)->field.cqe_next->field.cqe_prev = \ |
560 |
+ (elm)->field.cqe_prev; \ |
561 |
+ if ((elm)->field.cqe_prev == (void *)(head)) \ |
562 |
+ (head)->cqh_first = (elm)->field.cqe_next; \ |
563 |
+ else \ |
564 |
+ (elm)->field.cqe_prev->field.cqe_next = \ |
565 |
+ (elm)->field.cqe_next; \ |
566 |
+} while (/*CONSTCOND*/0) |
567 |
+ |
568 |
+#define CIRCLEQ_FOREACH(var, head, field) \ |
569 |
+ for ((var) = ((head)->cqh_first); \ |
570 |
+ (var) != (const void *)(head); \ |
571 |
+ (var) = ((var)->field.cqe_next)) |
572 |
+ |
573 |
+#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ |
574 |
+ for ((var) = ((head)->cqh_last); \ |
575 |
+ (var) != (const void *)(head); \ |
576 |
+ (var) = ((var)->field.cqe_prev)) |
577 |
+ |
578 |
+/* |
579 |
+ * Circular queue access methods. |
580 |
+ */ |
581 |
+#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) |
582 |
+#define CIRCLEQ_FIRST(head) ((head)->cqh_first) |
583 |
+#define CIRCLEQ_LAST(head) ((head)->cqh_last) |
584 |
+#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) |
585 |
+#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) |
586 |
+ |
587 |
+#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ |
588 |
+ (((elm)->field.cqe_next == (void *)(head)) \ |
589 |
+ ? ((head)->cqh_first) \ |
590 |
+ : (elm->field.cqe_next)) |
591 |
+#define CIRCLEQ_LOOP_PREV(head, elm, field) \ |
592 |
+ (((elm)->field.cqe_prev == (void *)(head)) \ |
593 |
+ ? ((head)->cqh_last) \ |
594 |
+ : (elm->field.cqe_prev)) |
595 |
+ |
596 |
+#endif /* sys/queue.h */ |
597 |
|
598 |
diff --git a/sys-libs/queue-standalone/metadata.xml b/sys-libs/queue-standalone/metadata.xml |
599 |
new file mode 100644 |
600 |
index 00000000000..d920e3ba3e5 |
601 |
--- /dev/null |
602 |
+++ b/sys-libs/queue-standalone/metadata.xml |
603 |
@@ -0,0 +1,8 @@ |
604 |
+<?xml version="1.0" encoding="UTF-8"?> |
605 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
606 |
+<pkgmetadata> |
607 |
+ <maintainer type="person"> |
608 |
+ <email>blueness@g.o</email> |
609 |
+ <name>Anthony G. Basile</name> |
610 |
+ </maintainer> |
611 |
+</pkgmetadata> |
612 |
|
613 |
diff --git a/sys-libs/queue-standalone/queue-standalone-0.1.ebuild b/sys-libs/queue-standalone/queue-standalone-0.1.ebuild |
614 |
new file mode 100644 |
615 |
index 00000000000..2e1356e1ed8 |
616 |
--- /dev/null |
617 |
+++ b/sys-libs/queue-standalone/queue-standalone-0.1.ebuild |
618 |
@@ -0,0 +1,22 @@ |
619 |
+# Copyright 1999-2018 Gentoo Foundation |
620 |
+# Distributed under the terms of the GNU General Public License v2 |
621 |
+ |
622 |
+EAPI=7 |
623 |
+ |
624 |
+DESCRIPTION="Install <sys/queue.h> from glibc." |
625 |
+HOMEPAGE="https://www.gnu.org/software/libc/libc.html" |
626 |
+ |
627 |
+LICENSE="BSD" |
628 |
+SLOT="0" |
629 |
+KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~x86" |
630 |
+ |
631 |
+DEPEND=" |
632 |
+ !sys-libs/glibc |
633 |
+ !sys-libs/uclibc" |
634 |
+ |
635 |
+S="${WORKDIR}" |
636 |
+ |
637 |
+src_install() { |
638 |
+ mkdir -p "${D}"/usr/include/sys |
639 |
+ cp "${FILESDIR}"/queue.h "${D}"/usr/include/sys |
640 |
+} |