xdasd_list.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002  * Copyright (c) 2006, Novell, Inc.
00003  * 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 are 
00007  * met:
00008  * 
00009  *     * Redistributions of source code must retain the above copyright 
00010  *       notice, this list of conditions and the following disclaimer.
00011  *     * Redistributions in binary form must reproduce the above copyright 
00012  *       notice, this list of conditions and the following disclaimer in the 
00013  *       documentation and/or other materials provided with the distribution.
00014  *     * Neither the name of the Novell nor the names of its contributors 
00015  *       may be used to endorse or promote products derived from this 
00016  *       software without specific prior written permission.
00017  * 
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00020  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00021  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
00022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
00025  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
00026  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
00027  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *--------------------------------------------------------------------------*/
00030 
00039 #ifndef XDASD_LIST_H_INCLUDED
00040 #define XDASD_LIST_H_INCLUDED
00041 
00049 #define XDL_IS_HEAD(x) ((x)->isHead)
00050 
00053 #define XDL_IS_EMPTY(h)    \
00054    ((((h)->next == (h)) && ((h)->prev == (h)) )? 1: 0)
00055 
00058 #define XDL_INSERT(n,x)    \
00059   {(n)->prev = (x);        \
00060    (n)->next = (x)->next;  \
00061    (x)->next->prev = (n);  \
00062    (x)->next = (n);}
00063 
00066 #define XDL_INSERT_AFTER XDL_INSERT
00067 
00070 #define XDL_INSERT_BEFORE(n,x)\
00071   {(n)->next = (x);           \
00072    (n)->prev = (x)->prev;     \
00073    (x)->prev->next = (n);     \
00074    (x)->prev = (n);}
00075 
00078 #define XDL_INSERT_WORKNODE_LAST(n,x)  \
00079   {gettimeofday(&((n)->timer));        \
00080    (n)->next = (x);                    \
00081    (n)->prev = (x)->prev;              \
00082    (x)->prev->next = (n);              \
00083    (x)->prev = (n);}
00084 
00087 #define XDL_INSERT_WORKNODE_FIRST(n,x) \
00088   {gettimeofday(&((n)->timer));        \
00089    (n)->prev = (x);                    \
00090    (n)->next = (x)->next;              \
00091    (x)->next->prev = (n);              \
00092    (x)->next = (n);}
00093 
00096 #define XDL_UNLINK(x)            \
00097   {(x)->prev->next = (x)->next;  \
00098    (x)->next->prev = (x)->prev;} 
00099 
00102 #define XDL_IS_LAST(h,x)   \
00103    (((x)->prev == (h) && (h)->prev == (x))? 1: 0)
00104 
00107 #define XDL_IS_FIRST(h,x)  \
00108    (((x)->prev == (h) && (h)->next == (x))? 1: 0)
00109 
00112 #define XDL_IS_ONLY(h,x)   \
00113    (((x)->next == (h) && (h)->prev == (x))? 1: 0)
00114 
00117 #define XDL_LINK_HEAD(d,s) \
00118   {(d)->next = (s)->next;  \
00119    (d)->prev = (s)->prev;  \
00120    (s)->next->prev = (d);  \
00121    (s)->prev->next = (d);}
00122 
00125 typedef struct XDLItem_tag
00126 {
00127    struct XDLItem_tag * prev;
00128    struct XDLItem_tag * next;
00129 } XDLItem;
00130 
00133 typedef struct XDList_tag
00134 {
00135    XDLItem * head;
00136    XDLItem * tail;
00137    int count;
00138 } XDList;
00139 
00140 XDLItem * xdasd_list_unlink(XDList * list, XDLItem * item);
00141 XDLItem * xdasd_list_link_head(XDList * list, XDLItem * item);
00142 XDLItem * xdasd_list_link_tail(XDList * list, XDLItem * item);
00143 
00147 #endif   /* XDASD_LIST_H_INCLUDED */
00148 

Generated on Thu Aug 20 22:33:05 2009 for OpenXDAS by  doxygen 1.5.6