u_double_list.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
00017  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 
00018  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
00019  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
00020  * USE OR OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * The above copyright notice and this permission notice (including the
00023  * next paragraph) shall be included in all copies or substantial portions
00024  * of the Software.
00025  * 
00026  **************************************************************************/
00027 
00037 #ifndef _U_DOUBLE_LIST_H_
00038 #define _U_DOUBLE_LIST_H_
00039 
00040 
00041 #include <stddef.h>
00042 
00043 
00044 struct list_head
00045 {
00046     struct list_head *prev;
00047     struct list_head *next;
00048 };
00049 
00050 
00051 #define LIST_INITHEAD(__item)                   \
00052   do {                                          \
00053     (__item)->prev = (__item);                  \
00054     (__item)->next = (__item);                  \
00055   } while (0)
00056 
00057 #define LIST_ADD(__item, __list)                \
00058   do {                                          \
00059     (__item)->prev = (__list);                  \
00060     (__item)->next = (__list)->next;            \
00061     (__list)->next->prev = (__item);            \
00062     (__list)->next = (__item);                  \
00063   } while (0)
00064 
00065 #define LIST_ADDTAIL(__item, __list)            \
00066   do {                                          \
00067     (__item)->next = (__list);                  \
00068     (__item)->prev = (__list)->prev;            \
00069     (__list)->prev->next = (__item);            \
00070     (__list)->prev = (__item);                  \
00071   } while(0)
00072 
00073 #define LIST_REPLACE(__from, __to)              \
00074   do {                                          \
00075     (__to)->prev = (__from)->prev;              \
00076     (__to)->next = (__from)->next;              \
00077     (__from)->next->prev = (__to);              \
00078     (__from)->prev->next = (__to);              \
00079   } while (0)
00080 
00081 #define LIST_DEL(__item)                        \
00082   do {                                          \
00083     (__item)->prev->next = (__item)->next;      \
00084     (__item)->next->prev = (__item)->prev;      \
00085   } while(0)
00086 
00087 #define LIST_DELINIT(__item)                    \
00088   do {                                          \
00089     (__item)->prev->next = (__item)->next;      \
00090     (__item)->next->prev = (__item)->prev;      \
00091     (__item)->next = (__item);                  \
00092     (__item)->prev = (__item);                  \
00093   } while(0)
00094 
00095 #define LIST_ENTRY(__type, __item, __field)   \
00096     ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
00097 
00098 
00099 #endif /*_U_DOUBLE_LIST_H_*/

Generated on Tue Sep 29 06:25:15 2009 for Gallium3D by  doxygen 1.5.4