Changeset 7856d09 in mainline
- Timestamp:
- 2013-11-12T09:16:04Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2764497, a0ff947
- Parents:
- 34cb6c8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/list.h
r34cb6c8 r7856d09 37 37 #define KERN_LIST_H_ 38 38 39 #include <debug.h> 39 40 #include <typedefs.h> 40 41 #include <trace.h> … … 73 74 _link != &(list).head; _link = _link->next) 74 75 76 #define list_foreach_rev(list, member, itype, iterator) \ 77 for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \ 78 for (link_t *_link = (list).head.prev; \ 79 iterator = list_get_instance(_link, itype, member), \ 80 _link != &(list).head; _link = _link->prev) 81 75 82 #define assert_link_not_used(link) \ 76 ASSERT( ((link)->prev == NULL) && ((link)->next == NULL))83 ASSERT(!link_used(link)) 77 84 78 85 /** Initialize doubly-linked circular list link … … 319 326 } 320 327 328 /** Determine if link is used. 329 * 330 * @param link Link 331 * @return @c true if link is used, @c false if not. 332 */ 333 static inline bool link_used(link_t *link) 334 { 335 if (link->prev == NULL && link->next == NULL) 336 return false; 337 338 ASSERT(link->prev != NULL && link->next != NULL); 339 return true; 340 } 341 321 342 extern int list_member(const link_t *, const list_t *); 322 343 extern void list_concat(list_t *, list_t *); -
uspace/lib/c/include/adt/list.h
r34cb6c8 r7856d09 38 38 39 39 #include <assert.h> 40 #include <stdbool.h> 40 41 #include <unistd.h> 41 42 … … 72 73 iterator = list_get_instance(_link, itype, member), \ 73 74 _link != &(list).head; _link = _link->next) 75 76 #define list_foreach_rev(list, member, itype, iterator) \ 77 for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \ 78 for (link_t *_link = (list).head.prev; \ 79 iterator = list_get_instance(_link, itype, member), \ 80 _link != &(list).head; _link = _link->prev) 74 81 75 82 /** Unlike list_foreach(), allows removing items while traversing a list. … … 105 112 106 113 #define assert_link_not_used(link) \ 107 assert( ((link)->prev == NULL) && ((link)->next == NULL))114 assert(!link_used(link)) 108 115 109 116 /** Returns true if the link is definitely part of a list. False if not sure. */ … … 357 364 } 358 365 366 /** Determine if link is used. 367 * 368 * @param link Link 369 * @return @c true if link is used, @c false if not. 370 */ 371 static inline bool link_used(link_t *link) 372 { 373 if (link->prev == NULL && link->next == NULL) 374 return false; 375 376 assert(link->prev != NULL && link->next != NULL); 377 return true; 378 } 379 359 380 extern int list_member(const link_t *, const list_t *); 360 381 extern void list_concat(list_t *, list_t *);
Note:
See TracChangeset
for help on using the changeset viewer.