Make list_entry, hash_entry more type-safe.
[pintos-anon] / src / lib / kernel / list.h
index e71c1cab31500c801547ec39131ee668fdd8c288..2388f9acdbf8e553d79ff6a27b93703020a3739e 100644 (file)
@@ -105,8 +105,9 @@ struct list
    name of the outer structure STRUCT and the member name MEMBER
    of the list element.  See the big comment at the top of the
    file for an example. */
-#define list_entry(LIST_ELEM, STRUCT, MEMBER)                              \
-        ((STRUCT *) ((uint8_t *) (LIST_ELEM) - offsetof (STRUCT, MEMBER)))
+#define list_entry(LIST_ELEM, STRUCT, MEMBER)           \
+        ((STRUCT *) ((uint8_t *) &(LIST_ELEM)->next     \
+                     - offsetof (STRUCT, MEMBER.next)))
 
 void list_init (struct list *);
 
@@ -153,8 +154,6 @@ typedef bool list_less_func (const struct list_elem *a,
                              void *aux);
 
 /* Operations on lists with ordered elements. */
-void list_merge (struct list *, struct list *,
-                 list_less_func *, void *aux);
 void list_sort (struct list *,
                 list_less_func *, void *aux);
 void list_insert_ordered (struct list *, struct list_elem *,