[kernel] explicitely enable bootmem on 2.6.35 - required by crashlog (#7695)
[openwrt.git] / target / linux / s3c24xx / files-2.6.30 / drivers / ar6000 / include / dl_list.h
1 /*
2 *
3 * Double-link list definitions (adapted from Atheros SDIO stack)
4 *
5 * Copyright (c) 2007 Atheros Communications Inc.
6 * All rights reserved.
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation;
12 *
13 * Software distributed under the License is distributed on an "AS
14 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15 * implied. See the License for the specific language governing
16 * rights and limitations under the License.
17 *
18 *
19 *
20 */
21 #ifndef __DL_LIST_H___
22 #define __DL_LIST_H___
23
24 #define A_CONTAINING_STRUCT(address, struct_type, field_name)\
25 ((struct_type *)((A_UINT32)(address) - (A_UINT32)(&((struct_type *)0)->field_name)))
26
27 /* list functions */
28 /* pointers for the list */
29 typedef struct _DL_LIST {
30 struct _DL_LIST *pPrev;
31 struct _DL_LIST *pNext;
32 }DL_LIST, *PDL_LIST;
33 /*
34 * DL_LIST_INIT , initialize doubly linked list
35 */
36 #define DL_LIST_INIT(pList)\
37 {(pList)->pPrev = pList; (pList)->pNext = pList;}
38
39 #define DL_LIST_IS_EMPTY(pList) (((pList)->pPrev == (pList)) && ((pList)->pNext == (pList)))
40 #define DL_LIST_GET_ITEM_AT_HEAD(pList) (pList)->pNext
41 #define DL_LIST_GET_ITEM_AT_TAIL(pList) (pList)->pPrev
42 /*
43 * ITERATE_OVER_LIST pStart is the list, pTemp is a temp list member
44 * NOT: do not use this function if the items in the list are deleted inside the
45 * iteration loop
46 */
47 #define ITERATE_OVER_LIST(pStart, pTemp) \
48 for((pTemp) =(pStart)->pNext; pTemp != (pStart); (pTemp) = (pTemp)->pNext)
49
50
51 /* safe iterate macro that allows the item to be removed from the list
52 * the iteration continues to the next item in the list
53 */
54 #define ITERATE_OVER_LIST_ALLOW_REMOVE(pStart,pItem,st,offset) \
55 { \
56 PDL_LIST pTemp; \
57 pTemp = (pStart)->pNext; \
58 while (pTemp != (pStart)) { \
59 (pItem) = A_CONTAINING_STRUCT(pTemp,st,offset); \
60 pTemp = pTemp->pNext; \
61
62 #define ITERATE_END }}
63
64 /*
65 * DL_ListInsertTail - insert pAdd to the end of the list
66 */
67 static INLINE PDL_LIST DL_ListInsertTail(PDL_LIST pList, PDL_LIST pAdd) {
68 /* insert at tail */
69 pAdd->pPrev = pList->pPrev;
70 pAdd->pNext = pList;
71 pList->pPrev->pNext = pAdd;
72 pList->pPrev = pAdd;
73 return pAdd;
74 }
75
76 /*
77 * DL_ListInsertHead - insert pAdd into the head of the list
78 */
79 static INLINE PDL_LIST DL_ListInsertHead(PDL_LIST pList, PDL_LIST pAdd) {
80 /* insert at head */
81 pAdd->pPrev = pList;
82 pAdd->pNext = pList->pNext;
83 pList->pNext->pPrev = pAdd;
84 pList->pNext = pAdd;
85 return pAdd;
86 }
87
88 #define DL_ListAdd(pList,pItem) DL_ListInsertHead((pList),(pItem))
89 /*
90 * DL_ListRemove - remove pDel from list
91 */
92 static INLINE PDL_LIST DL_ListRemove(PDL_LIST pDel) {
93 pDel->pNext->pPrev = pDel->pPrev;
94 pDel->pPrev->pNext = pDel->pNext;
95 /* point back to itself just to be safe, incase remove is called again */
96 pDel->pNext = pDel;
97 pDel->pPrev = pDel;
98 return pDel;
99 }
100
101 /*
102 * DL_ListRemoveItemFromHead - get a list item from the head
103 */
104 static INLINE PDL_LIST DL_ListRemoveItemFromHead(PDL_LIST pList) {
105 PDL_LIST pItem = NULL;
106 if (pList->pNext != pList) {
107 pItem = pList->pNext;
108 /* remove the first item from head */
109 DL_ListRemove(pItem);
110 }
111 return pItem;
112 }
113
114 #endif /* __DL_LIST_H___ */
This page took 0.054358 seconds and 5 git commands to generate.