Changeset bc56f30 in mainline for uspace/lib/c/include/adt/list.h
- Timestamp:
- 2019-05-27T12:38:26Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0d14c25
- Parents:
- 4d51c60
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-13 16:06:49)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-05-27 12:38:26)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/list.h
r4d51c60 rbc56f30 42 42 #include <stdint.h> 43 43 #include <trace.h> 44 45 /** Doubly linked list link. */ 46 typedef struct link { 47 struct link *prev; /**< Pointer to the previous item in the list. */ 48 struct link *next; /**< Pointer to the next item in the list. */ 49 } link_t; 50 51 /** Doubly linked list. */ 52 typedef struct list { 53 link_t head; /**< List head. Does not have any data. */ 54 } list_t; 55 56 extern bool list_member(const link_t *, const list_t *); 57 extern void list_splice(list_t *, link_t *); 58 extern unsigned long list_count(const list_t *); 44 #include <_bits/decls.h> 45 46 #ifndef __cplusplus 47 48 /** 49 * We don't define the macros in C++ to avoid polluting headers with 50 * namespaceless names. We don't actually need them, so this is fine. 51 * We still allow including the rest of the file (in `helenos` namespace) 52 * so that we can expose publicly visible types that have list_t members. 53 */ 59 54 60 55 /** Declare and initialize statically allocated list. … … 138 133 assert(!link_used(link)) 139 134 135 #define list_pop(list, type, member) \ 136 ((type *) list_pop_internal(list, \ 137 (list_link_to_void(&(((type *) NULL)->member)) - NULL))) 138 139 #endif /* !__cplusplus */ 140 141 __HELENOS_DECLS_BEGIN; 142 143 /** Doubly linked list link. */ 144 typedef struct __adt_list_link { 145 struct __adt_list_link *prev; /**< Pointer to the previous item in the list. */ 146 struct __adt_list_link *next; /**< Pointer to the next item in the list. */ 147 } link_t; 148 149 /** Doubly linked list. */ 150 typedef struct { 151 link_t head; /**< List head. Does not have any data. */ 152 } list_t; 153 154 extern bool list_member(const link_t *, const list_t *); 155 extern void list_splice(list_t *, link_t *); 156 extern unsigned long list_count(const list_t *); 157 140 158 /** Returns true if the link is definitely part of a list. False if not sure. */ 141 159 static inline bool link_in_use(const link_t *link) … … 425 443 } 426 444 427 #define list_pop(list, type, member) \ 428 ((type *) list_pop_internal(list, \ 429 (list_link_to_void(&(((type *) NULL)->member)) - NULL))) 445 __HELENOS_DECLS_END; 430 446 431 447 #endif
Note:
See TracChangeset
for help on using the changeset viewer.