Changeset feeac0d in mainline for kernel/generic/include/adt/list.h
- Timestamp:
- 2013-09-10T16:32:35Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4982d87
- Parents:
- e8d6ce2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/list.h
re8d6ce2 rfeeac0d 67 67 ((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member)))) 68 68 69 #define list_foreach(list, iterator) \ 70 for (link_t *iterator = (list).head.next; \ 71 iterator != &(list).head; iterator = iterator->next) 69 #define list_foreach(list, member, itype, iterator) \ 70 for (itype *iterator = NULL; iterator == NULL; iterator =(itype *)1) \ 71 for (link_t *_link = (list).head.next; \ 72 iterator = list_get_instance(_link, itype, member), \ 73 _link != &(list).head; _link = _link->next) 72 74 73 75 #define assert_link_not_used(link) \ … … 184 186 * @return Head item of the list. 185 187 * @return NULL if the list is empty. 186 *187 188 */ 188 189 static inline link_t *list_first(const list_t *list) … … 197 198 * @return Head item of the list. 198 199 * @return NULL if the list is empty. 199 *200 200 */ 201 201 static inline link_t *list_last(list_t *list) 202 202 { 203 203 return ((list->head.prev == &list->head) ? NULL : list->head.prev); 204 } 205 206 /** Get next item in list. 207 * 208 * @param link Current item link 209 * @param list List containing @a link 210 * 211 * @return Next item or NULL if @a link is the last item. 212 */ 213 static inline link_t *list_next(link_t *link, const list_t *list) 214 { 215 return (link->next == &list->head) ? NULL : link->next; 216 } 217 218 /** Get previous item in list. 219 * 220 * @param link Current item link 221 * @param list List containing @a link 222 * 223 * @return Previous item or NULL if @a link is the first item. 224 */ 225 static inline link_t *list_prev(link_t *link, const list_t *list) 226 { 227 return (link->prev == &list->head) ? NULL : link->prev; 204 228 } 205 229 … … 270 294 { 271 295 unsigned int cnt = 0; 272 273 list_foreach(*list, link) { 296 link_t *link; 297 298 link = list_first(list); 299 while (link != NULL) { 274 300 if (cnt == n) 275 301 return link; 276 302 277 303 cnt++; 304 link = list_next(link, list); 278 305 } 279 306
Note:
See TracChangeset
for help on using the changeset viewer.