Index: kernel/generic/include/adt/list.h
===================================================================
--- kernel/generic/include/adt/list.h	(revision d71331bea5345927ef31fc1551b6db3ae620837f)
+++ kernel/generic/include/adt/list.h	(revision ef1603b3aaf4bc28c37fa3c7f408b23f535f8e0a)
@@ -71,4 +71,36 @@
 	    iterator != &(list).head; iterator = iterator->next)
 
+/** Unlike list_foreach(), allows removing items while traversing a list.
+ * 
+ * @code
+ * list_t mylist;
+ * typedef struct item {
+ *     int value;
+ *     link_t item_link;
+ * } item_t;
+ * 
+ * //..
+ * 
+ * // Print each list element's value and remove the element from the list.
+ * list_foreach_safe(mylist, cur_link, next_link) {
+ *     item_t *cur_item = list_get_instance(cur_link, item_t, item_link);
+ *     printf("%d\n", cur_item->value);
+ *     list_remove(cur_link);
+ * }
+ * @endcode
+ * 
+ * @param list List to traverse.
+ * @param iterator Iterator to the current element of the list.
+ *             The item this iterator points may be safely removed
+ *             from the list.
+ * @param next_iter Iterator to the next element of the list.
+ */
+#define list_foreach_safe(list, iterator, next_iter) \
+	for (link_t *iterator = (list).head.next, \
+		*next_iter = iterator->next; \
+		iterator != &(list).head; \
+		iterator = next_iter, next_iter = iterator->next)
+
+	
 #define assert_link_not_used(link) \
 	ASSERT(((link)->prev == NULL) && ((link)->next == NULL))
@@ -85,4 +117,15 @@
 	link->prev = NULL;
 	link->next = NULL;
+}
+
+/** Returns true if the initialized link is already in use by any list.
+ * 
+ * @param link Link to examine whether if belongs to a list or not.
+ * @return 1 if the link is part of a list. 
+ * @return 0 otherwise.
+ */
+NO_TRACE static inline int link_used(const link_t *link)
+{
+	return link->prev != NULL || link->next != NULL;
 }
 
