Changeset 5e6e50b in mainline for uspace/lib/c/include/adt/list.h


Ignore:
Timestamp:
2011-05-17T09:20:34Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2aaf804
Parents:
a29529b (diff), 3375bd4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Development branch changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/list.h

    ra29529b r5e6e50b  
    4747 *
    4848 * @param name Name of the new statically allocated list.
     49 *
    4950 */
    5051#define LIST_INITIALIZE(name)  link_t name = { \
     
    5859 *
    5960 * @param link Pointer to link_t structure to be initialized.
     61 *
    6062 */
    6163static inline void link_initialize(link_t *link)
     
    7072 *
    7173 * @param head Pointer to link_t structure representing head of the list.
     74 *
    7275 */
    7376static inline void list_initialize(link_t *head)
     
    8386 * @param link Pointer to link_t structure to be added.
    8487 * @param head Pointer to link_t structure representing head of the list.
     88 *
    8589 */
    8690static inline void list_prepend(link_t *link, link_t *head)
     
    98102 * @param link Pointer to link_t structure to be added.
    99103 * @param head Pointer to link_t structure representing head of the list.
     104 *
    100105 */
    101106static inline void list_append(link_t *link, link_t *head)
     
    123128 * Remove item from doubly-linked circular list.
    124129 *
    125  * @param link Pointer to link_t structure to be removed from the list it is contained in.
     130 * @param link Pointer to link_t structure to be removed from the list
     131 *             it is contained in.
     132 *
    126133 */
    127134static inline void list_remove(link_t *link)
     
    137144 *
    138145 * @param head Pointer to link_t structure representing head of the list.
     146 *
    139147 */
    140148static inline int list_empty(link_t *head)
     
    142150        return ((head->next == head) ? 1 : 0);
    143151}
    144 
    145152
    146153/** Split or concatenate headless doubly-linked circular list
     
    151158 * concatenates splitted lists and splits concatenated lists.
    152159 *
    153  * @param part1 Pointer to link_t structure leading the first (half of the headless) list.
    154  * @param part2 Pointer to link_t structure leading the second (half of the headless) list.
     160 * @param part1 Pointer to link_t structure leading the first
     161 *              (half of the headless) list.
     162 * @param part2 Pointer to link_t structure leading the second
     163 *              (half of the headless) list.
     164 *
    155165 */
    156166static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
     
    165175}
    166176
    167 
    168177/** Split headless doubly-linked circular list
    169178 *
    170179 * Split headless doubly-linked circular list.
    171180 *
    172  * @param part1 Pointer to link_t structure leading the first half of the headless list.
    173  * @param part2 Pointer to link_t structure leading the second half of the headless list.
     181 * @param part1 Pointer to link_t structure leading
     182 *              the first half of the headless list.
     183 * @param part2 Pointer to link_t structure leading
     184 *              the second half of the headless list.
     185 *
    174186 */
    175187static inline void headless_list_split(link_t *part1, link_t *part2)
     
    182194 * Concatenate two headless doubly-linked circular lists.
    183195 *
    184  * @param part1 Pointer to link_t structure leading the first headless list.
    185  * @param part2 Pointer to link_t structure leading the second headless list.
     196 * @param part1 Pointer to link_t structure leading
     197 *              the first headless list.
     198 * @param part2 Pointer to link_t structure leading
     199 *              the second headless list.
     200 *
    186201 */
    187202static inline void headless_list_concat(link_t *part1, link_t *part2)
     
    190205}
    191206
    192 #define list_get_instance(link, type, member)  ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
    193 
    194 extern int list_member(const link_t *link, const link_t *head);
    195 extern void list_concat(link_t *head1, link_t *head2);
    196 extern unsigned int list_count(const link_t *link);
     207#define list_get_instance(link, type, member) \
     208        ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
     209
     210#define list_foreach(list, iterator) \
     211        for (link_t *iterator = (list).next; \
     212            iterator != &(list); iterator = iterator->next)
     213
     214extern int list_member(const link_t *, const link_t *);
     215extern void list_concat(link_t *, link_t *);
     216extern unsigned int list_count(const link_t *);
    197217
    198218#endif
Note: See TracChangeset for help on using the changeset viewer.