Changeset c14762e in mainline


Ignore:
Timestamp:
2012-07-12T16:43:38Z (12 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e8471b9
Parents:
2e16033
Message:

adt: Removed duplicate implementations of list_concat().

Location:
kernel/generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/adt/list.h

    r2e16033 rc14762e  
    5151} list_t;
    5252
     53
     54extern int list_member(const link_t *, const list_t *);
     55extern void list_splice(list_t *, link_t *);
     56extern unsigned int list_count(const list_t *);
     57
     58
    5359/** Declare and initialize statically allocated list.
    5460 *
     
    301307}
    302308
    303 /** Moves items of one list into another after the specified item.
    304  *
    305  * Inserts all items of @a list after item at @a pos in another list.
    306  * Both lists may be empty.
    307  *
    308  * @param list Source list to move after pos.
    309  * @param pos Source items will be placed after this item.
    310  */
    311 NO_TRACE static inline void list_splice(list_t *list, link_t *pos)
    312 {
    313         link_t *pos_next = pos->next;
    314        
    315         if (!list_empty(list)) {
    316                 link_t *first = list->head.next;
    317                 link_t *last = list->head.prev;
    318 
    319                 pos->next = first;
    320                 first->prev = pos;
    321 
    322                 last->next = pos_next;
    323                 pos_next->prev = last;
    324                
    325                 list_initialize(list);
    326         }
    327 }
    328 
    329 /** Moves all items of list @a src to the end of list @a dest.
    330  *
    331  * Both lists may be empty.
    332  *
    333  * @param src Source list to move. Becomes empty.
    334  * @param dest Items of src will be inserted at the end of this list, ie
    335  *             after all items of src.
    336  */
    337 NO_TRACE static inline void list_append_list(list_t *src, list_t *dest)
    338 {
    339         list_splice(src, dest->head.prev);
    340 }
    341 
    342 /** Moves all items of list @a src to the beginning of list @a dest.
    343  *
    344  * Both lists may be empty.
    345  *
    346  * @param src Source list to move. Becomes empty.
    347  * @param dest Items of src will be inserted at the beginning of this list.
    348  */
    349 NO_TRACE static inline void list_prepend_list(list_t *src, list_t *dest)
    350 {
    351         list_splice(src, &dest->head);
     309/** Concatenate two lists
     310 *
     311 * Concatenate lists @a list1 and @a list2, producing a single
     312 * list @a list1 containing items from both (in @a list1, @a list2
     313 * order) and empty list @a list2.
     314 *
     315 * @param list1         First list and concatenated output
     316 * @param list2         Second list and empty output.
     317 *
     318 */
     319NO_TRACE static inline void list_concat(list_t *list1, list_t *list2)
     320{
     321        list_splice(list2, list1->head.prev);
    352322}
    353323
     
    375345}
    376346
    377 extern int list_member(const link_t *, const list_t *);
    378 extern void list_concat(list_t *, list_t *);
    379 extern unsigned int list_count(const list_t *);
    380 
    381347#endif
    382348
  • kernel/generic/src/adt/list.c

    r2e16033 rc14762e  
    6868}
    6969
    70 /** Concatenate two lists
    71  *
    72  * Concatenate lists @a list1 and @a list2, producing a single
    73  * list @a list1 containing items from both (in @a list1, @a list2
    74  * order) and empty list @a list2.
    75  *
    76  * @param list1         First list and concatenated output
    77  * @param list2         Second list and empty output.
    78  *
     70/** Moves items of one list into another after the specified item.
     71 *
     72 * Inserts all items of @a list after item at @a pos in another list.
     73 * Both lists may be empty.
     74 *
     75 * @param list Source list to move after pos. Empty afterwards.
     76 * @param pos Source items will be placed after this item.
    7977 */
    80 void list_concat(list_t *list1, list_t *list2)
     78void list_splice(list_t *list, link_t *pos)
    8179{
    82         if (list_empty(list2))
     80        if (list_empty(list))
    8381                return;
    84 
    85         list2->head.next->prev = list1->head.prev;
    86         list2->head.prev->next = &list1->head;
    87         list1->head.prev->next = list2->head.next;
    88         list1->head.prev = list2->head.prev;
    89         list_initialize(list2);
     82       
     83        /* Attach list to destination. */
     84        list->head.next->prev = pos;
     85        list->head.prev->next = pos->next;
     86       
     87        /* Link destination list to the added list. */
     88        pos->next->prev = list->head.prev;
     89        pos->next = list->head.next;
     90       
     91        list_initialize(list);
    9092}
    9193
  • kernel/generic/src/smp/smp_call.c

    r2e16033 rc14762e  
    191191       
    192192        spinlock_lock(&CPU->smp_calls_lock);
    193         list_splice(&CPU->smp_pending_calls, &calls_list.head);
     193        list_concat(&calls_list, &CPU->smp_pending_calls);
    194194        spinlock_unlock(&CPU->smp_calls_lock);
    195195
  • kernel/generic/src/synch/rcu.c

    r2e16033 rc14762e  
    932932         * cur_preempted is empty, but see comment in record_qs().
    933933         */
    934         list_append_list(&rcu.next_preempted, &rcu.cur_preempted);
     934        list_concat(&rcu.cur_preempted, &rcu.next_preempted);
    935935       
    936936        irq_spinlock_unlock(&rcu.preempt_lock, true);
Note: See TracChangeset for help on using the changeset viewer.