xlsxwriter 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +40 -0
- data/ext/xlsxwriter/chart.c +105 -0
- data/ext/xlsxwriter/chart.h +27 -0
- data/ext/xlsxwriter/extconf.rb +14 -0
- data/ext/xlsxwriter/format.c +67 -0
- data/ext/xlsxwriter/format.h +9 -0
- data/ext/xlsxwriter/libxlsxwriter/LICENSE.txt +89 -0
- data/ext/xlsxwriter/libxlsxwriter/Makefile +141 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +1093 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +336 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +215 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +751 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/ext/xlsxwriter/libxlsxwriter/lib/.gitignore +0 -0
- data/ext/xlsxwriter/libxlsxwriter/src/Makefile +125 -0
- data/ext/xlsxwriter/libxlsxwriter/src/app.c +439 -0
- data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3420 -0
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +341 -0
- data/ext/xlsxwriter/libxlsxwriter/src/core.c +293 -0
- data/ext/xlsxwriter/libxlsxwriter/src/custom.c +224 -0
- data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +746 -0
- data/ext/xlsxwriter/libxlsxwriter/src/format.c +728 -0
- data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +223 -0
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +877 -0
- data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +242 -0
- data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +264 -0
- data/ext/xlsxwriter/libxlsxwriter/src/styles.c +1086 -0
- data/ext/xlsxwriter/libxlsxwriter/src/theme.c +348 -0
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +512 -0
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +1895 -0
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +4992 -0
- data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +355 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.h +209 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/workbook.c +257 -0
- data/ext/xlsxwriter/workbook.h +42 -0
- data/ext/xlsxwriter/workbook_properties.c +103 -0
- data/ext/xlsxwriter/workbook_properties.h +10 -0
- data/ext/xlsxwriter/worksheet.c +1064 -0
- data/ext/xlsxwriter/worksheet.h +74 -0
- data/ext/xlsxwriter/xlsxwriter.c +239 -0
- data/lib/xlsxwriter.rb +6 -0
- data/lib/xlsxwriter/version.rb +3 -0
- data/lib/xlsxwriter/worksheet.rb +72 -0
- data/test/run-test.rb +11 -0
- data/test/support/xlsx_comparable.rb +109 -0
- data/test/test-array-formula.rb +33 -0
- data/test/test-autofilter.rb +70 -0
- data/test/test-chart-area.rb +25 -0
- data/test/test-data.rb +65 -0
- data/test/test-default-row.rb +25 -0
- data/test/test-defined-name.rb +46 -0
- data/test/test-escapes.rb +33 -0
- data/test/test-fit-to-pages.rb +21 -0
- data/test/test-formatting.rb +137 -0
- data/test/test-gridlines.rb +15 -0
- data/test/test-hyperlink.rb +67 -0
- data/test/test-image.rb +84 -0
- data/test/test-merge-range.rb +18 -0
- data/test/test-misc.rb +29 -0
- data/test/test-optimize.rb +32 -0
- data/test/test-page-breaks.rb +13 -0
- data/test/test-page-setup.rb +28 -0
- data/test/test-panes.rb +45 -0
- data/test/test-print-area.rb +19 -0
- data/test/test-print-options.rb +61 -0
- data/test/test-print-scale.rb +12 -0
- data/test/test-properties.rb +51 -0
- data/test/test-protect.rb +27 -0
- data/test/test-repeat.rb +23 -0
- data/test/test-row-col-format.rb +35 -0
- data/test/test-set-selection.rb +13 -0
- data/test/test-set-start-page.rb +13 -0
- data/test/test-simple.rb +62 -0
- data/test/test-types.rb +17 -0
- data/test/xlsx-func-testcase.rb +36 -0
- metadata +228 -0
@@ -0,0 +1,694 @@
|
|
1
|
+
/*-
|
2
|
+
* Copyright (c) 1991, 1993
|
3
|
+
* The Regents of the University of California. All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* 4. Neither the name of the University nor the names of its contributors
|
14
|
+
* may be used to endorse or promote products derived from this software
|
15
|
+
* without specific prior written permission.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
23
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
24
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
26
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27
|
+
* SUCH DAMAGE.
|
28
|
+
*
|
29
|
+
* @(#)queue.h 8.5 (Berkeley) 8/20/94
|
30
|
+
* $FreeBSD$
|
31
|
+
*/
|
32
|
+
|
33
|
+
#ifndef _SYS_QUEUE_H_
|
34
|
+
#define _SYS_QUEUE_H_
|
35
|
+
|
36
|
+
/* #include <sys/cdefs.h> */
|
37
|
+
|
38
|
+
/*
|
39
|
+
* This file defines four types of data structures: singly-linked lists,
|
40
|
+
* singly-linked tail queues, lists and tail queues.
|
41
|
+
*
|
42
|
+
* A singly-linked list is headed by a single forward pointer. The elements
|
43
|
+
* are singly linked for minimum space and pointer manipulation overhead at
|
44
|
+
* the expense of O(n) removal for arbitrary elements. New elements can be
|
45
|
+
* added to the list after an existing element or at the head of the list.
|
46
|
+
* Elements being removed from the head of the list should use the explicit
|
47
|
+
* macro for this purpose for optimum efficiency. A singly-linked list may
|
48
|
+
* only be traversed in the forward direction. Singly-linked lists are ideal
|
49
|
+
* for applications with large datasets and few or no removals or for
|
50
|
+
* implementing a LIFO queue.
|
51
|
+
*
|
52
|
+
* A singly-linked tail queue is headed by a pair of pointers, one to the
|
53
|
+
* head of the list and the other to the tail of the list. The elements are
|
54
|
+
* singly linked for minimum space and pointer manipulation overhead at the
|
55
|
+
* expense of O(n) removal for arbitrary elements. New elements can be added
|
56
|
+
* to the list after an existing element, at the head of the list, or at the
|
57
|
+
* end of the list. Elements being removed from the head of the tail queue
|
58
|
+
* should use the explicit macro for this purpose for optimum efficiency.
|
59
|
+
* A singly-linked tail queue may only be traversed in the forward direction.
|
60
|
+
* Singly-linked tail queues are ideal for applications with large datasets
|
61
|
+
* and few or no removals or for implementing a FIFO queue.
|
62
|
+
*
|
63
|
+
* A list is headed by a single forward pointer (or an array of forward
|
64
|
+
* pointers for a hash table header). The elements are doubly linked
|
65
|
+
* so that an arbitrary element can be removed without a need to
|
66
|
+
* traverse the list. New elements can be added to the list before
|
67
|
+
* or after an existing element or at the head of the list. A list
|
68
|
+
* may be traversed in either direction.
|
69
|
+
*
|
70
|
+
* A tail queue is headed by a pair of pointers, one to the head of the
|
71
|
+
* list and the other to the tail of the list. The elements are doubly
|
72
|
+
* linked so that an arbitrary element can be removed without a need to
|
73
|
+
* traverse the list. New elements can be added to the list before or
|
74
|
+
* after an existing element, at the head of the list, or at the end of
|
75
|
+
* the list. A tail queue may be traversed in either direction.
|
76
|
+
*
|
77
|
+
* For details on the use of these macros, see the queue(3) manual page.
|
78
|
+
*
|
79
|
+
*
|
80
|
+
* SLIST LIST STAILQ TAILQ
|
81
|
+
* _HEAD + + + +
|
82
|
+
* _HEAD_INITIALIZER + + + +
|
83
|
+
* _ENTRY + + + +
|
84
|
+
* _INIT + + + +
|
85
|
+
* _EMPTY + + + +
|
86
|
+
* _FIRST + + + +
|
87
|
+
* _NEXT + + + +
|
88
|
+
* _PREV - + - +
|
89
|
+
* _LAST - - + +
|
90
|
+
* _FOREACH + + + +
|
91
|
+
* _FOREACH_FROM + + + +
|
92
|
+
* _FOREACH_SAFE + + + +
|
93
|
+
* _FOREACH_FROM_SAFE + + + +
|
94
|
+
* _FOREACH_REVERSE - - - +
|
95
|
+
* _FOREACH_REVERSE_FROM - - - +
|
96
|
+
* _FOREACH_REVERSE_SAFE - - - +
|
97
|
+
* _FOREACH_REVERSE_FROM_SAFE - - - +
|
98
|
+
* _INSERT_HEAD + + + +
|
99
|
+
* _INSERT_BEFORE - + - +
|
100
|
+
* _INSERT_AFTER + + + +
|
101
|
+
* _INSERT_TAIL - - + +
|
102
|
+
* _CONCAT - - + +
|
103
|
+
* _REMOVE_AFTER + - + -
|
104
|
+
* _REMOVE_HEAD + - + -
|
105
|
+
* _REMOVE + + + +
|
106
|
+
* _SWAP + + + +
|
107
|
+
*
|
108
|
+
*/
|
109
|
+
#ifdef QUEUE_MACRO_DEBUG
|
110
|
+
/* Store the last 2 places the queue element or head was altered */
|
111
|
+
struct qm_trace {
|
112
|
+
unsigned long lastline;
|
113
|
+
unsigned long prevline;
|
114
|
+
const char *lastfile;
|
115
|
+
const char *prevfile;
|
116
|
+
};
|
117
|
+
|
118
|
+
#define TRACEBUF struct qm_trace trace;
|
119
|
+
#define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } ,
|
120
|
+
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
|
121
|
+
#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
|
122
|
+
|
123
|
+
#define QMD_TRACE_HEAD(head) do { \
|
124
|
+
(head)->trace.prevline = (head)->trace.lastline; \
|
125
|
+
(head)->trace.prevfile = (head)->trace.lastfile; \
|
126
|
+
(head)->trace.lastline = __LINE__; \
|
127
|
+
(head)->trace.lastfile = __FILE__; \
|
128
|
+
} while (0)
|
129
|
+
|
130
|
+
#define QMD_TRACE_ELEM(elem) do { \
|
131
|
+
(elem)->trace.prevline = (elem)->trace.lastline; \
|
132
|
+
(elem)->trace.prevfile = (elem)->trace.lastfile; \
|
133
|
+
(elem)->trace.lastline = __LINE__; \
|
134
|
+
(elem)->trace.lastfile = __FILE__; \
|
135
|
+
} while (0)
|
136
|
+
|
137
|
+
#else
|
138
|
+
#define QMD_TRACE_ELEM(elem)
|
139
|
+
#define QMD_TRACE_HEAD(head)
|
140
|
+
#define QMD_SAVELINK(name, link)
|
141
|
+
#define TRACEBUF
|
142
|
+
#define TRACEBUF_INITIALIZER
|
143
|
+
#define TRASHIT(x)
|
144
|
+
#endif /* QUEUE_MACRO_DEBUG */
|
145
|
+
|
146
|
+
/*
|
147
|
+
* Singly-linked List declarations.
|
148
|
+
*/
|
149
|
+
#define SLIST_HEAD(name, type) \
|
150
|
+
struct name { \
|
151
|
+
struct type *slh_first; /* first element */ \
|
152
|
+
}
|
153
|
+
|
154
|
+
#define SLIST_HEAD_INITIALIZER(head) \
|
155
|
+
{ NULL }
|
156
|
+
|
157
|
+
#define SLIST_ENTRY(type) \
|
158
|
+
struct { \
|
159
|
+
struct type *sle_next; /* next element */ \
|
160
|
+
}
|
161
|
+
|
162
|
+
/*
|
163
|
+
* Singly-linked List functions.
|
164
|
+
*/
|
165
|
+
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
|
166
|
+
|
167
|
+
#define SLIST_FIRST(head) ((head)->slh_first)
|
168
|
+
|
169
|
+
#define SLIST_FOREACH(var, head, field) \
|
170
|
+
for ((var) = SLIST_FIRST((head)); \
|
171
|
+
(var); \
|
172
|
+
(var) = SLIST_NEXT((var), field))
|
173
|
+
|
174
|
+
#define SLIST_FOREACH_FROM(var, head, field) \
|
175
|
+
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
|
176
|
+
(var); \
|
177
|
+
(var) = SLIST_NEXT((var), field))
|
178
|
+
|
179
|
+
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
180
|
+
for ((var) = SLIST_FIRST((head)); \
|
181
|
+
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
182
|
+
(var) = (tvar))
|
183
|
+
|
184
|
+
#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
185
|
+
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
|
186
|
+
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
187
|
+
(var) = (tvar))
|
188
|
+
|
189
|
+
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
190
|
+
for ((varp) = &SLIST_FIRST((head)); \
|
191
|
+
((var) = *(varp)) != NULL; \
|
192
|
+
(varp) = &SLIST_NEXT((var), field))
|
193
|
+
|
194
|
+
#define SLIST_INIT(head) do { \
|
195
|
+
SLIST_FIRST((head)) = NULL; \
|
196
|
+
} while (0)
|
197
|
+
|
198
|
+
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
199
|
+
SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
|
200
|
+
SLIST_NEXT((slistelm), field) = (elm); \
|
201
|
+
} while (0)
|
202
|
+
|
203
|
+
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
204
|
+
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
|
205
|
+
SLIST_FIRST((head)) = (elm); \
|
206
|
+
} while (0)
|
207
|
+
|
208
|
+
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
209
|
+
|
210
|
+
#define SLIST_REMOVE(head, elm, type, field) do { \
|
211
|
+
QMD_SAVELINK(oldnext, (elm)->field.sle_next); \
|
212
|
+
if (SLIST_FIRST((head)) == (elm)) { \
|
213
|
+
SLIST_REMOVE_HEAD((head), field); \
|
214
|
+
} \
|
215
|
+
else { \
|
216
|
+
struct type *curelm = SLIST_FIRST((head)); \
|
217
|
+
while (SLIST_NEXT(curelm, field) != (elm)) \
|
218
|
+
curelm = SLIST_NEXT(curelm, field); \
|
219
|
+
SLIST_REMOVE_AFTER(curelm, field); \
|
220
|
+
} \
|
221
|
+
TRASHIT(*oldnext); \
|
222
|
+
} while (0)
|
223
|
+
|
224
|
+
#define SLIST_REMOVE_AFTER(elm, field) do { \
|
225
|
+
SLIST_NEXT(elm, field) = \
|
226
|
+
SLIST_NEXT(SLIST_NEXT(elm, field), field); \
|
227
|
+
} while (0)
|
228
|
+
|
229
|
+
#define SLIST_REMOVE_HEAD(head, field) do { \
|
230
|
+
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
|
231
|
+
} while (0)
|
232
|
+
|
233
|
+
#define SLIST_SWAP(head1, head2, type) do { \
|
234
|
+
struct type *swap_first = SLIST_FIRST(head1); \
|
235
|
+
SLIST_FIRST(head1) = SLIST_FIRST(head2); \
|
236
|
+
SLIST_FIRST(head2) = swap_first; \
|
237
|
+
} while (0)
|
238
|
+
|
239
|
+
/*
|
240
|
+
* Singly-linked Tail queue declarations.
|
241
|
+
*/
|
242
|
+
#define STAILQ_HEAD(name, type) \
|
243
|
+
struct name { \
|
244
|
+
struct type *stqh_first;/* first element */ \
|
245
|
+
struct type **stqh_last;/* addr of last next element */ \
|
246
|
+
}
|
247
|
+
|
248
|
+
#define STAILQ_HEAD_INITIALIZER(head) \
|
249
|
+
{ NULL, &(head).stqh_first }
|
250
|
+
|
251
|
+
#define STAILQ_ENTRY(type) \
|
252
|
+
struct { \
|
253
|
+
struct type *stqe_next; /* next element */ \
|
254
|
+
}
|
255
|
+
|
256
|
+
/*
|
257
|
+
* Singly-linked Tail queue functions.
|
258
|
+
*/
|
259
|
+
#define STAILQ_CONCAT(head1, head2) do { \
|
260
|
+
if (!STAILQ_EMPTY((head2))) { \
|
261
|
+
*(head1)->stqh_last = (head2)->stqh_first; \
|
262
|
+
(head1)->stqh_last = (head2)->stqh_last; \
|
263
|
+
STAILQ_INIT((head2)); \
|
264
|
+
} \
|
265
|
+
} while (0)
|
266
|
+
|
267
|
+
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
|
268
|
+
|
269
|
+
#define STAILQ_FIRST(head) ((head)->stqh_first)
|
270
|
+
|
271
|
+
#define STAILQ_FOREACH(var, head, field) \
|
272
|
+
for((var) = STAILQ_FIRST((head)); \
|
273
|
+
(var); \
|
274
|
+
(var) = STAILQ_NEXT((var), field))
|
275
|
+
|
276
|
+
#define STAILQ_FOREACH_FROM(var, head, field) \
|
277
|
+
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
|
278
|
+
(var); \
|
279
|
+
(var) = STAILQ_NEXT((var), field))
|
280
|
+
|
281
|
+
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
282
|
+
for ((var) = STAILQ_FIRST((head)); \
|
283
|
+
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
284
|
+
(var) = (tvar))
|
285
|
+
|
286
|
+
#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
287
|
+
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
|
288
|
+
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
289
|
+
(var) = (tvar))
|
290
|
+
|
291
|
+
#define STAILQ_INIT(head) do { \
|
292
|
+
STAILQ_FIRST((head)) = NULL; \
|
293
|
+
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
294
|
+
} while (0)
|
295
|
+
|
296
|
+
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
|
297
|
+
if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
|
298
|
+
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
299
|
+
STAILQ_NEXT((tqelm), field) = (elm); \
|
300
|
+
} while (0)
|
301
|
+
|
302
|
+
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
|
303
|
+
if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
|
304
|
+
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
305
|
+
STAILQ_FIRST((head)) = (elm); \
|
306
|
+
} while (0)
|
307
|
+
|
308
|
+
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
|
309
|
+
STAILQ_NEXT((elm), field) = NULL; \
|
310
|
+
*(head)->stqh_last = (elm); \
|
311
|
+
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
312
|
+
} while (0)
|
313
|
+
|
314
|
+
#define STAILQ_LAST(head, type, field) \
|
315
|
+
(STAILQ_EMPTY((head)) ? NULL : \
|
316
|
+
__containerof((head)->stqh_last, struct type, field.stqe_next))
|
317
|
+
|
318
|
+
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
319
|
+
|
320
|
+
#define STAILQ_REMOVE(head, elm, type, field) do { \
|
321
|
+
QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
|
322
|
+
if (STAILQ_FIRST((head)) == (elm)) { \
|
323
|
+
STAILQ_REMOVE_HEAD((head), field); \
|
324
|
+
} \
|
325
|
+
else { \
|
326
|
+
struct type *curelm = STAILQ_FIRST((head)); \
|
327
|
+
while (STAILQ_NEXT(curelm, field) != (elm)) \
|
328
|
+
curelm = STAILQ_NEXT(curelm, field); \
|
329
|
+
STAILQ_REMOVE_AFTER(head, curelm, field); \
|
330
|
+
} \
|
331
|
+
TRASHIT(*oldnext); \
|
332
|
+
} while (0)
|
333
|
+
|
334
|
+
#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
|
335
|
+
if ((STAILQ_NEXT(elm, field) = \
|
336
|
+
STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
|
337
|
+
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
338
|
+
} while (0)
|
339
|
+
|
340
|
+
#define STAILQ_REMOVE_HEAD(head, field) do { \
|
341
|
+
if ((STAILQ_FIRST((head)) = \
|
342
|
+
STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
|
343
|
+
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
344
|
+
} while (0)
|
345
|
+
|
346
|
+
#define STAILQ_SWAP(head1, head2, type) do { \
|
347
|
+
struct type *swap_first = STAILQ_FIRST(head1); \
|
348
|
+
struct type **swap_last = (head1)->stqh_last; \
|
349
|
+
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
|
350
|
+
(head1)->stqh_last = (head2)->stqh_last; \
|
351
|
+
STAILQ_FIRST(head2) = swap_first; \
|
352
|
+
(head2)->stqh_last = swap_last; \
|
353
|
+
if (STAILQ_EMPTY(head1)) \
|
354
|
+
(head1)->stqh_last = &STAILQ_FIRST(head1); \
|
355
|
+
if (STAILQ_EMPTY(head2)) \
|
356
|
+
(head2)->stqh_last = &STAILQ_FIRST(head2); \
|
357
|
+
} while (0)
|
358
|
+
|
359
|
+
|
360
|
+
/*
|
361
|
+
* List declarations.
|
362
|
+
*/
|
363
|
+
#define LIST_HEAD(name, type) \
|
364
|
+
struct name { \
|
365
|
+
struct type *lh_first; /* first element */ \
|
366
|
+
}
|
367
|
+
|
368
|
+
#define LIST_HEAD_INITIALIZER(head) \
|
369
|
+
{ NULL }
|
370
|
+
|
371
|
+
#define LIST_ENTRY(type) \
|
372
|
+
struct { \
|
373
|
+
struct type *le_next; /* next element */ \
|
374
|
+
struct type **le_prev; /* address of previous next element */ \
|
375
|
+
}
|
376
|
+
|
377
|
+
/*
|
378
|
+
* List functions.
|
379
|
+
*/
|
380
|
+
|
381
|
+
#if (defined(_KERNEL) && defined(INVARIANTS))
|
382
|
+
#define QMD_LIST_CHECK_HEAD(head, field) do { \
|
383
|
+
if (LIST_FIRST((head)) != NULL && \
|
384
|
+
LIST_FIRST((head))->field.le_prev != \
|
385
|
+
&LIST_FIRST((head))) \
|
386
|
+
panic("Bad list head %p first->prev != head", (head)); \
|
387
|
+
} while (0)
|
388
|
+
|
389
|
+
#define QMD_LIST_CHECK_NEXT(elm, field) do { \
|
390
|
+
if (LIST_NEXT((elm), field) != NULL && \
|
391
|
+
LIST_NEXT((elm), field)->field.le_prev != \
|
392
|
+
&((elm)->field.le_next)) \
|
393
|
+
panic("Bad link elm %p next->prev != elm", (elm)); \
|
394
|
+
} while (0)
|
395
|
+
|
396
|
+
#define QMD_LIST_CHECK_PREV(elm, field) do { \
|
397
|
+
if (*(elm)->field.le_prev != (elm)) \
|
398
|
+
panic("Bad link elm %p prev->next != elm", (elm)); \
|
399
|
+
} while (0)
|
400
|
+
#else
|
401
|
+
#define QMD_LIST_CHECK_HEAD(head, field)
|
402
|
+
#define QMD_LIST_CHECK_NEXT(elm, field)
|
403
|
+
#define QMD_LIST_CHECK_PREV(elm, field)
|
404
|
+
#endif /* (_KERNEL && INVARIANTS) */
|
405
|
+
|
406
|
+
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
|
407
|
+
|
408
|
+
#define LIST_FIRST(head) ((head)->lh_first)
|
409
|
+
|
410
|
+
#define LIST_FOREACH(var, head, field) \
|
411
|
+
for ((var) = LIST_FIRST((head)); \
|
412
|
+
(var); \
|
413
|
+
(var) = LIST_NEXT((var), field))
|
414
|
+
|
415
|
+
#define LIST_FOREACH_FROM(var, head, field) \
|
416
|
+
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
|
417
|
+
(var); \
|
418
|
+
(var) = LIST_NEXT((var), field))
|
419
|
+
|
420
|
+
#define LIST_FOREACH_SAFE(var, head, field, tvar) \
|
421
|
+
for ((var) = LIST_FIRST((head)); \
|
422
|
+
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
423
|
+
(var) = (tvar))
|
424
|
+
|
425
|
+
#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
426
|
+
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
|
427
|
+
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
428
|
+
(var) = (tvar))
|
429
|
+
|
430
|
+
#define LIST_INIT(head) do { \
|
431
|
+
LIST_FIRST((head)) = NULL; \
|
432
|
+
} while (0)
|
433
|
+
|
434
|
+
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
435
|
+
QMD_LIST_CHECK_NEXT(listelm, field); \
|
436
|
+
if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
|
437
|
+
LIST_NEXT((listelm), field)->field.le_prev = \
|
438
|
+
&LIST_NEXT((elm), field); \
|
439
|
+
LIST_NEXT((listelm), field) = (elm); \
|
440
|
+
(elm)->field.le_prev = &LIST_NEXT((listelm), field); \
|
441
|
+
} while (0)
|
442
|
+
|
443
|
+
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
444
|
+
QMD_LIST_CHECK_PREV(listelm, field); \
|
445
|
+
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
446
|
+
LIST_NEXT((elm), field) = (listelm); \
|
447
|
+
*(listelm)->field.le_prev = (elm); \
|
448
|
+
(listelm)->field.le_prev = &LIST_NEXT((elm), field); \
|
449
|
+
} while (0)
|
450
|
+
|
451
|
+
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
452
|
+
QMD_LIST_CHECK_HEAD((head), field); \
|
453
|
+
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
|
454
|
+
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
|
455
|
+
LIST_FIRST((head)) = (elm); \
|
456
|
+
(elm)->field.le_prev = &LIST_FIRST((head)); \
|
457
|
+
} while (0)
|
458
|
+
|
459
|
+
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
460
|
+
|
461
|
+
#define LIST_PREV(elm, head, type, field) \
|
462
|
+
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
|
463
|
+
__containerof((elm)->field.le_prev, struct type, field.le_next))
|
464
|
+
|
465
|
+
#define LIST_REMOVE(elm, field) do { \
|
466
|
+
QMD_SAVELINK(oldnext, (elm)->field.le_next); \
|
467
|
+
QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
|
468
|
+
QMD_LIST_CHECK_NEXT(elm, field); \
|
469
|
+
QMD_LIST_CHECK_PREV(elm, field); \
|
470
|
+
if (LIST_NEXT((elm), field) != NULL) \
|
471
|
+
LIST_NEXT((elm), field)->field.le_prev = \
|
472
|
+
(elm)->field.le_prev; \
|
473
|
+
*(elm)->field.le_prev = LIST_NEXT((elm), field); \
|
474
|
+
TRASHIT(*oldnext); \
|
475
|
+
TRASHIT(*oldprev); \
|
476
|
+
} while (0)
|
477
|
+
|
478
|
+
#define LIST_SWAP(head1, head2, type, field) do { \
|
479
|
+
struct type *swap_tmp = LIST_FIRST((head1)); \
|
480
|
+
LIST_FIRST((head1)) = LIST_FIRST((head2)); \
|
481
|
+
LIST_FIRST((head2)) = swap_tmp; \
|
482
|
+
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
|
483
|
+
swap_tmp->field.le_prev = &LIST_FIRST((head1)); \
|
484
|
+
if ((swap_tmp = LIST_FIRST((head2))) != NULL) \
|
485
|
+
swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
|
486
|
+
} while (0)
|
487
|
+
|
488
|
+
/*
|
489
|
+
* Tail queue declarations.
|
490
|
+
*/
|
491
|
+
#define TAILQ_HEAD(name, type) \
|
492
|
+
struct name { \
|
493
|
+
struct type *tqh_first; /* first element */ \
|
494
|
+
struct type **tqh_last; /* addr of last next element */ \
|
495
|
+
TRACEBUF \
|
496
|
+
}
|
497
|
+
|
498
|
+
#define TAILQ_HEAD_INITIALIZER(head) \
|
499
|
+
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
|
500
|
+
|
501
|
+
#define TAILQ_ENTRY(type) \
|
502
|
+
struct { \
|
503
|
+
struct type *tqe_next; /* next element */ \
|
504
|
+
struct type **tqe_prev; /* address of previous next element */ \
|
505
|
+
TRACEBUF \
|
506
|
+
}
|
507
|
+
|
508
|
+
/*
|
509
|
+
* Tail queue functions.
|
510
|
+
*/
|
511
|
+
#if (defined(_KERNEL) && defined(INVARIANTS))
|
512
|
+
#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
|
513
|
+
if (!TAILQ_EMPTY(head) && \
|
514
|
+
TAILQ_FIRST((head))->field.tqe_prev != \
|
515
|
+
&TAILQ_FIRST((head))) \
|
516
|
+
panic("Bad tailq head %p first->prev != head", (head)); \
|
517
|
+
} while (0)
|
518
|
+
|
519
|
+
#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
|
520
|
+
if (*(head)->tqh_last != NULL) \
|
521
|
+
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
|
522
|
+
} while (0)
|
523
|
+
|
524
|
+
#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
|
525
|
+
if (TAILQ_NEXT((elm), field) != NULL && \
|
526
|
+
TAILQ_NEXT((elm), field)->field.tqe_prev != \
|
527
|
+
&((elm)->field.tqe_next)) \
|
528
|
+
panic("Bad link elm %p next->prev != elm", (elm)); \
|
529
|
+
} while (0)
|
530
|
+
|
531
|
+
#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
|
532
|
+
if (*(elm)->field.tqe_prev != (elm)) \
|
533
|
+
panic("Bad link elm %p prev->next != elm", (elm)); \
|
534
|
+
} while (0)
|
535
|
+
#else
|
536
|
+
#define QMD_TAILQ_CHECK_HEAD(head, field)
|
537
|
+
#define QMD_TAILQ_CHECK_TAIL(head, headname)
|
538
|
+
#define QMD_TAILQ_CHECK_NEXT(elm, field)
|
539
|
+
#define QMD_TAILQ_CHECK_PREV(elm, field)
|
540
|
+
#endif /* (_KERNEL && INVARIANTS) */
|
541
|
+
|
542
|
+
#define TAILQ_CONCAT(head1, head2, field) do { \
|
543
|
+
if (!TAILQ_EMPTY(head2)) { \
|
544
|
+
*(head1)->tqh_last = (head2)->tqh_first; \
|
545
|
+
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
|
546
|
+
(head1)->tqh_last = (head2)->tqh_last; \
|
547
|
+
TAILQ_INIT((head2)); \
|
548
|
+
QMD_TRACE_HEAD(head1); \
|
549
|
+
QMD_TRACE_HEAD(head2); \
|
550
|
+
} \
|
551
|
+
} while (0)
|
552
|
+
|
553
|
+
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
|
554
|
+
|
555
|
+
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
556
|
+
|
557
|
+
#define TAILQ_FOREACH(var, head, field) \
|
558
|
+
for ((var) = TAILQ_FIRST((head)); \
|
559
|
+
(var); \
|
560
|
+
(var) = TAILQ_NEXT((var), field))
|
561
|
+
|
562
|
+
#define TAILQ_FOREACH_FROM(var, head, field) \
|
563
|
+
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
|
564
|
+
(var); \
|
565
|
+
(var) = TAILQ_NEXT((var), field))
|
566
|
+
|
567
|
+
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
568
|
+
for ((var) = TAILQ_FIRST((head)); \
|
569
|
+
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
570
|
+
(var) = (tvar))
|
571
|
+
|
572
|
+
#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
|
573
|
+
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
|
574
|
+
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
575
|
+
(var) = (tvar))
|
576
|
+
|
577
|
+
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
578
|
+
for ((var) = TAILQ_LAST((head), headname); \
|
579
|
+
(var); \
|
580
|
+
(var) = TAILQ_PREV((var), headname, field))
|
581
|
+
|
582
|
+
#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
|
583
|
+
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
|
584
|
+
(var); \
|
585
|
+
(var) = TAILQ_PREV((var), headname, field))
|
586
|
+
|
587
|
+
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
|
588
|
+
for ((var) = TAILQ_LAST((head), headname); \
|
589
|
+
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
|
590
|
+
(var) = (tvar))
|
591
|
+
|
592
|
+
#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \
|
593
|
+
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
|
594
|
+
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
|
595
|
+
(var) = (tvar))
|
596
|
+
|
597
|
+
#define TAILQ_INIT(head) do { \
|
598
|
+
TAILQ_FIRST((head)) = NULL; \
|
599
|
+
(head)->tqh_last = &TAILQ_FIRST((head)); \
|
600
|
+
QMD_TRACE_HEAD(head); \
|
601
|
+
} while (0)
|
602
|
+
|
603
|
+
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
604
|
+
QMD_TAILQ_CHECK_NEXT(listelm, field); \
|
605
|
+
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
|
606
|
+
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
607
|
+
&TAILQ_NEXT((elm), field); \
|
608
|
+
else { \
|
609
|
+
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
610
|
+
QMD_TRACE_HEAD(head); \
|
611
|
+
} \
|
612
|
+
TAILQ_NEXT((listelm), field) = (elm); \
|
613
|
+
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
|
614
|
+
QMD_TRACE_ELEM(&(elm)->field); \
|
615
|
+
QMD_TRACE_ELEM(&listelm->field); \
|
616
|
+
} while (0)
|
617
|
+
|
618
|
+
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
619
|
+
QMD_TAILQ_CHECK_PREV(listelm, field); \
|
620
|
+
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
621
|
+
TAILQ_NEXT((elm), field) = (listelm); \
|
622
|
+
*(listelm)->field.tqe_prev = (elm); \
|
623
|
+
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
|
624
|
+
QMD_TRACE_ELEM(&(elm)->field); \
|
625
|
+
QMD_TRACE_ELEM(&listelm->field); \
|
626
|
+
} while (0)
|
627
|
+
|
628
|
+
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
629
|
+
QMD_TAILQ_CHECK_HEAD(head, field); \
|
630
|
+
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
|
631
|
+
TAILQ_FIRST((head))->field.tqe_prev = \
|
632
|
+
&TAILQ_NEXT((elm), field); \
|
633
|
+
else \
|
634
|
+
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
635
|
+
TAILQ_FIRST((head)) = (elm); \
|
636
|
+
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
|
637
|
+
QMD_TRACE_HEAD(head); \
|
638
|
+
QMD_TRACE_ELEM(&(elm)->field); \
|
639
|
+
} while (0)
|
640
|
+
|
641
|
+
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
642
|
+
QMD_TAILQ_CHECK_TAIL(head, field); \
|
643
|
+
TAILQ_NEXT((elm), field) = NULL; \
|
644
|
+
(elm)->field.tqe_prev = (head)->tqh_last; \
|
645
|
+
*(head)->tqh_last = (elm); \
|
646
|
+
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
647
|
+
QMD_TRACE_HEAD(head); \
|
648
|
+
QMD_TRACE_ELEM(&(elm)->field); \
|
649
|
+
} while (0)
|
650
|
+
|
651
|
+
#define TAILQ_LAST(head, headname) \
|
652
|
+
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
653
|
+
|
654
|
+
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
655
|
+
|
656
|
+
#define TAILQ_PREV(elm, headname, field) \
|
657
|
+
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
658
|
+
|
659
|
+
#define TAILQ_REMOVE(head, elm, field) do { \
|
660
|
+
QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
|
661
|
+
QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
|
662
|
+
QMD_TAILQ_CHECK_NEXT(elm, field); \
|
663
|
+
QMD_TAILQ_CHECK_PREV(elm, field); \
|
664
|
+
if ((TAILQ_NEXT((elm), field)) != NULL) \
|
665
|
+
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
666
|
+
(elm)->field.tqe_prev; \
|
667
|
+
else { \
|
668
|
+
(head)->tqh_last = (elm)->field.tqe_prev; \
|
669
|
+
QMD_TRACE_HEAD(head); \
|
670
|
+
} \
|
671
|
+
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
|
672
|
+
TRASHIT(*oldnext); \
|
673
|
+
TRASHIT(*oldprev); \
|
674
|
+
QMD_TRACE_ELEM(&(elm)->field); \
|
675
|
+
} while (0)
|
676
|
+
|
677
|
+
#define TAILQ_SWAP(head1, head2, type, field) do { \
|
678
|
+
struct type *swap_first = (head1)->tqh_first; \
|
679
|
+
struct type **swap_last = (head1)->tqh_last; \
|
680
|
+
(head1)->tqh_first = (head2)->tqh_first; \
|
681
|
+
(head1)->tqh_last = (head2)->tqh_last; \
|
682
|
+
(head2)->tqh_first = swap_first; \
|
683
|
+
(head2)->tqh_last = swap_last; \
|
684
|
+
if ((swap_first = (head1)->tqh_first) != NULL) \
|
685
|
+
swap_first->field.tqe_prev = &(head1)->tqh_first; \
|
686
|
+
else \
|
687
|
+
(head1)->tqh_last = &(head1)->tqh_first; \
|
688
|
+
if ((swap_first = (head2)->tqh_first) != NULL) \
|
689
|
+
swap_first->field.tqe_prev = &(head2)->tqh_first; \
|
690
|
+
else \
|
691
|
+
(head2)->tqh_last = &(head2)->tqh_first; \
|
692
|
+
} while (0)
|
693
|
+
|
694
|
+
#endif /* !_SYS_QUEUE_H_ */
|