Renames BSD's LIST_* to BSD_LIST_*
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 4 Feb 2015 16:18:52 +0000 (11:18 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sun, 1 Mar 2015 14:36:01 +0000 (09:36 -0500)
Linux's list.h also has a LIST_HEAD, and Akaros only has one user of the BSD
LIST_.

Incidentally, newer man pages for sys/queue.h (try man queue) don't have SLISTS
or the STAILQs anymore.  It's still in the header, but not part of the manual.
Perhaps they are cutting things out?

kern/arch/riscv/page_alloc.c
kern/arch/x86/page_alloc.c
kern/include/page_alloc.h
kern/include/sys/queue.h
kern/src/page_alloc.c

index d76734d..1adb186 100644 (file)
@@ -38,7 +38,7 @@ void page_alloc_init(struct multiboot_info *mbi)
 
        size_t num_colors = llc_cache->num_colors;
        for (size_t i = 0; i < num_colors; i++)
-               LIST_INIT(&lists[i]);
+               BSD_LIST_INIT(&lists[i]);
        
        uintptr_t first_free_page = ROUNDUP(boot_freemem, PGSIZE);
        uintptr_t first_invalid_page = LA2PPN(boot_freelimit);
@@ -52,7 +52,8 @@ void page_alloc_init(struct multiboot_info *mbi)
        for (uintptr_t page = first_free_page; page < first_invalid_page; page++)
        {
                page_setref(&pages[page], 0);
-               LIST_INSERT_HEAD(&lists[page & (num_colors-1)], &pages[page], pg_link);
+               BSD_LIST_INSERT_HEAD(&lists[page & (num_colors-1)], &pages[page],
+                                    pg_link);
        }
        nr_free_pages = first_invalid_page - first_free_page;
 
index ae17264..eaf1b40 100644 (file)
@@ -28,15 +28,15 @@ static void page_alloc_bootstrap() {
            (page_list_t*)boot_alloc(list_size,PGSIZE);
        colored_page_free_list = SINIT(tmp);
        for (int i = 0; i < llc_cache->num_colors; i++)
-               LIST_INIT(&colored_page_free_list[i]);
+               BSD_LIST_INIT(&colored_page_free_list[i]);
 }
 
 /* Can do whatever here.  For now, our page allocator just works with colors,
  * not NUMA zones or anything. */
 static void track_free_page(struct page *page)
 {
-       LIST_INSERT_HEAD(&colored_page_free_list[get_page_color(page2ppn(page),
-                                                               llc_cache)],
+       BSD_LIST_INSERT_HEAD(&colored_page_free_list[get_page_color(page2ppn(page),
+                                                                   llc_cache)],
                         page, pg_link);
        nr_free_pages++;
        /* Page was previous marked as busy, need to set it free explicitly */
index 0914562..ccaaa59 100644 (file)
@@ -24,8 +24,8 @@ struct page_map;              /* preprocessor games */
 struct page;
 typedef size_t ppn_t;
 typedef struct page page_t;
-typedef LIST_HEAD(PageList, page) page_list_t;
-typedef LIST_ENTRY(page) page_list_entry_t;
+typedef BSD_LIST_HEAD(PageList, page) page_list_t;
+typedef BSD_LIST_ENTRY(page) page_list_entry_t;
 
 /* Per-page flag bits related to their state in the page cache */
 #define PG_LOCKED              0x001   /* involved in an IO op */
@@ -41,7 +41,7 @@ typedef LIST_ENTRY(page) page_list_entry_t;
  * an issue, we can dynamically allocate some of these things when we're a
  * buffer page (in a page mapping) */
 struct page {
-       LIST_ENTRY(page)                        pg_link;        /* membership in various lists */
+       BSD_LIST_ENTRY(page)            pg_link;        /* membership in various lists */
        struct kref                                     pg_kref;
        atomic_t                                        pg_flags;
        struct page_map                         *pg_mapping; /* for debugging... */
index b602f9d..c14f014 100644 (file)
@@ -333,15 +333,15 @@ struct {                                                          \
 /*
  * List declarations.
  */
-#define        LIST_HEAD(name, type)                                           \
+#define        BSD_LIST_HEAD(name, type)                                               \
 struct name {                                                          \
        struct type *lh_first;  /* first element */                     \
 }
 
-#define        LIST_HEAD_INITIALIZER(head)                                     \
+#define        BSD_LIST_HEAD_INITIALIZER(head)                                 \
        { NULL }
 
-#define        LIST_ENTRY(type)                                                \
+#define        BSD_LIST_ENTRY(type)                                            \
 struct {                                                               \
        struct type *le_next;   /* next element */                      \
        struct type **le_prev;  /* address of previous next element */  \
@@ -353,15 +353,15 @@ struct {                                                          \
 
 #if (defined(_KERNEL) && defined(INVARIANTS))
 #define        QMD_LIST_CHECK_HEAD(head, field) do {                           \
-       if (LIST_FIRST((head)) != NULL &&                               \
-           LIST_FIRST((head))->field.le_prev !=                        \
-            &LIST_FIRST((head)))                                       \
+       if (BSD_LIST_FIRST((head)) != NULL &&                           \
+           BSD_LIST_FIRST((head))->field.le_prev !=                    \
+            &BSD_LIST_FIRST((head)))                                   \
                panic("Bad list head %p first->prev != head", (head));  \
 } while (0)
 
 #define        QMD_LIST_CHECK_NEXT(elm, field) do {                            \
-       if (LIST_NEXT((elm), field) != NULL &&                          \
-           LIST_NEXT((elm), field)->field.le_prev !=                   \
+       if (BSD_LIST_NEXT((elm), field) != NULL &&                              \
+           BSD_LIST_NEXT((elm), field)->field.le_prev !=                       \
             &((elm)->field.le_next))                                   \
                panic("Bad link elm %p next->prev != elm", (elm));      \
 } while (0)
@@ -376,72 +376,72 @@ struct {                                                          \
 #define        QMD_LIST_CHECK_PREV(elm, field)
 #endif /* (_KERNEL && INVARIANTS) */
 
-#define        LIST_EMPTY(head)        ((head)->lh_first == NULL)
+#define        BSD_LIST_EMPTY(head)    ((head)->lh_first == NULL)
 
-#define        LIST_FIRST(head)        ((head)->lh_first)
+#define        BSD_LIST_FIRST(head)    ((head)->lh_first)
 
-#define        LIST_FOREACH(var, head, field)                                  \
-       for ((var) = LIST_FIRST((head));                                \
+#define        BSD_LIST_FOREACH(var, head, field)                                      \
+       for ((var) = BSD_LIST_FIRST((head));                            \
            (var);                                                      \
-           (var) = LIST_NEXT((var), field))
+           (var) = BSD_LIST_NEXT((var), field))
 
-#define        LIST_FOREACH_SAFE(var, head, field, tvar)                       \
-       for ((var) = LIST_FIRST((head));                                \
-           (var) && ((tvar) = LIST_NEXT((var), field), 1);             \
+#define        BSD_LIST_FOREACH_SAFE(var, head, field, tvar)                   \
+       for ((var) = BSD_LIST_FIRST((head));                            \
+           (var) && ((tvar) = BSD_LIST_NEXT((var), field), 1);         \
            (var) = (tvar))
 
-#define        LIST_INIT(head) do {                                            \
-       LIST_FIRST((head)) = NULL;                                      \
+#define        BSD_LIST_INIT(head) do {                                                \
+       BSD_LIST_FIRST((head)) = NULL;                                  \
 } while (0)
 
-#define        LIST_INSERT_AFTER(listelm, elm, field) do {                     \
+#define        BSD_LIST_INSERT_AFTER(listelm, elm, field) do {                 \
        QMD_LIST_CHECK_NEXT(listelm, field);                            \
-       if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
-               LIST_NEXT((listelm), field)->field.le_prev =            \
-                   &LIST_NEXT((elm), field);                           \
-       LIST_NEXT((listelm), field) = (elm);                            \
-       (elm)->field.le_prev = &LIST_NEXT((listelm), field);            \
+       if ((BSD_LIST_NEXT((elm), field) = BSD_LIST_NEXT((listelm), field)) != NULL)\
+               BSD_LIST_NEXT((listelm), field)->field.le_prev =                \
+                   &BSD_LIST_NEXT((elm), field);                               \
+       BSD_LIST_NEXT((listelm), field) = (elm);                                \
+       (elm)->field.le_prev = &BSD_LIST_NEXT((listelm), field);                \
 } while (0)
 
-#define        LIST_INSERT_BEFORE(listelm, elm, field) do {                    \
+#define        BSD_LIST_INSERT_BEFORE(listelm, elm, field) do {                        \
        QMD_LIST_CHECK_PREV(listelm, field);                            \
        (elm)->field.le_prev = (listelm)->field.le_prev;                \
-       LIST_NEXT((elm), field) = (listelm);                            \
+       BSD_LIST_NEXT((elm), field) = (listelm);                                \
        *(listelm)->field.le_prev = (elm);                              \
-       (listelm)->field.le_prev = &LIST_NEXT((elm), field);            \
+       (listelm)->field.le_prev = &BSD_LIST_NEXT((elm), field);                \
 } while (0)
 
-#define        LIST_INSERT_HEAD(head, elm, field) do {                         \
+#define        BSD_LIST_INSERT_HEAD(head, elm, field) do {                             \
        QMD_LIST_CHECK_HEAD((head), field);                             \
-       if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)     \
-               LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
-       LIST_FIRST((head)) = (elm);                                     \
-       (elm)->field.le_prev = &LIST_FIRST((head));                     \
+       if ((BSD_LIST_NEXT((elm), field) = BSD_LIST_FIRST((head))) != NULL)     \
+               BSD_LIST_FIRST((head))->field.le_prev = &BSD_LIST_NEXT((elm), field);\
+       BSD_LIST_FIRST((head)) = (elm);                                 \
+       (elm)->field.le_prev = &BSD_LIST_FIRST((head));                 \
 } while (0)
 
-#define        LIST_NEXT(elm, field)   ((elm)->field.le_next)
+#define        BSD_LIST_NEXT(elm, field)       ((elm)->field.le_next)
 
-#define        LIST_REMOVE(elm, field) do {                                    \
+#define        BSD_LIST_REMOVE(elm, field) do {                                        \
        QMD_SAVELINK(oldnext, (elm)->field.le_next);                    \
        QMD_SAVELINK(oldprev, (elm)->field.le_prev);                    \
        QMD_LIST_CHECK_NEXT(elm, field);                                \
        QMD_LIST_CHECK_PREV(elm, field);                                \
-       if (LIST_NEXT((elm), field) != NULL)                            \
-               LIST_NEXT((elm), field)->field.le_prev =                \
+       if (BSD_LIST_NEXT((elm), field) != NULL)                                \
+               BSD_LIST_NEXT((elm), field)->field.le_prev =            \
                    (elm)->field.le_prev;                               \
-       *(elm)->field.le_prev = LIST_NEXT((elm), field);                \
+       *(elm)->field.le_prev = BSD_LIST_NEXT((elm), field);            \
        TRASHIT(*oldnext);                                              \
        TRASHIT(*oldprev);                                              \
 } while (0)
 
-#define LIST_SWAP(head1, head2, type, field) do {                      \
-       struct type *swap_tmp = LIST_FIRST((head1));                    \
-       LIST_FIRST((head1)) = LIST_FIRST((head2));                      \
-       LIST_FIRST((head2)) = swap_tmp;                                 \
-       if ((swap_tmp = LIST_FIRST((head1))) != NULL)                   \
-               swap_tmp->field.le_prev = &LIST_FIRST((head1));         \
-       if ((swap_tmp = LIST_FIRST((head2))) != NULL)                   \
-               swap_tmp->field.le_prev = &LIST_FIRST((head2));         \
+#define BSD_LIST_SWAP(head1, head2, type, field) do {                  \
+       struct type *swap_tmp = BSD_LIST_FIRST((head1));                        \
+       BSD_LIST_FIRST((head1)) = BSD_LIST_FIRST((head2));                      \
+       BSD_LIST_FIRST((head2)) = swap_tmp;                                     \
+       if ((swap_tmp = BSD_LIST_FIRST((head1))) != NULL)                       \
+               swap_tmp->field.le_prev = &BSD_LIST_FIRST((head1));             \
+       if ((swap_tmp = BSD_LIST_FIRST((head2))) != NULL)                       \
+               swap_tmp->field.le_prev = &BSD_LIST_FIRST((head2));             \
 } while (0)
 
 /*
index 072de6d..e2033c0 100644 (file)
@@ -63,8 +63,8 @@ static void __page_init(struct page *page)
        }                                                                       \
        /* Allocate a page from that color */                                   \
        if(i < (base_color+range)) {                                            \
-               *page = LIST_FIRST(&colored_page_free_list[i]);                     \
-               LIST_REMOVE(*page, pg_link);                                        \
+               *page = BSD_LIST_FIRST(&colored_page_free_list[i]);                 \
+               BSD_LIST_REMOVE(*page, pg_link);                                    \
                __page_init(*page);                                                 \
                return i;                                                           \
        }                                                                       \
@@ -75,14 +75,15 @@ static ssize_t __page_alloc_from_color_range(page_t** page,
                                            uint16_t range) 
 {
        __PAGE_ALLOC_FROM_RANGE_GENERIC(page, base_color, range, 
-                        !LIST_EMPTY(&colored_page_free_list[i]));
+                        !BSD_LIST_EMPTY(&colored_page_free_list[i]));
 }
 
 static ssize_t __page_alloc_from_color_map_range(page_t** page, uint8_t* map, 
                                               size_t base_color, size_t range)
 {  
        __PAGE_ALLOC_FROM_RANGE_GENERIC(page, base_color, range, 
-                   GET_BITMASK_BIT(map, i) && !LIST_EMPTY(&colored_page_free_list[i]))
+                   GET_BITMASK_BIT(map, i) &&
+                       !BSD_LIST_EMPTY(&colored_page_free_list[i]))
 }
 
 static ssize_t __colored_page_alloc(uint8_t* map, page_t** page, 
@@ -97,7 +98,7 @@ static ssize_t __colored_page_alloc(uint8_t* map, page_t** page,
 
 static void __real_page_alloc(struct page *page)
 {
-       LIST_REMOVE(page, pg_link);
+       BSD_LIST_REMOVE(page, pg_link);
        __page_init(page);
 }
 
@@ -357,7 +358,7 @@ static void page_release(struct kref *kref)
                free_bhs(page);
        /* Give our page back to the free list.  The protections for this are that
         * the list lock is grabbed by page_decref. */
-       LIST_INSERT_HEAD(
+       BSD_LIST_INSERT_HEAD(
           &(colored_page_free_list[get_page_color(page2ppn(page), llc_cache)]),
           page,
           pg_link