Changeset 36795edf in mainline for kernel/generic/include/adt/list.h
- Timestamp:
- 2021-03-12T19:16:51Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a85d5c6
- Parents:
- 17fac946
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/list.h
r17fac946 r36795edf 38 38 39 39 #include <assert.h> 40 #include <macros.h> 41 #include <member.h> 40 42 #include <stdbool.h> 41 43 #include <stddef.h> 44 #include <stdint.h> 42 45 #include <trace.h> 43 46 … … 89 92 90 93 #define list_get_instance(link, type, member) \ 91 ((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member))))94 member_to_inst(link, type, member) 92 95 93 96 #define list_foreach(list, member, itype, iterator) \ 94 for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \97 for (itype *iterator = NULL; iterator == NULL; iterator = &((itype *) NULL)[1]) \ 95 98 for (link_t *_link = (list).head.next; \ 96 99 iterator = list_get_instance(_link, itype, member), \ … … 98 101 99 102 #define list_foreach_rev(list, member, itype, iterator) \ 100 for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \103 for (itype *iterator = NULL; iterator == NULL; iterator = &((itype *) NULL)[1]) \ 101 104 for (link_t *_link = (list).head.prev; \ 102 105 iterator = list_get_instance(_link, itype, member), \ … … 375 378 * 376 379 */ 377 static inline link_t *list_nth(const list_t *list, unsigned longn)378 { 379 unsigned longcnt = 0;380 static inline link_t *list_nth(const list_t *list, size_t n) 381 { 382 size_t cnt = 0; 380 383 381 384 link_t *link = list_first(list); … … 391 394 } 392 395 393 /** Verify that argument type is a pointer to link_t (at compile time).394 *395 * This can be used to check argument type in a macro.396 */397 static inline const void *list_link_to_void(const link_t *link)398 {399 return link;400 }401 402 396 /** Determine if link is used. 403 397 *
Note:
See TracChangeset
for help on using the changeset viewer.