Changeset 55b77d9 in mainline for kernel/generic/include


Ignore:
Timestamp:
2011-06-17T20:39:16Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f164724
Parents:
98caf49
Message:

Separate list_t typedef from link_t (kernel part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • Replace improper uses of list_prepend() with list_insert_after()
  • Replace improper uses of list_append() with list_insert_before()
Location:
kernel/generic/include
Files:
13 edited

Legend:

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

    r98caf49 r55b77d9  
    8989typedef struct {
    9090        btree_node_t *root;     /**< B-tree root node pointer. */
    91         link_t leaf_head;       /**< Leaf-level list head. */
     91        list_t leaf_list;       /**< List of leaves. */
    9292} btree_t;
    9393
  • kernel/generic/include/adt/hash_table.h

    r98caf49 r55b77d9  
    6868/** Hash table structure. */
    6969typedef struct {
    70         link_t *entry;
     70        list_t *entry;
    7171        size_t entries;
    7272        size_t max_keys;
  • kernel/generic/include/adt/list.h

    r98caf49 r55b77d9  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3940#include <trace.h>
    4041
    41 /** Doubly linked list head and link type. */
     42/** Doubly linked list link. */
    4243typedef struct link {
    4344        struct link *prev;  /**< Pointer to the previous item in the list. */
     
    4546} link_t;
    4647
     48/** Doubly linked list. */
     49typedef struct list {
     50        link_t head;  /**< List head. Does not have any data. */
     51} list_t;
     52
    4753/** Declare and initialize statically allocated list.
    4854 *
     
    5157 */
    5258#define LIST_INITIALIZE(name) \
    53         link_t name = { \
    54                 .prev = &name, \
    55                 .next = &name \
     59        list_t name = { \
     60                .head = { \
     61                        .prev = &(name).head, \
     62                        .next = &(name).head \
     63                } \
    5664        }
    5765
     
    6068
    6169#define list_foreach(list, iterator) \
    62         for (link_t *iterator = (list).next; \
    63             iterator != &(list); iterator = iterator->next)
     70        for (link_t *iterator = (list).head.next; \
     71            iterator != &(list).head; iterator = iterator->next)
    6472
    6573/** Initialize doubly-linked circular list link
     
    8088 * Initialize doubly-linked circular list.
    8189 *
    82  * @param list Pointer to link_t structure representing the list.
    83  *
    84  */
    85 NO_TRACE static inline void list_initialize(link_t *list)
    86 {
    87         list->prev = list;
    88         list->next = list;
     90 * @param list Pointer to list_t structure.
     91 *
     92 */
     93NO_TRACE static inline void list_initialize(list_t *list)
     94{
     95        list->head.prev = &list->head;
     96        list->head.next = &list->head;
     97}
     98
     99/** Insert item before another item in doubly-linked circular list.
     100 *
     101 */
     102static inline void list_insert_before(link_t *lnew, link_t *lold)
     103{
     104        lnew->next = lold;
     105        lnew->prev = lold->prev;
     106        lold->prev->next = lnew;
     107        lold->prev = lnew;
     108}
     109
     110/** Insert item after another item in doubly-linked circular list.
     111 *
     112 */
     113static inline void list_insert_after(link_t *lnew, link_t *lold)
     114{
     115        lnew->prev = lold;
     116        lnew->next = lold->next;
     117        lold->next->prev = lnew;
     118        lold->next = lnew;
    89119}
    90120
     
    94124 *
    95125 * @param link Pointer to link_t structure to be added.
    96  * @param list Pointer to link_t structure representing the list.
    97  *
    98  */
    99 NO_TRACE static inline void list_prepend(link_t *link, link_t *list)
    100 {
    101         link->next = list->next;
    102         link->prev = list;
    103         list->next->prev = link;
    104         list->next = link;
     126 * @param list Pointer to list_t structure.
     127 *
     128 */
     129NO_TRACE static inline void list_prepend(link_t *link, list_t *list)
     130{
     131        list_insert_after(link, &list->head);
    105132}
    106133
     
    110137 *
    111138 * @param link Pointer to link_t structure to be added.
    112  * @param list Pointer to link_t structure representing the list.
    113  *
    114  */
    115 NO_TRACE static inline void list_append(link_t *link, link_t *list)
    116 {
    117         link->prev = list->prev;
    118         link->next = list;
    119         list->prev->next = link;
    120         list->prev = link;
    121 }
    122 
    123 /** Insert item before another item in doubly-linked circular list.
    124  *
    125  */
    126 static inline void list_insert_before(link_t *link, link_t *list)
    127 {
    128         list_append(link, list);
    129 }
    130 
    131 /** Insert item after another item in doubly-linked circular list.
    132  *
    133  */
    134 static inline void list_insert_after(link_t *link, link_t *list)
    135 {
    136         list_prepend(list, link);
     139 * @param list Pointer to list_t structure.
     140 *
     141 */
     142NO_TRACE static inline void list_append(link_t *link, list_t *list)
     143{
     144        list_insert_before(link, &list->head);
    137145}
    138146
     
    156164 * Query emptiness of doubly-linked circular list.
    157165 *
    158  * @param list Pointer to link_t structure representing the list.
    159  *
    160  */
    161 NO_TRACE static inline int list_empty(link_t *list)
    162 {
    163         return (list->next == list);
    164 }
    165 
    166 /** Get head item of a list.
    167  *
    168  * @param list Pointer to link_t structure representing the list.
     166 * @param list Pointer to lins_t structure.
     167 *
     168 */
     169NO_TRACE static inline int list_empty(list_t *list)
     170{
     171        return (list->head.next == &list->head);
     172}
     173
     174/** Get first item in list.
     175 *
     176 * @param list Pointer to list_t structure.
    169177 *
    170178 * @return Head item of the list.
     
    172180 *
    173181 */
    174 static inline link_t *list_head(link_t *list)
    175 {
    176         return ((list->next == list) ? NULL : list->next);
     182static inline link_t *list_first(list_t *list)
     183{
     184        return ((list->head.next == &list->head) ? NULL : list->head.next);
     185}
     186
     187/** Get last item in list.
     188 *
     189 * @param list Pointer to list_t structure.
     190 *
     191 * @return Head item of the list.
     192 * @return NULL if the list is empty.
     193 *
     194 */
     195static inline link_t *list_last(list_t *list)
     196{
     197        return ((list->head.prev == &list->head) ? NULL : list->head.prev);
    177198}
    178199
     
    231252}
    232253
    233 /** Get n-th item of a list.
     254/** Get n-th item in a list.
    234255 *
    235256 * @param list Pointer to link_t structure representing the list.
     
    240261 *
    241262 */
    242 static inline link_t *list_nth(link_t *list, unsigned int n)
     263static inline link_t *list_nth(list_t *list, unsigned int n)
    243264{
    244265        unsigned int cnt = 0;
     
    254275}
    255276
    256 extern int list_member(const link_t *, const link_t *);
    257 extern void list_concat(link_t *, link_t *);
    258 extern unsigned int list_count(const link_t *);
     277extern int list_member(const link_t *, const list_t *);
     278extern void list_concat(list_t *, list_t *);
     279extern unsigned int list_count(const list_t *);
    259280
    260281#endif
  • kernel/generic/include/console/chardev.h

    r98caf49 r55b77d9  
    8888        /** Fields suitable for multiplexing. */
    8989        link_t link;
    90         link_t list;
     90        list_t list;
    9191       
    9292        /** Implementation of outdev operations. */
  • kernel/generic/include/console/kconsole.h

    r98caf49 r55b77d9  
    9191
    9292SPINLOCK_EXTERN(cmd_lock);
    93 extern link_t cmd_head;
     93extern list_t cmd_list;
    9494
    9595extern void kconsole_init(void);
  • kernel/generic/include/cpu.h

    r98caf49 r55b77d9  
    5959       
    6060        IRQ_SPINLOCK_DECLARE(timeoutlock);
    61         link_t timeout_active_head;
     61        list_t timeout_active_list;
    6262       
    6363        /**
  • kernel/generic/include/ipc/ipc.h

    r98caf49 r55b77d9  
    166166       
    167167        /** Phones connected to this answerbox. */
    168         link_t connected_phones;
     168        list_t connected_phones;
    169169        /** Received calls. */
    170         link_t calls;
    171         link_t dispatched_calls;  /* Should be hash table in the future */
     170        list_t calls;
     171        list_t dispatched_calls;  /* Should be hash table in the future */
    172172       
    173173        /** Answered calls. */
    174         link_t answers;
     174        list_t answers;
    175175       
    176176        IRQ_SPINLOCK_DECLARE(irq_lock);
    177177       
    178178        /** Notifications from IRQ handlers. */
    179         link_t irq_notifs;
     179        list_t irq_notifs;
    180180        /** IRQs with notifications to this answerbox. */
    181         link_t irq_head;
     181        list_t irq_list;
    182182} answerbox_t;
    183183
     
    243243extern void ipc_backsend_err(phone_t *, call_t *, sysarg_t);
    244244extern void ipc_answerbox_slam_phones(answerbox_t *, bool);
    245 extern void ipc_cleanup_call_list(link_t *);
     245extern void ipc_cleanup_call_list(list_t *);
    246246
    247247extern void ipc_print_task(task_id_t);
  • kernel/generic/include/mm/as.h

    r98caf49 r55b77d9  
    254254
    255255extern as_operations_t *as_operations;
    256 extern link_t inactive_as_with_asid_head;
     256extern list_t inactive_as_with_asid_list;
    257257
    258258extern void as_init(void);
  • kernel/generic/include/mm/buddy.h

    r98caf49 r55b77d9  
    7272        /** Maximal order of block which can be stored by buddy system. */
    7373        uint8_t max_order;
    74         link_t *order;
     74        list_t *order;
    7575        buddy_system_operations_t *op;
    7676        /** Pointer to be used by the implementation. */
  • kernel/generic/include/mm/slab.h

    r98caf49 r55b77d9  
    111111       
    112112        /* Slabs */
    113         link_t full_slabs;     /**< List of full slabs */
    114         link_t partial_slabs;  /**< List of partial slabs */
     113        list_t full_slabs;     /**< List of full slabs */
     114        list_t partial_slabs;  /**< List of partial slabs */
    115115        SPINLOCK_DECLARE(slablock);
    116116        /* Magazines */
    117         link_t magazines;  /**< List o full magazines */
     117        list_t magazines;  /**< List o full magazines */
    118118        SPINLOCK_DECLARE(maglock);
    119119       
  • kernel/generic/include/proc/scheduler.h

    r98caf49 r55b77d9  
    4848typedef struct {
    4949        IRQ_SPINLOCK_DECLARE(lock);
    50         link_t rq_head;              /**< List of ready threads. */
    51         size_t n;                    /**< Number of threads in rq_ready. */
     50        list_t rq;                      /**< List of ready threads. */
     51        size_t n;                       /**< Number of threads in rq_ready. */
    5252} runq_t;
    5353
  • kernel/generic/include/proc/task.h

    r98caf49 r55b77d9  
    7373        char name[TASK_NAME_BUFLEN];
    7474        /** List of threads contained in this task. */
    75         link_t th_head;
     75        list_t threads;
    7676        /** Address space. */
    7777        as_t *as;
     
    9494        stats_ipc_t ipc_info;   /**< IPC statistics */
    9595        /** List of synchronous answerboxes. */
    96         link_t sync_box_head;
     96        list_t sync_boxes;
    9797       
    9898#ifdef CONFIG_UDEBUG
  • kernel/generic/include/synch/waitq.h

    r98caf49 r55b77d9  
    6363       
    6464        /** List of sleeping threads for which there was no missed_wakeup. */
    65         link_t head;
     65        list_t sleepers;
    6666} waitq_t;
    6767
Note: See TracChangeset for help on using the changeset viewer.