Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/sys
File: queue.h
/*
[0] Fix | Delete
* Copyright (c) 1991, 1993
[1] Fix | Delete
* The Regents of the University of California. All rights reserved.
[2] Fix | Delete
*
[3] Fix | Delete
* Redistribution and use in source and binary forms, with or without
[4] Fix | Delete
* modification, are permitted provided that the following conditions
[5] Fix | Delete
* are met:
[6] Fix | Delete
* 1. Redistributions of source code must retain the above copyright
[7] Fix | Delete
* notice, this list of conditions and the following disclaimer.
[8] Fix | Delete
* 2. Redistributions in binary form must reproduce the above copyright
[9] Fix | Delete
* notice, this list of conditions and the following disclaimer in the
[10] Fix | Delete
* documentation and/or other materials provided with the distribution.
[11] Fix | Delete
* 3. Neither the name of the University nor the names of its contributors
[12] Fix | Delete
* may be used to endorse or promote products derived from this software
[13] Fix | Delete
* without specific prior written permission.
[14] Fix | Delete
*
[15] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
[16] Fix | Delete
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
[17] Fix | Delete
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
[18] Fix | Delete
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
[19] Fix | Delete
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
[20] Fix | Delete
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
[21] Fix | Delete
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
[22] Fix | Delete
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
[23] Fix | Delete
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
[24] Fix | Delete
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
[25] Fix | Delete
* SUCH DAMAGE.
[26] Fix | Delete
*
[27] Fix | Delete
* @(#)queue.h 8.5 (Berkeley) 8/20/94
[28] Fix | Delete
*/
[29] Fix | Delete
[30] Fix | Delete
#ifndef _SYS_QUEUE_H_
[31] Fix | Delete
#define _SYS_QUEUE_H_
[32] Fix | Delete
[33] Fix | Delete
/*
[34] Fix | Delete
* This file defines five types of data structures: singly-linked lists,
[35] Fix | Delete
* lists, simple queues, tail queues, and circular queues.
[36] Fix | Delete
*
[37] Fix | Delete
* A singly-linked list is headed by a single forward pointer. The
[38] Fix | Delete
* elements are singly linked for minimum space and pointer manipulation
[39] Fix | Delete
* overhead at the expense of O(n) removal for arbitrary elements. New
[40] Fix | Delete
* elements can be added to the list after an existing element or at the
[41] Fix | Delete
* head of the list. Elements being removed from the head of the list
[42] Fix | Delete
* should use the explicit macro for this purpose for optimum
[43] Fix | Delete
* efficiency. A singly-linked list may only be traversed in the forward
[44] Fix | Delete
* direction. Singly-linked lists are ideal for applications with large
[45] Fix | Delete
* datasets and few or no removals or for implementing a LIFO queue.
[46] Fix | Delete
*
[47] Fix | Delete
* A list is headed by a single forward pointer (or an array of forward
[48] Fix | Delete
* pointers for a hash table header). The elements are doubly linked
[49] Fix | Delete
* so that an arbitrary element can be removed without a need to
[50] Fix | Delete
* traverse the list. New elements can be added to the list before
[51] Fix | Delete
* or after an existing element or at the head of the list. A list
[52] Fix | Delete
* may only be traversed in the forward direction.
[53] Fix | Delete
*
[54] Fix | Delete
* A simple queue is headed by a pair of pointers, one the head of the
[55] Fix | Delete
* list and the other to the tail of the list. The elements are singly
[56] Fix | Delete
* linked to save space, so elements can only be removed from the
[57] Fix | Delete
* head of the list. New elements can be added to the list after
[58] Fix | Delete
* an existing element, at the head of the list, or at the end of the
[59] Fix | Delete
* list. A simple queue may only be traversed in the forward direction.
[60] Fix | Delete
*
[61] Fix | Delete
* A tail queue is headed by a pair of pointers, one to the head of the
[62] Fix | Delete
* list and the other to the tail of the list. The elements are doubly
[63] Fix | Delete
* linked so that an arbitrary element can be removed without a need to
[64] Fix | Delete
* traverse the list. New elements can be added to the list before or
[65] Fix | Delete
* after an existing element, at the head of the list, or at the end of
[66] Fix | Delete
* the list. A tail queue may be traversed in either direction.
[67] Fix | Delete
*
[68] Fix | Delete
* A circle queue is headed by a pair of pointers, one to the head of the
[69] Fix | Delete
* list and the other to the tail of the list. The elements are doubly
[70] Fix | Delete
* linked so that an arbitrary element can be removed without a need to
[71] Fix | Delete
* traverse the list. New elements can be added to the list before or after
[72] Fix | Delete
* an existing element, at the head of the list, or at the end of the list.
[73] Fix | Delete
* A circle queue may be traversed in either direction, but has a more
[74] Fix | Delete
* complex end of list detection.
[75] Fix | Delete
*
[76] Fix | Delete
* For details on the use of these macros, see the queue(3) manual page.
[77] Fix | Delete
*/
[78] Fix | Delete
[79] Fix | Delete
/*
[80] Fix | Delete
* List definitions.
[81] Fix | Delete
*/
[82] Fix | Delete
#define LIST_HEAD(name, type) \
[83] Fix | Delete
struct name { \
[84] Fix | Delete
struct type *lh_first; /* first element */ \
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
#define LIST_HEAD_INITIALIZER(head) \
[88] Fix | Delete
{ NULL }
[89] Fix | Delete
[90] Fix | Delete
#define LIST_ENTRY(type) \
[91] Fix | Delete
struct { \
[92] Fix | Delete
struct type *le_next; /* next element */ \
[93] Fix | Delete
struct type **le_prev; /* address of previous next element */ \
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
/*
[97] Fix | Delete
* List functions.
[98] Fix | Delete
*/
[99] Fix | Delete
#define LIST_INIT(head) do { \
[100] Fix | Delete
(head)->lh_first = NULL; \
[101] Fix | Delete
} while (/*CONSTCOND*/0)
[102] Fix | Delete
[103] Fix | Delete
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
[104] Fix | Delete
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
[105] Fix | Delete
(listelm)->field.le_next->field.le_prev = \
[106] Fix | Delete
&(elm)->field.le_next; \
[107] Fix | Delete
(listelm)->field.le_next = (elm); \
[108] Fix | Delete
(elm)->field.le_prev = &(listelm)->field.le_next; \
[109] Fix | Delete
} while (/*CONSTCOND*/0)
[110] Fix | Delete
[111] Fix | Delete
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
[112] Fix | Delete
(elm)->field.le_prev = (listelm)->field.le_prev; \
[113] Fix | Delete
(elm)->field.le_next = (listelm); \
[114] Fix | Delete
*(listelm)->field.le_prev = (elm); \
[115] Fix | Delete
(listelm)->field.le_prev = &(elm)->field.le_next; \
[116] Fix | Delete
} while (/*CONSTCOND*/0)
[117] Fix | Delete
[118] Fix | Delete
#define LIST_INSERT_HEAD(head, elm, field) do { \
[119] Fix | Delete
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
[120] Fix | Delete
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
[121] Fix | Delete
(head)->lh_first = (elm); \
[122] Fix | Delete
(elm)->field.le_prev = &(head)->lh_first; \
[123] Fix | Delete
} while (/*CONSTCOND*/0)
[124] Fix | Delete
[125] Fix | Delete
#define LIST_REMOVE(elm, field) do { \
[126] Fix | Delete
if ((elm)->field.le_next != NULL) \
[127] Fix | Delete
(elm)->field.le_next->field.le_prev = \
[128] Fix | Delete
(elm)->field.le_prev; \
[129] Fix | Delete
*(elm)->field.le_prev = (elm)->field.le_next; \
[130] Fix | Delete
} while (/*CONSTCOND*/0)
[131] Fix | Delete
[132] Fix | Delete
#define LIST_FOREACH(var, head, field) \
[133] Fix | Delete
for ((var) = ((head)->lh_first); \
[134] Fix | Delete
(var); \
[135] Fix | Delete
(var) = ((var)->field.le_next))
[136] Fix | Delete
[137] Fix | Delete
/*
[138] Fix | Delete
* List access methods.
[139] Fix | Delete
*/
[140] Fix | Delete
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
[141] Fix | Delete
#define LIST_FIRST(head) ((head)->lh_first)
[142] Fix | Delete
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
[143] Fix | Delete
[144] Fix | Delete
[145] Fix | Delete
/*
[146] Fix | Delete
* Singly-linked List definitions.
[147] Fix | Delete
*/
[148] Fix | Delete
#define SLIST_HEAD(name, type) \
[149] Fix | Delete
struct name { \
[150] Fix | Delete
struct type *slh_first; /* first element */ \
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
#define SLIST_HEAD_INITIALIZER(head) \
[154] Fix | Delete
{ NULL }
[155] Fix | Delete
[156] Fix | Delete
#define SLIST_ENTRY(type) \
[157] Fix | Delete
struct { \
[158] Fix | Delete
struct type *sle_next; /* next element */ \
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
/*
[162] Fix | Delete
* Singly-linked List functions.
[163] Fix | Delete
*/
[164] Fix | Delete
#define SLIST_INIT(head) do { \
[165] Fix | Delete
(head)->slh_first = NULL; \
[166] Fix | Delete
} while (/*CONSTCOND*/0)
[167] Fix | Delete
[168] Fix | Delete
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
[169] Fix | Delete
(elm)->field.sle_next = (slistelm)->field.sle_next; \
[170] Fix | Delete
(slistelm)->field.sle_next = (elm); \
[171] Fix | Delete
} while (/*CONSTCOND*/0)
[172] Fix | Delete
[173] Fix | Delete
#define SLIST_INSERT_HEAD(head, elm, field) do { \
[174] Fix | Delete
(elm)->field.sle_next = (head)->slh_first; \
[175] Fix | Delete
(head)->slh_first = (elm); \
[176] Fix | Delete
} while (/*CONSTCOND*/0)
[177] Fix | Delete
[178] Fix | Delete
#define SLIST_REMOVE_HEAD(head, field) do { \
[179] Fix | Delete
(head)->slh_first = (head)->slh_first->field.sle_next; \
[180] Fix | Delete
} while (/*CONSTCOND*/0)
[181] Fix | Delete
[182] Fix | Delete
#define SLIST_REMOVE(head, elm, type, field) do { \
[183] Fix | Delete
if ((head)->slh_first == (elm)) { \
[184] Fix | Delete
SLIST_REMOVE_HEAD((head), field); \
[185] Fix | Delete
} \
[186] Fix | Delete
else { \
[187] Fix | Delete
struct type *curelm = (head)->slh_first; \
[188] Fix | Delete
while(curelm->field.sle_next != (elm)) \
[189] Fix | Delete
curelm = curelm->field.sle_next; \
[190] Fix | Delete
curelm->field.sle_next = \
[191] Fix | Delete
curelm->field.sle_next->field.sle_next; \
[192] Fix | Delete
} \
[193] Fix | Delete
} while (/*CONSTCOND*/0)
[194] Fix | Delete
[195] Fix | Delete
#define SLIST_FOREACH(var, head, field) \
[196] Fix | Delete
for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
[197] Fix | Delete
[198] Fix | Delete
/*
[199] Fix | Delete
* Singly-linked List access methods.
[200] Fix | Delete
*/
[201] Fix | Delete
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
[202] Fix | Delete
#define SLIST_FIRST(head) ((head)->slh_first)
[203] Fix | Delete
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
[204] Fix | Delete
[205] Fix | Delete
[206] Fix | Delete
/*
[207] Fix | Delete
* Singly-linked Tail queue declarations.
[208] Fix | Delete
*/
[209] Fix | Delete
#define STAILQ_HEAD(name, type) \
[210] Fix | Delete
struct name { \
[211] Fix | Delete
struct type *stqh_first; /* first element */ \
[212] Fix | Delete
struct type **stqh_last; /* addr of last next element */ \
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
#define STAILQ_HEAD_INITIALIZER(head) \
[216] Fix | Delete
{ NULL, &(head).stqh_first }
[217] Fix | Delete
[218] Fix | Delete
#define STAILQ_ENTRY(type) \
[219] Fix | Delete
struct { \
[220] Fix | Delete
struct type *stqe_next; /* next element */ \
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
/*
[224] Fix | Delete
* Singly-linked Tail queue functions.
[225] Fix | Delete
*/
[226] Fix | Delete
#define STAILQ_INIT(head) do { \
[227] Fix | Delete
(head)->stqh_first = NULL; \
[228] Fix | Delete
(head)->stqh_last = &(head)->stqh_first; \
[229] Fix | Delete
} while (/*CONSTCOND*/0)
[230] Fix | Delete
[231] Fix | Delete
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
[232] Fix | Delete
if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
[233] Fix | Delete
(head)->stqh_last = &(elm)->field.stqe_next; \
[234] Fix | Delete
(head)->stqh_first = (elm); \
[235] Fix | Delete
} while (/*CONSTCOND*/0)
[236] Fix | Delete
[237] Fix | Delete
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
[238] Fix | Delete
(elm)->field.stqe_next = NULL; \
[239] Fix | Delete
*(head)->stqh_last = (elm); \
[240] Fix | Delete
(head)->stqh_last = &(elm)->field.stqe_next; \
[241] Fix | Delete
} while (/*CONSTCOND*/0)
[242] Fix | Delete
[243] Fix | Delete
#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
[244] Fix | Delete
if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
[245] Fix | Delete
(head)->stqh_last = &(elm)->field.stqe_next; \
[246] Fix | Delete
(listelm)->field.stqe_next = (elm); \
[247] Fix | Delete
} while (/*CONSTCOND*/0)
[248] Fix | Delete
[249] Fix | Delete
#define STAILQ_REMOVE_HEAD(head, field) do { \
[250] Fix | Delete
if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
[251] Fix | Delete
(head)->stqh_last = &(head)->stqh_first; \
[252] Fix | Delete
} while (/*CONSTCOND*/0)
[253] Fix | Delete
[254] Fix | Delete
#define STAILQ_REMOVE(head, elm, type, field) do { \
[255] Fix | Delete
if ((head)->stqh_first == (elm)) { \
[256] Fix | Delete
STAILQ_REMOVE_HEAD((head), field); \
[257] Fix | Delete
} else { \
[258] Fix | Delete
struct type *curelm = (head)->stqh_first; \
[259] Fix | Delete
while (curelm->field.stqe_next != (elm)) \
[260] Fix | Delete
curelm = curelm->field.stqe_next; \
[261] Fix | Delete
if ((curelm->field.stqe_next = \
[262] Fix | Delete
curelm->field.stqe_next->field.stqe_next) == NULL) \
[263] Fix | Delete
(head)->stqh_last = &(curelm)->field.stqe_next; \
[264] Fix | Delete
} \
[265] Fix | Delete
} while (/*CONSTCOND*/0)
[266] Fix | Delete
[267] Fix | Delete
#define STAILQ_FOREACH(var, head, field) \
[268] Fix | Delete
for ((var) = ((head)->stqh_first); \
[269] Fix | Delete
(var); \
[270] Fix | Delete
(var) = ((var)->field.stqe_next))
[271] Fix | Delete
[272] Fix | Delete
#define STAILQ_CONCAT(head1, head2) do { \
[273] Fix | Delete
if (!STAILQ_EMPTY((head2))) { \
[274] Fix | Delete
*(head1)->stqh_last = (head2)->stqh_first; \
[275] Fix | Delete
(head1)->stqh_last = (head2)->stqh_last; \
[276] Fix | Delete
STAILQ_INIT((head2)); \
[277] Fix | Delete
} \
[278] Fix | Delete
} while (/*CONSTCOND*/0)
[279] Fix | Delete
[280] Fix | Delete
/*
[281] Fix | Delete
* Singly-linked Tail queue access methods.
[282] Fix | Delete
*/
[283] Fix | Delete
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
[284] Fix | Delete
#define STAILQ_FIRST(head) ((head)->stqh_first)
[285] Fix | Delete
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
[286] Fix | Delete
[287] Fix | Delete
[288] Fix | Delete
/*
[289] Fix | Delete
* Simple queue definitions.
[290] Fix | Delete
*/
[291] Fix | Delete
#define SIMPLEQ_HEAD(name, type) \
[292] Fix | Delete
struct name { \
[293] Fix | Delete
struct type *sqh_first; /* first element */ \
[294] Fix | Delete
struct type **sqh_last; /* addr of last next element */ \
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
#define SIMPLEQ_HEAD_INITIALIZER(head) \
[298] Fix | Delete
{ NULL, &(head).sqh_first }
[299] Fix | Delete
[300] Fix | Delete
#define SIMPLEQ_ENTRY(type) \
[301] Fix | Delete
struct { \
[302] Fix | Delete
struct type *sqe_next; /* next element */ \
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
/*
[306] Fix | Delete
* Simple queue functions.
[307] Fix | Delete
*/
[308] Fix | Delete
#define SIMPLEQ_INIT(head) do { \
[309] Fix | Delete
(head)->sqh_first = NULL; \
[310] Fix | Delete
(head)->sqh_last = &(head)->sqh_first; \
[311] Fix | Delete
} while (/*CONSTCOND*/0)
[312] Fix | Delete
[313] Fix | Delete
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
[314] Fix | Delete
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
[315] Fix | Delete
(head)->sqh_last = &(elm)->field.sqe_next; \
[316] Fix | Delete
(head)->sqh_first = (elm); \
[317] Fix | Delete
} while (/*CONSTCOND*/0)
[318] Fix | Delete
[319] Fix | Delete
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
[320] Fix | Delete
(elm)->field.sqe_next = NULL; \
[321] Fix | Delete
*(head)->sqh_last = (elm); \
[322] Fix | Delete
(head)->sqh_last = &(elm)->field.sqe_next; \
[323] Fix | Delete
} while (/*CONSTCOND*/0)
[324] Fix | Delete
[325] Fix | Delete
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
[326] Fix | Delete
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
[327] Fix | Delete
(head)->sqh_last = &(elm)->field.sqe_next; \
[328] Fix | Delete
(listelm)->field.sqe_next = (elm); \
[329] Fix | Delete
} while (/*CONSTCOND*/0)
[330] Fix | Delete
[331] Fix | Delete
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
[332] Fix | Delete
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
[333] Fix | Delete
(head)->sqh_last = &(head)->sqh_first; \
[334] Fix | Delete
} while (/*CONSTCOND*/0)
[335] Fix | Delete
[336] Fix | Delete
#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
[337] Fix | Delete
if ((head)->sqh_first == (elm)) { \
[338] Fix | Delete
SIMPLEQ_REMOVE_HEAD((head), field); \
[339] Fix | Delete
} else { \
[340] Fix | Delete
struct type *curelm = (head)->sqh_first; \
[341] Fix | Delete
while (curelm->field.sqe_next != (elm)) \
[342] Fix | Delete
curelm = curelm->field.sqe_next; \
[343] Fix | Delete
if ((curelm->field.sqe_next = \
[344] Fix | Delete
curelm->field.sqe_next->field.sqe_next) == NULL) \
[345] Fix | Delete
(head)->sqh_last = &(curelm)->field.sqe_next; \
[346] Fix | Delete
} \
[347] Fix | Delete
} while (/*CONSTCOND*/0)
[348] Fix | Delete
[349] Fix | Delete
#define SIMPLEQ_FOREACH(var, head, field) \
[350] Fix | Delete
for ((var) = ((head)->sqh_first); \
[351] Fix | Delete
(var); \
[352] Fix | Delete
(var) = ((var)->field.sqe_next))
[353] Fix | Delete
[354] Fix | Delete
/*
[355] Fix | Delete
* Simple queue access methods.
[356] Fix | Delete
*/
[357] Fix | Delete
#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
[358] Fix | Delete
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
[359] Fix | Delete
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
[360] Fix | Delete
[361] Fix | Delete
[362] Fix | Delete
/*
[363] Fix | Delete
* Tail queue definitions.
[364] Fix | Delete
*/
[365] Fix | Delete
#define _TAILQ_HEAD(name, type, qual) \
[366] Fix | Delete
struct name { \
[367] Fix | Delete
qual type *tqh_first; /* first element */ \
[368] Fix | Delete
qual type *qual *tqh_last; /* addr of last next element */ \
[369] Fix | Delete
}
[370] Fix | Delete
#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
[371] Fix | Delete
[372] Fix | Delete
#define TAILQ_HEAD_INITIALIZER(head) \
[373] Fix | Delete
{ NULL, &(head).tqh_first }
[374] Fix | Delete
[375] Fix | Delete
#define _TAILQ_ENTRY(type, qual) \
[376] Fix | Delete
struct { \
[377] Fix | Delete
qual type *tqe_next; /* next element */ \
[378] Fix | Delete
qual type *qual *tqe_prev; /* address of previous next element */\
[379] Fix | Delete
}
[380] Fix | Delete
#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
[381] Fix | Delete
[382] Fix | Delete
/*
[383] Fix | Delete
* Tail queue functions.
[384] Fix | Delete
*/
[385] Fix | Delete
#define TAILQ_INIT(head) do { \
[386] Fix | Delete
(head)->tqh_first = NULL; \
[387] Fix | Delete
(head)->tqh_last = &(head)->tqh_first; \
[388] Fix | Delete
} while (/*CONSTCOND*/0)
[389] Fix | Delete
[390] Fix | Delete
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
[391] Fix | Delete
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
[392] Fix | Delete
(head)->tqh_first->field.tqe_prev = \
[393] Fix | Delete
&(elm)->field.tqe_next; \
[394] Fix | Delete
else \
[395] Fix | Delete
(head)->tqh_last = &(elm)->field.tqe_next; \
[396] Fix | Delete
(head)->tqh_first = (elm); \
[397] Fix | Delete
(elm)->field.tqe_prev = &(head)->tqh_first; \
[398] Fix | Delete
} while (/*CONSTCOND*/0)
[399] Fix | Delete
[400] Fix | Delete
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
[401] Fix | Delete
(elm)->field.tqe_next = NULL; \
[402] Fix | Delete
(elm)->field.tqe_prev = (head)->tqh_last; \
[403] Fix | Delete
*(head)->tqh_last = (elm); \
[404] Fix | Delete
(head)->tqh_last = &(elm)->field.tqe_next; \
[405] Fix | Delete
} while (/*CONSTCOND*/0)
[406] Fix | Delete
[407] Fix | Delete
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
[408] Fix | Delete
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
[409] Fix | Delete
(elm)->field.tqe_next->field.tqe_prev = \
[410] Fix | Delete
&(elm)->field.tqe_next; \
[411] Fix | Delete
else \
[412] Fix | Delete
(head)->tqh_last = &(elm)->field.tqe_next; \
[413] Fix | Delete
(listelm)->field.tqe_next = (elm); \
[414] Fix | Delete
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
[415] Fix | Delete
} while (/*CONSTCOND*/0)
[416] Fix | Delete
[417] Fix | Delete
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
[418] Fix | Delete
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
[419] Fix | Delete
(elm)->field.tqe_next = (listelm); \
[420] Fix | Delete
*(listelm)->field.tqe_prev = (elm); \
[421] Fix | Delete
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
[422] Fix | Delete
} while (/*CONSTCOND*/0)
[423] Fix | Delete
[424] Fix | Delete
#define TAILQ_REMOVE(head, elm, field) do { \
[425] Fix | Delete
if (((elm)->field.tqe_next) != NULL) \
[426] Fix | Delete
(elm)->field.tqe_next->field.tqe_prev = \
[427] Fix | Delete
(elm)->field.tqe_prev; \
[428] Fix | Delete
else \
[429] Fix | Delete
(head)->tqh_last = (elm)->field.tqe_prev; \
[430] Fix | Delete
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
[431] Fix | Delete
} while (/*CONSTCOND*/0)
[432] Fix | Delete
[433] Fix | Delete
#define TAILQ_FOREACH(var, head, field) \
[434] Fix | Delete
for ((var) = ((head)->tqh_first); \
[435] Fix | Delete
(var); \
[436] Fix | Delete
(var) = ((var)->field.tqe_next))
[437] Fix | Delete
[438] Fix | Delete
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
[439] Fix | Delete
for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
[440] Fix | Delete
(var); \
[441] Fix | Delete
(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
[442] Fix | Delete
[443] Fix | Delete
#define TAILQ_CONCAT(head1, head2, field) do { \
[444] Fix | Delete
if (!TAILQ_EMPTY(head2)) { \
[445] Fix | Delete
*(head1)->tqh_last = (head2)->tqh_first; \
[446] Fix | Delete
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
[447] Fix | Delete
(head1)->tqh_last = (head2)->tqh_last; \
[448] Fix | Delete
TAILQ_INIT((head2)); \
[449] Fix | Delete
} \
[450] Fix | Delete
} while (/*CONSTCOND*/0)
[451] Fix | Delete
[452] Fix | Delete
/*
[453] Fix | Delete
* Tail queue access methods.
[454] Fix | Delete
*/
[455] Fix | Delete
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
[456] Fix | Delete
#define TAILQ_FIRST(head) ((head)->tqh_first)
[457] Fix | Delete
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
[458] Fix | Delete
[459] Fix | Delete
#define TAILQ_LAST(head, headname) \
[460] Fix | Delete
(*(((struct headname *)((head)->tqh_last))->tqh_last))
[461] Fix | Delete
#define TAILQ_PREV(elm, headname, field) \
[462] Fix | Delete
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
[463] Fix | Delete
[464] Fix | Delete
[465] Fix | Delete
/*
[466] Fix | Delete
* Circular queue definitions.
[467] Fix | Delete
*/
[468] Fix | Delete
#define CIRCLEQ_HEAD(name, type) \
[469] Fix | Delete
struct name { \
[470] Fix | Delete
struct type *cqh_first; /* first element */ \
[471] Fix | Delete
struct type *cqh_last; /* last element */ \
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
#define CIRCLEQ_HEAD_INITIALIZER(head) \
[475] Fix | Delete
{ (void *)&head, (void *)&head }
[476] Fix | Delete
[477] Fix | Delete
#define CIRCLEQ_ENTRY(type) \
[478] Fix | Delete
struct { \
[479] Fix | Delete
struct type *cqe_next; /* next element */ \
[480] Fix | Delete
struct type *cqe_prev; /* previous element */ \
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
/*
[484] Fix | Delete
* Circular queue functions.
[485] Fix | Delete
*/
[486] Fix | Delete
#define CIRCLEQ_INIT(head) do { \
[487] Fix | Delete
(head)->cqh_first = (void *)(head); \
[488] Fix | Delete
(head)->cqh_last = (void *)(head); \
[489] Fix | Delete
} while (/*CONSTCOND*/0)
[490] Fix | Delete
[491] Fix | Delete
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
[492] Fix | Delete
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
[493] Fix | Delete
(elm)->field.cqe_prev = (listelm); \
[494] Fix | Delete
if ((listelm)->field.cqe_next == (void *)(head)) \
[495] Fix | Delete
(head)->cqh_last = (elm); \
[496] Fix | Delete
else \
[497] Fix | Delete
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
[498] Fix | Delete
(listelm)->field.cqe_next = (elm); \
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function