7 #ifndef UBICLIB_EDLIST_H_
8 #define UBICLIB_EDLIST_H_
23 #include <ubinos_config.h>
72 #define edlist_init(edlist) \
74 (edlist)->count = 0; \
75 (edlist)->head = NULL; \
76 (edlist)->tail = NULL; \
77 (edlist)->cur = NULL; \
78 (edlist)->data = NULL; \
86 #define edlist_link_init(link) \
88 (link)->prev = NULL; \
89 (link)->next = NULL; \
90 (link)->list = NULL; \
107 #define edlist_insertprev(elmttype, linkname, edlist, ref, elmt) \
109 (elmt)->linkname.next = ((elmttype) ref); \
111 if (NULL == ((elmttype) ref)) { \
112 (elmt)->linkname.prev = (edlist)->tail; \
113 (edlist)->tail = (elmt); \
116 (elmt)->linkname.prev = ((elmttype) ref)->linkname.prev; \
117 ((elmttype) ref)->linkname.prev = (elmt); \
120 if (NULL == (elmt)->linkname.prev) { \
121 (edlist)->head = (elmt); \
124 (elmt)->linkname.prev->linkname.next = (elmt); \
129 (elmt)->linkname.list = (edlist); \
146 #define edlist_insertnext(elmttype, linkname, edlist, ref, elmt) \
148 (elmt)->linkname.prev = ((elmttype) ref); \
150 if (NULL == ((elmttype) ref)) { \
151 (elmt)->linkname.next = (edlist)->head; \
152 (edlist)->head = (elmt); \
155 (elmt)->linkname.next = ((elmttype) ref)->linkname.next; \
156 ((elmttype) ref)->linkname.next = (elmt); \
159 if (NULL == (elmt)->linkname.next) { \
160 (edlist)->tail = (elmt); \
163 (elmt)->linkname.next->linkname.prev = (elmt); \
168 (elmt)->linkname.list = (edlist); \
180 #define edlist_remove(elmttype, linkname, elmt) \
182 if (NULL != ((elmt)->linkname.list)) { \
183 if ((elmt) == ((elmt)->linkname.list)->cur) { \
184 ((elmt)->linkname.list)->cur = (elmt)->linkname.prev; \
187 if (NULL == (elmt)->linkname.prev) { \
188 ((elmt)->linkname.list)->head = (elmt)->linkname.next; \
191 (elmt)->linkname.prev->linkname.next = (elmt)->linkname.next; \
194 if (NULL == (elmt)->linkname.next) { \
195 ((elmt)->linkname.list)->tail = (elmt)->linkname.prev; \
198 (elmt)->linkname.next->linkname.prev = (elmt)->linkname.prev; \
201 ((elmt)->linkname.list)->count--; \
203 (elmt)->linkname.prev = NULL; \
204 (elmt)->linkname.next = NULL; \
205 (elmt)->linkname.list = NULL; \
237 #define edlist_setcur(elmttype, linkname, edlist, cur) ((elmttype) _edlist_setcur(edlist, cur))
263 #define edlist_getcur(elmttype, linkname, edlist) ((elmttype) _edlist_getcur(edlist))
279 #define edlist_getcurnext(elmttype, linkname, edlist) \
281 ((NULL == (edlist)->cur || NULL == ((elmttype) (edlist)->cur)->linkname.next) ? \
282 _edlist_setcur((edlist), (edlist)->head) : \
283 _edlist_setcur((edlist), ((elmttype) (edlist)->cur)->linkname.next) ) )
294 #define edlist_head(elmttype, linkname, edlist) ((elmttype) (edlist)->head)
305 #define edlist_tail(elmttype, linkname, edlist) ((elmttype) (edlist)->tail)
316 #define edlist_next(elmttype, linkname, elmt) ((elmt)->linkname.next)
327 #define edlist_prev(elmttype, linkname, elmt) ((elmt)->linkname.prev)
338 #define edlist_list(elmttype, linkname, elmt) ((elmt)->linkname.list)
struct _edlist_t edlist_t
void * _edlist_getcur(edlist_pt edlist)
void * _edlist_setcur(edlist_pt edlist, void *cur)
struct _edlist_elmt_t edlist_elmt_t
edlist_t * edlist_pt
Definition: edlist.h:43
edlist_elmt_t * edlist_elmt_pt
Definition: edlist.h:65
struct _edlist_elmt_t::@0 link
void * data
Definition: edlist.h:55
void * tail
Definition: edlist.h:31
void * cur
Definition: edlist.h:32
void * head
Definition: edlist.h:30
void * data
Definition: edlist.h:33
unsigned int count
Definition: edlist.h:29