Changeset 2246de6 in mainline for uspace/lib/libc/include/libadt/list.h
- Timestamp:
- 2009-05-21T06:57:08Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cb41a5e
- Parents:
- 55982d6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/include/libadt/list.h
r55982d6 r2246de6 38 38 #include <unistd.h> 39 39 40 #ifndef true41 # define true 142 #endif43 #ifndef false44 # define false 045 #endif46 47 typedef struct link link_t;48 49 40 /** Doubly linked list head and link type. */ 50 struct link {51 link_t *prev;/**< Pointer to the previous item in the list. */52 link_t *next;/**< Pointer to the next item in the list. */53 } ;41 typedef struct link { 42 struct link *prev; /**< Pointer to the previous item in the list. */ 43 struct link *next; /**< Pointer to the next item in the list. */ 44 } link_t; 54 45 55 46 /** Declare and initialize statically allocated list. … … 57 48 * @param name Name of the new statically allocated list. 58 49 */ 59 #define LIST_INITIALIZE(name) link_t name = { .prev = &name, .next = &name } 50 #define LIST_INITIALIZE(name) link_t name = { \ 51 .prev = &name, \ 52 .next = &name \ 53 } 60 54 61 55 /** Initialize doubly-linked circular list link … … 146 140 static inline int list_empty(link_t *head) 147 141 { 148 return head->next == head ? true : false;142 return ((head->next == head) ? 1 : 0); 149 143 } 150 144 … … 162 156 static inline void headless_list_split_or_concat(link_t *part1, link_t *part2) 163 157 { 164 link_t *hlp;165 166 158 part1->prev->next = part2; 167 part2->prev->next = part1; 168 hlp = part1->prev; 159 part2->prev->next = part1; 160 161 link_t *hlp = part1->prev; 162 169 163 part1->prev = part2->prev; 170 164 part2->prev = hlp; … … 196 190 } 197 191 198 #define list_get_instance(link, type,member) (type *)(((char *)(link))-((char *)&(((type *)NULL)->member)))192 #define list_get_instance(link, type, member) ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member)))) 199 193 200 194 extern int list_member(const link_t *link, const link_t *head); 201 195 extern void list_concat(link_t *head1, link_t *head2); 196 extern unsigned int list_count(const link_t *link); 202 197 203 198 #endif
Note:
See TracChangeset
for help on using the changeset viewer.