• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

list.h

00001 /*-
00002  * Copyright (c) 1991, 1993
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  *      @(#)queue.h     8.5 (Berkeley) 8/20/94
00030  * $FreeBSD: /repoman/r/ncvs/src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $
00031  */
00032 
00033 #ifndef _SER_LIST_H
00034 #define _SER_LIST_H
00035 
00036 /* #include <sys/cdefs.h> - not needed and not present on all the systems */
00037 
00038 /*
00039  * This file defines four types of data structures: singly-linked lists,
00040  * singly-linked tail queues, lists and tail queues.
00041  *
00042  * A singly-linked list is headed by a single forward pointer. The elements
00043  * are singly linked for minimum space and pointer manipulation overhead at
00044  * the expense of O(n) removal for arbitrary elements. New elements can be
00045  * added to the list after an existing element or at the head of the list.
00046  * Elements being removed from the head of the list should use the explicit
00047  * macro for this purpose for optimum efficiency. A singly-linked list may
00048  * only be traversed in the forward direction.  Singly-linked lists are ideal
00049  * for applications with large datasets and few or no removals or for
00050  * implementing a LIFO queue.
00051  *
00052  * A singly-linked tail queue is headed by a pair of pointers, one to the
00053  * head of the list and the other to the tail of the list. The elements are
00054  * singly linked for minimum space and pointer manipulation overhead at the
00055  * expense of O(n) removal for arbitrary elements. New elements can be added
00056  * to the list after an existing element, at the head of the list, or at the
00057  * end of the list. Elements being removed from the head of the tail queue
00058  * should use the explicit macro for this purpose for optimum efficiency.
00059  * A singly-linked tail queue may only be traversed in the forward direction.
00060  * Singly-linked tail queues are ideal for applications with large datasets
00061  * and few or no removals or for implementing a FIFO queue.
00062  *
00063  * A list is headed by a single forward pointer (or an array of forward
00064  * pointers for a hash table header). The elements are doubly linked
00065  * so that an arbitrary element can be removed without a need to
00066  * traverse the list. New elements can be added to the list before
00067  * or after an existing element or at the head of the list. A list
00068  * may only be traversed in the forward direction.
00069  *
00070  * A tail queue is headed by a pair of pointers, one to the head of the
00071  * list and the other to the tail of the list. The elements are doubly
00072  * linked so that an arbitrary element can be removed without a need to
00073  * traverse the list. New elements can be added to the list before or
00074  * after an existing element, at the head of the list, or at the end of
00075  * the list. A tail queue may be traversed in either direction.
00076  *
00077  * For details on the use of these macros, see the queue(3) manual page.
00078  *
00079  *
00080  *                              SLIST   LIST    STAILQ  TAILQ
00081  * _HEAD                        +       +       +       +
00082  * _HEAD_INITIALIZER            +       +       +       +
00083  * _ENTRY                       +       +       +       +
00084  * _INIT                        +       +       +       +
00085  * _EMPTY                       +       +       +       +
00086  * _FIRST                       +       +       +       +
00087  * _NEXT                        +       +       +       +
00088  * _PREV                        -       -       -       +
00089  * _LAST                        -       -       +       +
00090  * _FOREACH                     +       +       +       +
00091  * _FOREACH_SAFE                +       +       +       +
00092  * _FOREACH_REVERSE             -       -       -       +
00093  * _FOREACH_REVERSE_SAFE        -       -       -       +
00094  * _INSERT_HEAD                 +       +       +       +
00095  * _INSERT_BEFORE               -       +       -       +
00096  * _INSERT_AFTER                +       +       +       +
00097  * _INSERT_TAIL                 -       -       +       +
00098  * _CONCAT                      -       -       +       +
00099  * _REMOVE_HEAD                 +       -       +       -
00100  * _REMOVE                      +       +       +       +
00101  *
00102  */
00103 #ifdef QUEUE_MACRO_DEBUG
00104 /* Store the last 2 places the queue element or head was altered */
00105 struct qm_trace {
00106         char * lastfile;
00107         int lastline;
00108         char * prevfile;
00109         int prevline;
00110 };
00111 
00112 #define TRACEBUF        struct qm_trace trace;
00113 #define TRASHIT(x)      do {(x) = (void *)-1;} while (0)
00114 
00115 #define QMD_TRACE_HEAD(head) do {                                       \
00116         (head)->trace.prevline = (head)->trace.lastline;                \
00117         (head)->trace.prevfile = (head)->trace.lastfile;                \
00118         (head)->trace.lastline = __LINE__;                              \
00119         (head)->trace.lastfile = __FILE__;                              \
00120 } while (0)
00121 
00122 #define QMD_TRACE_ELEM(elem) do {                                       \
00123         (elem)->trace.prevline = (elem)->trace.lastline;                \
00124         (elem)->trace.prevfile = (elem)->trace.lastfile;                \
00125         (elem)->trace.lastline = __LINE__;                              \
00126         (elem)->trace.lastfile = __FILE__;                              \
00127 } while (0)
00128 
00129 #else
00130 #define QMD_TRACE_ELEM(elem)
00131 #define QMD_TRACE_HEAD(head)
00132 #define TRACEBUF
00133 #define TRASHIT(x)
00134 #endif  /* QUEUE_MACRO_DEBUG */
00135 
00136 /*
00137  * Singly-linked List declarations.
00138  */
00139 #define SLIST_HEAD(name, type)                                          \
00140 struct name {                                                           \
00141         struct type *slh_first; /* first element */                     \
00142 }
00143 
00144 #define SLIST_HEAD_INITIALIZER(head)                                    \
00145         { NULL }
00146 
00147 #define SLIST_ENTRY(type)                                               \
00148 struct {                                                                \
00149         struct type *sle_next;  /* next element */                      \
00150 }
00151 
00152 /*
00153  * Singly-linked List functions.
00154  */
00155 #define SLIST_EMPTY(head)       ((head)->slh_first == NULL)
00156 
00157 #define SLIST_FIRST(head)       ((head)->slh_first)
00158 
00159 #define SLIST_FOREACH(var, head, field)                                 \
00160         for ((var) = SLIST_FIRST((head));                               \
00161             (var);                                                      \
00162             (var) = SLIST_NEXT((var), field))
00163 
00164 #define SLIST_FOREACH_SAFE(var, head, field, tvar)                      \
00165         for ((var) = SLIST_FIRST((head));                               \
00166             (var) && ((tvar) = SLIST_NEXT((var), field), 1);            \
00167             (var) = (tvar))
00168 
00169 #define SLIST_FOREACH_PREVPTR(var, varp, head, field)                   \
00170         for ((varp) = &SLIST_FIRST((head));                             \
00171             ((var) = *(varp)) != NULL;                                  \
00172             (varp) = &SLIST_NEXT((var), field))
00173 
00174 #define SLIST_INIT(head) do {                                           \
00175         SLIST_FIRST((head)) = NULL;                                     \
00176 } while (0)
00177 
00178 #define SLIST_INSERT_AFTER(slistelm, elm, field) do {                   \
00179         SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);       \
00180         SLIST_NEXT((slistelm), field) = (elm);                          \
00181 } while (0)
00182 
00183 #define SLIST_INSERT_HEAD(head, elm, field) do {                        \
00184         SLIST_NEXT((elm), field) = SLIST_FIRST((head));                 \
00185         SLIST_FIRST((head)) = (elm);                                    \
00186 } while (0)
00187 
00188 #define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
00189 
00190 #define SLIST_REMOVE(head, elm, type, field) do {                       \
00191         if (SLIST_FIRST((head)) == (elm)) {                             \
00192                 SLIST_REMOVE_HEAD((head), field);                       \
00193         }                                                               \
00194         else {                                                          \
00195                 struct type *curelm = SLIST_FIRST((head));              \
00196                 while (SLIST_NEXT(curelm, field) != (elm))              \
00197                         curelm = SLIST_NEXT(curelm, field);             \
00198                 SLIST_NEXT(curelm, field) =                             \
00199                     SLIST_NEXT(SLIST_NEXT(curelm, field), field);       \
00200         }                                                               \
00201         TRASHIT((elm)->field.sle_next);                                 \
00202 } while (0)
00203 
00204 #define SLIST_REMOVE_HEAD(head, field) do {                             \
00205         SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
00206 } while (0)
00207 
00208 /*
00209  * Singly-linked Tail queue declarations.
00210  */
00211 #define STAILQ_HEAD(name, type)                                         \
00212 struct name {                                                           \
00213         struct type *stqh_first;/* first element */                     \
00214         struct type **stqh_last;/* addr of last next element */         \
00215 }
00216 
00217 #define STAILQ_HEAD_INITIALIZER(head)                                   \
00218         { NULL, &(head).stqh_first }
00219 
00220 #define STAILQ_ENTRY(type)                                              \
00221 struct {                                                                \
00222         struct type *stqe_next; /* next element */                      \
00223 }
00224 
00225 /*
00226  * Singly-linked Tail queue functions.
00227  */
00228 #define STAILQ_CONCAT(head1, head2) do {                                \
00229         if (!STAILQ_EMPTY((head2))) {                                   \
00230                 *(head1)->stqh_last = (head2)->stqh_first;              \
00231                 (head1)->stqh_last = (head2)->stqh_last;                \
00232                 STAILQ_INIT((head2));                                   \
00233         }                                                               \
00234 } while (0)
00235 
00236 #define STAILQ_EMPTY(head)      ((head)->stqh_first == NULL)
00237 
00238 #define STAILQ_FIRST(head)      ((head)->stqh_first)
00239 
00240 #define STAILQ_FOREACH(var, head, field)                                \
00241         for((var) = STAILQ_FIRST((head));                               \
00242            (var);                                                       \
00243            (var) = STAILQ_NEXT((var), field))
00244 
00245 
00246 #define STAILQ_FOREACH_SAFE(var, head, field, tvar)                     \
00247         for ((var) = STAILQ_FIRST((head));                              \
00248             (var) && ((tvar) = STAILQ_NEXT((var), field), 1);           \
00249             (var) = (tvar))
00250 
00251 #define STAILQ_INIT(head) do {                                          \
00252         STAILQ_FIRST((head)) = NULL;                                    \
00253         (head)->stqh_last = &STAILQ_FIRST((head));                      \
00254 } while (0)
00255 
00256 #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {               \
00257         if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
00258                 (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
00259         STAILQ_NEXT((tqelm), field) = (elm);                            \
00260 } while (0)
00261 
00262 #define STAILQ_INSERT_HEAD(head, elm, field) do {                       \
00263         if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
00264                 (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
00265         STAILQ_FIRST((head)) = (elm);                                   \
00266 } while (0)
00267 
00268 #define STAILQ_INSERT_TAIL(head, elm, field) do {                       \
00269         STAILQ_NEXT((elm), field) = NULL;                               \
00270         *(head)->stqh_last = (elm);                                     \
00271         (head)->stqh_last = &STAILQ_NEXT((elm), field);                 \
00272 } while (0)
00273 
00274 #define STAILQ_LAST(head, type, field)                                  \
00275         (STAILQ_EMPTY((head)) ?                                         \
00276                 NULL :                                                  \
00277                 ((struct type *)(void *)                                \
00278                 ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
00279 
00280 #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
00281 
00282 #define STAILQ_REMOVE(head, elm, type, field) do {                      \
00283         if (STAILQ_FIRST((head)) == (elm)) {                            \
00284                 STAILQ_REMOVE_HEAD((head), field);                      \
00285         }                                                               \
00286         else {                                                          \
00287                 struct type *curelm = STAILQ_FIRST((head));             \
00288                 while (STAILQ_NEXT(curelm, field) != (elm))             \
00289                         curelm = STAILQ_NEXT(curelm, field);            \
00290                 if ((STAILQ_NEXT(curelm, field) =                       \
00291                      STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
00292                         (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
00293         }                                                               \
00294         TRASHIT((elm)->field.stqe_next);                                \
00295 } while (0)
00296 
00297 #define STAILQ_REMOVE_HEAD(head, field) do {                            \
00298         if ((STAILQ_FIRST((head)) =                                     \
00299              STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)         \
00300                 (head)->stqh_last = &STAILQ_FIRST((head));              \
00301 } while (0)
00302 
00303 /*
00304  * List declarations.
00305  */
00306 #define LIST_HEAD(name, type)                                           \
00307 struct name {                                                           \
00308         struct type *lh_first;  /* first element */                     \
00309 }
00310 
00311 #define LIST_HEAD_INITIALIZER(head)                                     \
00312         { NULL }
00313 
00314 #define LIST_ENTRY(type)                                                \
00315 struct {                                                                \
00316         struct type *le_next;   /* next element */                      \
00317         struct type **le_prev;  /* address of previous next element */  \
00318 }
00319 
00320 /*
00321  * List functions.
00322  */
00323 
00324 #define LIST_EMPTY(head)        ((head)->lh_first == NULL)
00325 
00326 #define LIST_FIRST(head)        ((head)->lh_first)
00327 
00328 #define LIST_FOREACH(var, head, field)                                  \
00329         for ((var) = LIST_FIRST((head));                                \
00330             (var);                                                      \
00331             (var) = LIST_NEXT((var), field))
00332 
00333 #define LIST_FOREACH_SAFE(var, head, field, tvar)                       \
00334         for ((var) = LIST_FIRST((head));                                \
00335             (var) && ((tvar) = LIST_NEXT((var), field), 1);             \
00336             (var) = (tvar))
00337 
00338 #define LIST_INIT(head) do {                                            \
00339         LIST_FIRST((head)) = NULL;                                      \
00340 } while (0)
00341 
00342 #define LIST_INSERT_AFTER(listelm, elm, field) do {                     \
00343         QMD_LIST_CHECK_NEXT(listelm, field);                            \
00344         if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
00345                 LIST_NEXT((listelm), field)->field.le_prev =            \
00346                     &LIST_NEXT((elm), field);                           \
00347         LIST_NEXT((listelm), field) = (elm);                            \
00348         (elm)->field.le_prev = &LIST_NEXT((listelm), field);            \
00349 } while (0)
00350 
00351 #define LIST_INSERT_BEFORE(listelm, elm, field) do {                    \
00352         QMD_LIST_CHECK_PREV(listelm, field);                            \
00353         (elm)->field.le_prev = (listelm)->field.le_prev;                \
00354         LIST_NEXT((elm), field) = (listelm);                            \
00355         *(listelm)->field.le_prev = (elm);                              \
00356         (listelm)->field.le_prev = &LIST_NEXT((elm), field);            \
00357 } while (0)
00358 
00359 #define LIST_INSERT_HEAD(head, elm, field) do {                         \
00360         QMD_LIST_CHECK_HEAD((head), field);                             \
00361         if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)     \
00362                 LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
00363         LIST_FIRST((head)) = (elm);                                     \
00364         (elm)->field.le_prev = &LIST_FIRST((head));                     \
00365 } while (0)
00366 
00367 #define LIST_NEXT(elm, field)   ((elm)->field.le_next)
00368 
00369 #define LIST_REMOVE(elm, field) do {                                    \
00370         QMD_LIST_CHECK_NEXT(elm, field);                                \
00371         QMD_LIST_CHECK_PREV(elm, field);                                \
00372         if (LIST_NEXT((elm), field) != NULL)                            \
00373                 LIST_NEXT((elm), field)->field.le_prev =                \
00374                     (elm)->field.le_prev;                               \
00375         *(elm)->field.le_prev = LIST_NEXT((elm), field);                \
00376         TRASHIT((elm)->field.le_next);                                  \
00377         TRASHIT((elm)->field.le_prev);                                  \
00378 } while (0)
00379 
00380 /*
00381  * Tail queue declarations.
00382  */
00383 #define TAILQ_HEAD(name, type)                                          \
00384 struct name {                                                           \
00385         struct type *tqh_first; /* first element */                     \
00386         struct type **tqh_last; /* addr of last next element */         \
00387         TRACEBUF                                                        \
00388 }
00389 
00390 #define TAILQ_HEAD_INITIALIZER(head)                                    \
00391         { NULL, &(head).tqh_first }
00392 
00393 #define TAILQ_ENTRY(type)                                               \
00394 struct {                                                                \
00395         struct type *tqe_next;  /* next element */                      \
00396         struct type **tqe_prev; /* address of previous next element */  \
00397         TRACEBUF                                                        \
00398 }
00399 
00400 /*
00401  * Tail queue functions.
00402  */
00403 
00404 #define TAILQ_CONCAT(head1, head2, field) do {                          \
00405         if (!TAILQ_EMPTY(head2)) {                                      \
00406                 *(head1)->tqh_last = (head2)->tqh_first;                \
00407                 (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
00408                 (head1)->tqh_last = (head2)->tqh_last;                  \
00409                 TAILQ_INIT((head2));                                    \
00410                 QMD_TRACE_HEAD(head1);                                  \
00411                 QMD_TRACE_HEAD(head2);                                  \
00412         }                                                               \
00413 } while (0)
00414 
00415 #define TAILQ_EMPTY(head)       ((head)->tqh_first == NULL)
00416 
00417 #define TAILQ_FIRST(head)       ((head)->tqh_first)
00418 
00419 #define TAILQ_FOREACH(var, head, field)                                 \
00420         for ((var) = TAILQ_FIRST((head));                               \
00421             (var);                                                      \
00422             (var) = TAILQ_NEXT((var), field))
00423 
00424 #define TAILQ_FOREACH_SAFE(var, head, field, tvar)                      \
00425         for ((var) = TAILQ_FIRST((head));                               \
00426             (var) && ((tvar) = TAILQ_NEXT((var), field), 1);            \
00427             (var) = (tvar))
00428 
00429 #define TAILQ_FOREACH_REVERSE(var, head, headname, field)               \
00430         for ((var) = TAILQ_LAST((head), headname);                      \
00431             (var);                                                      \
00432             (var) = TAILQ_PREV((var), headname, field))
00433 
00434 #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)    \
00435         for ((var) = TAILQ_LAST((head), headname);                      \
00436             (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);  \
00437             (var) = (tvar))
00438 
00439 #define TAILQ_INIT(head) do {                                           \
00440         TAILQ_FIRST((head)) = NULL;                                     \
00441         (head)->tqh_last = &TAILQ_FIRST((head));                        \
00442         QMD_TRACE_HEAD(head);                                           \
00443 } while (0)
00444 
00445 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {              \
00446         QMD_TAILQ_CHECK_NEXT(listelm, field);                           \
00447         if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
00448                 TAILQ_NEXT((elm), field)->field.tqe_prev =              \
00449                     &TAILQ_NEXT((elm), field);                          \
00450         else {                                                          \
00451                 (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
00452                 QMD_TRACE_HEAD(head);                                   \
00453         }                                                               \
00454         TAILQ_NEXT((listelm), field) = (elm);                           \
00455         (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);          \
00456         QMD_TRACE_ELEM(&(elm)->field);                                  \
00457         QMD_TRACE_ELEM(&listelm->field);                                \
00458 } while (0)
00459 
00460 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do {                   \
00461         QMD_TAILQ_CHECK_PREV(listelm, field);                           \
00462         (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \
00463         TAILQ_NEXT((elm), field) = (listelm);                           \
00464         *(listelm)->field.tqe_prev = (elm);                             \
00465         (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);          \
00466         QMD_TRACE_ELEM(&(elm)->field);                                  \
00467         QMD_TRACE_ELEM(&listelm->field);                                \
00468 } while (0)
00469 
00470 #define TAILQ_INSERT_HEAD(head, elm, field) do {                        \
00471         QMD_TAILQ_CHECK_HEAD(head, field);                              \
00472         if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
00473                 TAILQ_FIRST((head))->field.tqe_prev =                   \
00474                     &TAILQ_NEXT((elm), field);                          \
00475         else                                                            \
00476                 (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
00477         TAILQ_FIRST((head)) = (elm);                                    \
00478         (elm)->field.tqe_prev = &TAILQ_FIRST((head));                   \
00479         QMD_TRACE_HEAD(head);                                           \
00480         QMD_TRACE_ELEM(&(elm)->field);                                  \
00481 } while (0)
00482 
00483 #define TAILQ_INSERT_TAIL(head, elm, field) do {                        \
00484         QMD_TAILQ_CHECK_TAIL(head, field);                              \
00485         TAILQ_NEXT((elm), field) = NULL;                                \
00486         (elm)->field.tqe_prev = (head)->tqh_last;                       \
00487         *(head)->tqh_last = (elm);                                      \
00488         (head)->tqh_last = &TAILQ_NEXT((elm), field);                   \
00489         QMD_TRACE_HEAD(head);                                           \
00490         QMD_TRACE_ELEM(&(elm)->field);                                  \
00491 } while (0)
00492 
00493 #define TAILQ_LAST(head, headname)                                      \
00494         (*(((struct headname *)((head)->tqh_last))->tqh_last))
00495 
00496 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
00497 
00498 #define TAILQ_PREV(elm, headname, field)                                \
00499         (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
00500 
00501 #define TAILQ_REMOVE(head, elm, field) do {                             \
00502         QMD_TAILQ_CHECK_NEXT(elm, field);                               \
00503         QMD_TAILQ_CHECK_PREV(elm, field);                               \
00504         if ((TAILQ_NEXT((elm), field)) != NULL)                         \
00505                 TAILQ_NEXT((elm), field)->field.tqe_prev =              \
00506                     (elm)->field.tqe_prev;                              \
00507         else {                                                          \
00508                 (head)->tqh_last = (elm)->field.tqe_prev;               \
00509                 QMD_TRACE_HEAD(head);                                   \
00510         }                                                               \
00511         *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);              \
00512         TRASHIT((elm)->field.tqe_next);                                 \
00513         TRASHIT((elm)->field.tqe_prev);                                 \
00514         QMD_TRACE_ELEM(&(elm)->field);                                  \
00515 } while (0)
00516 
00517 #endif /* !_LIST_H */

Generated on Tue May 22 2012 13:10:10 for SIP Router by  doxygen 1.7.1