Mercurial > projects > pwm
annotate compat/queue.h @ 29:00d782cb45fa
Read configuration file on startup
author | Guido Berhoerster <guido+pwm@berhoerster.name> |
---|---|
date | Thu, 28 Sep 2017 10:06:59 +0200 |
parents | a08ef0674d8e |
children |
rev | line source |
---|---|
17
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
1 /* $OpenBSD: queue.h,v 1.44 2016/09/09 20:31:46 millert Exp $ */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
2 /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
3 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
4 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
5 * Copyright (c) 1991, 1993 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
6 * The Regents of the University of California. All rights reserved. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
7 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
8 * Redistribution and use in source and binary forms, with or without |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
9 * modification, are permitted provided that the following conditions |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
10 * are met: |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
11 * 1. Redistributions of source code must retain the above copyright |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
12 * notice, this list of conditions and the following disclaimer. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
13 * 2. Redistributions in binary form must reproduce the above copyright |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
14 * notice, this list of conditions and the following disclaimer in the |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
15 * documentation and/or other materials provided with the distribution. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
16 * 3. Neither the name of the University nor the names of its contributors |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
17 * may be used to endorse or promote products derived from this software |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
18 * without specific prior written permission. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
19 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
30 * SUCH DAMAGE. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
31 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
32 * @(#)queue.h 8.5 (Berkeley) 8/20/94 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
33 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
34 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
35 #ifndef _SYS_QUEUE_H_ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
36 #define _SYS_QUEUE_H_ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
37 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
38 #include <stddef.h> |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
39 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
40 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
41 * This file defines five types of data structures: singly-linked lists, |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
42 * lists, simple queues, tail queues and XOR simple queues. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
43 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
44 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
45 * A singly-linked list is headed by a single forward pointer. The elements |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
46 * are singly linked for minimum space and pointer manipulation overhead at |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
47 * the expense of O(n) removal for arbitrary elements. New elements can be |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
48 * added to the list after an existing element or at the head of the list. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
49 * Elements being removed from the head of the list should use the explicit |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
50 * macro for this purpose for optimum efficiency. A singly-linked list may |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
51 * only be traversed in the forward direction. Singly-linked lists are ideal |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
52 * for applications with large datasets and few or no removals or for |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
53 * implementing a LIFO queue. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
54 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
55 * A list is headed by a single forward pointer (or an array of forward |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
56 * pointers for a hash table header). The elements are doubly linked |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
57 * so that an arbitrary element can be removed without a need to |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
58 * traverse the list. New elements can be added to the list before |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
59 * or after an existing element or at the head of the list. A list |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
60 * may only be traversed in the forward direction. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
61 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
62 * A simple queue is headed by a pair of pointers, one to the head of the |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
63 * list and the other to the tail of the list. The elements are singly |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
64 * linked to save space, so elements can only be removed from the |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
65 * head of the list. New elements can be added to the list before or after |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
66 * an existing element, at the head of the list, or at the end of the |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
67 * list. A simple queue may only be traversed in the forward direction. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
68 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
69 * A tail queue is headed by a pair of pointers, one to the head of the |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
70 * list and the other to the tail of the list. The elements are doubly |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
71 * linked so that an arbitrary element can be removed without a need to |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
72 * traverse the list. New elements can be added to the list before or |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
73 * after an existing element, at the head of the list, or at the end of |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
74 * the list. A tail queue may be traversed in either direction. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
75 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
76 * An XOR simple queue is used in the same way as a regular simple queue. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
77 * The difference is that the head structure also includes a "cookie" that |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
78 * is XOR'd with the queue pointer (first, last or next) to generate the |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
79 * real pointer value. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
80 * |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
81 * For details on the use of these macros, see the queue(3) manual page. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
82 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
83 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
84 #if defined(QUEUE_MACRO_DEBUG) || (defined(_KERNEL) && defined(DIAGNOSTIC)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
85 #define _Q_INVALIDATE(a) (a) = ((void *)-1) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
86 #else |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
87 #define _Q_INVALIDATE(a) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
88 #endif |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
89 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
90 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
91 * Singly-linked List definitions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
92 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
93 #define SLIST_HEAD(name, type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
94 struct name { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
95 struct type *slh_first; /* first element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
96 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
97 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
98 #define SLIST_HEAD_INITIALIZER(head) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
99 { NULL } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
100 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
101 #define SLIST_ENTRY(type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
102 struct { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
103 struct type *sle_next; /* next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
104 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
105 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
106 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
107 * Singly-linked List access methods. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
108 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
109 #define SLIST_FIRST(head) ((head)->slh_first) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
110 #define SLIST_END(head) NULL |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
111 #define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
112 #define SLIST_NEXT(elm, field) ((elm)->field.sle_next) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
113 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
114 #define SLIST_FOREACH(var, head, field) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
115 for((var) = SLIST_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
116 (var) != SLIST_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
117 (var) = SLIST_NEXT(var, field)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
118 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
119 #define SLIST_FOREACH_SAFE(var, head, field, tvar) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
120 for ((var) = SLIST_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
121 (var) && ((tvar) = SLIST_NEXT(var, field), 1); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
122 (var) = (tvar)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
123 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
124 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
125 * Singly-linked List functions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
126 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
127 #define SLIST_INIT(head) { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
128 SLIST_FIRST(head) = SLIST_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
129 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
130 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
131 #define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
132 (elm)->field.sle_next = (slistelm)->field.sle_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
133 (slistelm)->field.sle_next = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
134 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
135 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
136 #define SLIST_INSERT_HEAD(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
137 (elm)->field.sle_next = (head)->slh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
138 (head)->slh_first = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
139 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
140 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
141 #define SLIST_REMOVE_AFTER(elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
142 (elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
143 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
144 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
145 #define SLIST_REMOVE_HEAD(head, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
146 (head)->slh_first = (head)->slh_first->field.sle_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
147 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
148 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
149 #define SLIST_REMOVE(head, elm, type, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
150 if ((head)->slh_first == (elm)) { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
151 SLIST_REMOVE_HEAD((head), field); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
152 } else { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
153 struct type *curelm = (head)->slh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
154 \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
155 while (curelm->field.sle_next != (elm)) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
156 curelm = curelm->field.sle_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
157 curelm->field.sle_next = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
158 curelm->field.sle_next->field.sle_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
159 } \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
160 _Q_INVALIDATE((elm)->field.sle_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
161 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
162 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
163 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
164 * List definitions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
165 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
166 #define LIST_HEAD(name, type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
167 struct name { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
168 struct type *lh_first; /* first element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
169 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
170 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
171 #define LIST_HEAD_INITIALIZER(head) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
172 { NULL } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
173 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
174 #define LIST_ENTRY(type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
175 struct { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
176 struct type *le_next; /* next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
177 struct type **le_prev; /* address of previous next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
178 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
179 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
180 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
181 * List access methods. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
182 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
183 #define LIST_FIRST(head) ((head)->lh_first) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
184 #define LIST_END(head) NULL |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
185 #define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
186 #define LIST_NEXT(elm, field) ((elm)->field.le_next) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
187 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
188 #define LIST_FOREACH(var, head, field) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
189 for((var) = LIST_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
190 (var)!= LIST_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
191 (var) = LIST_NEXT(var, field)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
192 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
193 #define LIST_FOREACH_SAFE(var, head, field, tvar) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
194 for ((var) = LIST_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
195 (var) && ((tvar) = LIST_NEXT(var, field), 1); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
196 (var) = (tvar)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
197 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
198 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
199 * List functions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
200 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
201 #define LIST_INIT(head) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
202 LIST_FIRST(head) = LIST_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
203 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
204 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
205 #define LIST_INSERT_AFTER(listelm, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
206 if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
207 (listelm)->field.le_next->field.le_prev = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
208 &(elm)->field.le_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
209 (listelm)->field.le_next = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
210 (elm)->field.le_prev = &(listelm)->field.le_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
211 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
212 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
213 #define LIST_INSERT_BEFORE(listelm, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
214 (elm)->field.le_prev = (listelm)->field.le_prev; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
215 (elm)->field.le_next = (listelm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
216 *(listelm)->field.le_prev = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
217 (listelm)->field.le_prev = &(elm)->field.le_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
218 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
219 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
220 #define LIST_INSERT_HEAD(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
221 if (((elm)->field.le_next = (head)->lh_first) != NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
222 (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
223 (head)->lh_first = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
224 (elm)->field.le_prev = &(head)->lh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
225 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
226 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
227 #define LIST_REMOVE(elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
228 if ((elm)->field.le_next != NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
229 (elm)->field.le_next->field.le_prev = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
230 (elm)->field.le_prev; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
231 *(elm)->field.le_prev = (elm)->field.le_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
232 _Q_INVALIDATE((elm)->field.le_prev); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
233 _Q_INVALIDATE((elm)->field.le_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
234 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
235 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
236 #define LIST_REPLACE(elm, elm2, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
237 if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
238 (elm2)->field.le_next->field.le_prev = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
239 &(elm2)->field.le_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
240 (elm2)->field.le_prev = (elm)->field.le_prev; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
241 *(elm2)->field.le_prev = (elm2); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
242 _Q_INVALIDATE((elm)->field.le_prev); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
243 _Q_INVALIDATE((elm)->field.le_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
244 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
245 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
246 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
247 * Simple queue definitions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
248 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
249 #define SIMPLEQ_HEAD(name, type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
250 struct name { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
251 struct type *sqh_first; /* first element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
252 struct type **sqh_last; /* addr of last next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
253 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
254 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
255 #define SIMPLEQ_HEAD_INITIALIZER(head) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
256 { NULL, &(head).sqh_first } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
257 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
258 #define SIMPLEQ_ENTRY(type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
259 struct { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
260 struct type *sqe_next; /* next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
261 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
262 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
263 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
264 * Simple queue access methods. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
265 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
266 #define SIMPLEQ_FIRST(head) ((head)->sqh_first) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
267 #define SIMPLEQ_END(head) NULL |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
268 #define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
269 #define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
270 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
271 #define SIMPLEQ_FOREACH(var, head, field) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
272 for((var) = SIMPLEQ_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
273 (var) != SIMPLEQ_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
274 (var) = SIMPLEQ_NEXT(var, field)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
275 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
276 #define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
277 for ((var) = SIMPLEQ_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
278 (var) && ((tvar) = SIMPLEQ_NEXT(var, field), 1); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
279 (var) = (tvar)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
280 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
281 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
282 * Simple queue functions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
283 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
284 #define SIMPLEQ_INIT(head) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
285 (head)->sqh_first = NULL; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
286 (head)->sqh_last = &(head)->sqh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
287 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
288 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
289 #define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
290 if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
291 (head)->sqh_last = &(elm)->field.sqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
292 (head)->sqh_first = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
293 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
294 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
295 #define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
296 (elm)->field.sqe_next = NULL; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
297 *(head)->sqh_last = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
298 (head)->sqh_last = &(elm)->field.sqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
299 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
300 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
301 #define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
302 if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
303 (head)->sqh_last = &(elm)->field.sqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
304 (listelm)->field.sqe_next = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
305 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
306 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
307 #define SIMPLEQ_REMOVE_HEAD(head, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
308 if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
309 (head)->sqh_last = &(head)->sqh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
310 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
311 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
312 #define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
313 if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
314 == NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
315 (head)->sqh_last = &(elm)->field.sqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
316 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
317 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
318 #define SIMPLEQ_CONCAT(head1, head2) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
319 if (!SIMPLEQ_EMPTY((head2))) { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
320 *(head1)->sqh_last = (head2)->sqh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
321 (head1)->sqh_last = (head2)->sqh_last; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
322 SIMPLEQ_INIT((head2)); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
323 } \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
324 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
325 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
326 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
327 * XOR Simple queue definitions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
328 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
329 #define XSIMPLEQ_HEAD(name, type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
330 struct name { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
331 struct type *sqx_first; /* first element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
332 struct type **sqx_last; /* addr of last next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
333 unsigned long sqx_cookie; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
334 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
335 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
336 #define XSIMPLEQ_ENTRY(type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
337 struct { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
338 struct type *sqx_next; /* next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
339 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
340 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
341 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
342 * XOR Simple queue access methods. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
343 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
344 #define XSIMPLEQ_XOR(head, ptr) ((__typeof(ptr))((head)->sqx_cookie ^ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
345 (unsigned long)(ptr))) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
346 #define XSIMPLEQ_FIRST(head) XSIMPLEQ_XOR(head, ((head)->sqx_first)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
347 #define XSIMPLEQ_END(head) NULL |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
348 #define XSIMPLEQ_EMPTY(head) (XSIMPLEQ_FIRST(head) == XSIMPLEQ_END(head)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
349 #define XSIMPLEQ_NEXT(head, elm, field) XSIMPLEQ_XOR(head, ((elm)->field.sqx_next)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
350 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
351 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
352 #define XSIMPLEQ_FOREACH(var, head, field) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
353 for ((var) = XSIMPLEQ_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
354 (var) != XSIMPLEQ_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
355 (var) = XSIMPLEQ_NEXT(head, var, field)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
356 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
357 #define XSIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
358 for ((var) = XSIMPLEQ_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
359 (var) && ((tvar) = XSIMPLEQ_NEXT(head, var, field), 1); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
360 (var) = (tvar)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
361 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
362 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
363 * XOR Simple queue functions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
364 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
365 #define XSIMPLEQ_INIT(head) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
366 arc4random_buf(&(head)->sqx_cookie, sizeof((head)->sqx_cookie)); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
367 (head)->sqx_first = XSIMPLEQ_XOR(head, NULL); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
368 (head)->sqx_last = XSIMPLEQ_XOR(head, &(head)->sqx_first); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
369 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
370 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
371 #define XSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
372 if (((elm)->field.sqx_next = (head)->sqx_first) == \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
373 XSIMPLEQ_XOR(head, NULL)) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
374 (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
375 (head)->sqx_first = XSIMPLEQ_XOR(head, (elm)); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
376 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
377 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
378 #define XSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
379 (elm)->field.sqx_next = XSIMPLEQ_XOR(head, NULL); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
380 *(XSIMPLEQ_XOR(head, (head)->sqx_last)) = XSIMPLEQ_XOR(head, (elm)); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
381 (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
382 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
383 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
384 #define XSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
385 if (((elm)->field.sqx_next = (listelm)->field.sqx_next) == \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
386 XSIMPLEQ_XOR(head, NULL)) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
387 (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
388 (listelm)->field.sqx_next = XSIMPLEQ_XOR(head, (elm)); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
389 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
390 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
391 #define XSIMPLEQ_REMOVE_HEAD(head, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
392 if (((head)->sqx_first = XSIMPLEQ_XOR(head, \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
393 (head)->sqx_first)->field.sqx_next) == XSIMPLEQ_XOR(head, NULL)) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
394 (head)->sqx_last = XSIMPLEQ_XOR(head, &(head)->sqx_first); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
395 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
396 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
397 #define XSIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
398 if (((elm)->field.sqx_next = XSIMPLEQ_XOR(head, \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
399 (elm)->field.sqx_next)->field.sqx_next) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
400 == XSIMPLEQ_XOR(head, NULL)) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
401 (head)->sqx_last = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
402 XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
403 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
404 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
405 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
406 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
407 * Tail queue definitions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
408 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
409 #define TAILQ_HEAD(name, type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
410 struct name { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
411 struct type *tqh_first; /* first element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
412 struct type **tqh_last; /* addr of last next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
413 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
414 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
415 #define TAILQ_HEAD_INITIALIZER(head) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
416 { NULL, &(head).tqh_first } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
417 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
418 #define TAILQ_ENTRY(type) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
419 struct { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
420 struct type *tqe_next; /* next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
421 struct type **tqe_prev; /* address of previous next element */ \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
422 } |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
423 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
424 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
425 * Tail queue access methods. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
426 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
427 #define TAILQ_FIRST(head) ((head)->tqh_first) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
428 #define TAILQ_END(head) NULL |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
429 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
430 #define TAILQ_LAST(head, headname) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
431 (*(((struct headname *)((head)->tqh_last))->tqh_last)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
432 /* XXX */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
433 #define TAILQ_PREV(elm, headname, field) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
434 (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
435 #define TAILQ_EMPTY(head) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
436 (TAILQ_FIRST(head) == TAILQ_END(head)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
437 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
438 #define TAILQ_FOREACH(var, head, field) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
439 for((var) = TAILQ_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
440 (var) != TAILQ_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
441 (var) = TAILQ_NEXT(var, field)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
442 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
443 #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
444 for ((var) = TAILQ_FIRST(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
445 (var) != TAILQ_END(head) && \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
446 ((tvar) = TAILQ_NEXT(var, field), 1); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
447 (var) = (tvar)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
448 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
449 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
450 #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
451 for((var) = TAILQ_LAST(head, headname); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
452 (var) != TAILQ_END(head); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
453 (var) = TAILQ_PREV(var, headname, field)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
454 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
455 #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
456 for ((var) = TAILQ_LAST(head, headname); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
457 (var) != TAILQ_END(head) && \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
458 ((tvar) = TAILQ_PREV(var, headname, field), 1); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
459 (var) = (tvar)) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
460 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
461 /* |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
462 * Tail queue functions. |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
463 */ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
464 #define TAILQ_INIT(head) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
465 (head)->tqh_first = NULL; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
466 (head)->tqh_last = &(head)->tqh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
467 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
468 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
469 #define TAILQ_INSERT_HEAD(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
470 if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
471 (head)->tqh_first->field.tqe_prev = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
472 &(elm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
473 else \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
474 (head)->tqh_last = &(elm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
475 (head)->tqh_first = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
476 (elm)->field.tqe_prev = &(head)->tqh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
477 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
478 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
479 #define TAILQ_INSERT_TAIL(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
480 (elm)->field.tqe_next = NULL; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
481 (elm)->field.tqe_prev = (head)->tqh_last; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
482 *(head)->tqh_last = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
483 (head)->tqh_last = &(elm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
484 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
485 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
486 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
487 if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
488 (elm)->field.tqe_next->field.tqe_prev = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
489 &(elm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
490 else \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
491 (head)->tqh_last = &(elm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
492 (listelm)->field.tqe_next = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
493 (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
494 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
495 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
496 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
497 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
498 (elm)->field.tqe_next = (listelm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
499 *(listelm)->field.tqe_prev = (elm); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
500 (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
501 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
502 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
503 #define TAILQ_REMOVE(head, elm, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
504 if (((elm)->field.tqe_next) != NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
505 (elm)->field.tqe_next->field.tqe_prev = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
506 (elm)->field.tqe_prev; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
507 else \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
508 (head)->tqh_last = (elm)->field.tqe_prev; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
509 *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
510 _Q_INVALIDATE((elm)->field.tqe_prev); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
511 _Q_INVALIDATE((elm)->field.tqe_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
512 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
513 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
514 #define TAILQ_REPLACE(head, elm, elm2, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
515 if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
516 (elm2)->field.tqe_next->field.tqe_prev = \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
517 &(elm2)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
518 else \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
519 (head)->tqh_last = &(elm2)->field.tqe_next; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
520 (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
521 *(elm2)->field.tqe_prev = (elm2); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
522 _Q_INVALIDATE((elm)->field.tqe_prev); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
523 _Q_INVALIDATE((elm)->field.tqe_next); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
524 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
525 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
526 #define TAILQ_CONCAT(head1, head2, field) do { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
527 if (!TAILQ_EMPTY(head2)) { \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
528 *(head1)->tqh_last = (head2)->tqh_first; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
529 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
530 (head1)->tqh_last = (head2)->tqh_last; \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
531 TAILQ_INIT((head2)); \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
532 } \ |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
533 } while (0) |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
534 |
a08ef0674d8e
Page long output in interactive mode
Guido Berhoerster <guido+pwm@berhoerster.name>
parents:
diff
changeset
|
535 #endif /* !_SYS_QUEUE_H_ */ |