Go to the documentation of this file.
30 #ifndef UBICLIB_EDLIST_H_
31 #define UBICLIB_EDLIST_H_
46 #include <ubinos_config.h>
95 #define edlist_init(edlist) \
97 (edlist)->count = 0; \
98 (edlist)->head = NULL; \
99 (edlist)->tail = NULL; \
100 (edlist)->cur = NULL; \
101 (edlist)->data = NULL; \
109 #define edlist_link_init(link) \
111 (link)->prev = NULL; \
112 (link)->next = NULL; \
113 (link)->list = NULL; \
130 #define edlist_insertprev(elmttype, linkname, edlist, ref, elmt) \
132 (elmt)->linkname.next = ((elmttype) ref); \
134 if (NULL == ((elmttype) ref)) { \
135 (elmt)->linkname.prev = (edlist)->tail; \
136 (edlist)->tail = (elmt); \
139 (elmt)->linkname.prev = ((elmttype) ref)->linkname.prev; \
140 ((elmttype) ref)->linkname.prev = (elmt); \
143 if (NULL == (elmt)->linkname.prev) { \
144 (edlist)->head = (elmt); \
147 (elmt)->linkname.prev->linkname.next = (elmt); \
152 (elmt)->linkname.list = (edlist); \
169 #define edlist_insertnext(elmttype, linkname, edlist, ref, elmt) \
171 (elmt)->linkname.prev = ((elmttype) ref); \
173 if (NULL == ((elmttype) ref)) { \
174 (elmt)->linkname.next = (edlist)->head; \
175 (edlist)->head = (elmt); \
178 (elmt)->linkname.next = ((elmttype) ref)->linkname.next; \
179 ((elmttype) ref)->linkname.next = (elmt); \
182 if (NULL == (elmt)->linkname.next) { \
183 (edlist)->tail = (elmt); \
186 (elmt)->linkname.next->linkname.prev = (elmt); \
191 (elmt)->linkname.list = (edlist); \
203 #define edlist_remove(elmttype, linkname, elmt) \
205 if (NULL != ((elmt)->linkname.list)) { \
206 if ((elmt) == ((elmt)->linkname.list)->cur) { \
207 ((elmt)->linkname.list)->cur = (elmt)->linkname.prev; \
210 if (NULL == (elmt)->linkname.prev) { \
211 ((elmt)->linkname.list)->head = (elmt)->linkname.next; \
214 (elmt)->linkname.prev->linkname.next = (elmt)->linkname.next; \
217 if (NULL == (elmt)->linkname.next) { \
218 ((elmt)->linkname.list)->tail = (elmt)->linkname.prev; \
221 (elmt)->linkname.next->linkname.prev = (elmt)->linkname.prev; \
224 ((elmt)->linkname.list)->count--; \
226 (elmt)->linkname.prev = NULL; \
227 (elmt)->linkname.next = NULL; \
228 (elmt)->linkname.list = NULL; \
260 #define edlist_setcur(elmttype, linkname, edlist, cur) ((elmttype) _edlist_setcur(edlist, cur))
286 #define edlist_getcur(elmttype, linkname, edlist) ((elmttype) _edlist_getcur(edlist))
302 #define edlist_getcurnext(elmttype, linkname, edlist) \
304 ((NULL == (edlist)->cur || NULL == ((elmttype) (edlist)->cur)->linkname.next) ? \
305 _edlist_setcur((edlist), (edlist)->head) : \
306 _edlist_setcur((edlist), ((elmttype) (edlist)->cur)->linkname.next) ) )
317 #define edlist_head(elmttype, linkname, edlist) ((elmttype) (edlist)->head)
328 #define edlist_tail(elmttype, linkname, edlist) ((elmttype) (edlist)->tail)
339 #define edlist_next(elmttype, linkname, elmt) ((elmt)->linkname.next)
350 #define edlist_prev(elmttype, linkname, elmt) ((elmt)->linkname.prev)
361 #define edlist_list(elmttype, linkname, elmt) ((elmt)->linkname.list)
void * tail
Definition: edlist.h:54
unsigned int count
Definition: edlist.h:52
void * head
Definition: edlist.h:53
void * cur
Definition: edlist.h:55
struct _edlist_elmt_t::@0 link
edlist_elmt_t * edlist_elmt_pt
Definition: edlist.h:88
void * _edlist_getcur(edlist_pt edlist)
void * data
Definition: edlist.h:56
edlist_t * edlist_pt
Definition: edlist.h:66
struct _edlist_elmt_t edlist_elmt_t
struct _edlist_t edlist_t
void * _edlist_setcur(edlist_pt edlist, void *cur)
void * data
Definition: edlist.h:78