Index: kernel/generic/src/adt/cht.c
===================================================================
--- kernel/generic/src/adt/cht.c	(revision 44a7ee5373ccc121fce74799244a44867eed301d)
+++ kernel/generic/src/adt/cht.c	(revision deacc58d86dbbc4e37a7d1534bd9933e671162e1)
@@ -290,5 +290,5 @@
 #include <adt/cht.h>
 #include <adt/hash.h>
-#include <debug.h>
+#include <assert.h>
 #include <mm/slab.h>
 #include <arch/barrier.h>
@@ -522,9 +522,9 @@
 	bool can_block, cht_ops_t *op)
 {
-	ASSERT(h);
-	ASSERT(op && op->hash && op->key_hash && op->equal && op->key_equal);
+	assert(h);
+	assert(op && op->hash && op->key_hash && op->equal && op->key_equal);
 	/* Memoized hashes are stored in the rcu_link.func function pointer. */
-	STATIC_ASSERT(sizeof(size_t) == sizeof(rcu_func_t));
-	ASSERT(sentinel.hash == (uintptr_t)sentinel.rcu_link.func);
+	static_assert(sizeof(size_t) == sizeof(rcu_func_t), "");
+	assert(sentinel.hash == (uintptr_t)sentinel.rcu_link.func);
 
 	/* All operations are compulsory. */
@@ -625,5 +625,5 @@
 	
 	/* You must clear the table of items. Otherwise cht_destroy will leak. */
-	ASSERT(atomic_get(&h->item_cnt) == 0);
+	assert(atomic_get(&h->item_cnt) == 0);
 }
 
@@ -685,7 +685,7 @@
 static inline cht_link_t *find_lazy(cht_t *h, void *key)
 {
-	ASSERT(h);
+	assert(h);
 	/* See docs to cht_find() and cht_find_lazy(). */
-	ASSERT(rcu_read_locked());
+	assert(rcu_read_locked());
 	
 	size_t hash = calc_key_hash(h, key);
@@ -731,7 +731,7 @@
 cht_link_t *cht_find_next_lazy(cht_t *h, const cht_link_t *item)
 {
-	ASSERT(h);
-	ASSERT(rcu_read_locked());
-	ASSERT(item);
+	assert(h);
+	assert(rcu_read_locked());
+	assert(item);
 	
 	return find_duplicate(h, item, calc_node_hash(h, item), get_next(item->link));
@@ -755,5 +755,5 @@
 	do {
 		cur = get_next(prev);
-		ASSERT(cur);
+		assert(cur);
 		prev = cur->link;
 	} while (node_hash(h, cur) < search_hash);
@@ -770,5 +770,5 @@
 		
 		cur = get_next(cur->link);
-		ASSERT(cur);
+		assert(cur);
 	} 
 	
@@ -790,6 +790,6 @@
 	marked_ptr_t old_head, size_t old_idx)
 {
-	ASSERT(N_INVALID == get_mark(old_head)); 
-	ASSERT(h->new_b);
+	assert(N_INVALID == get_mark(old_head)); 
+	assert(h->new_b);
 	
 	size_t new_idx = calc_bucket_idx(hash, h->new_b->order);
@@ -903,5 +903,5 @@
 			 * traversing search_head.
 			 */
-			ASSERT(N_JOIN & get_mark(get_next(old_head)->link));
+			assert(N_JOIN & get_mark(get_next(old_head)->link));
 			return search_bucket(h, old_head, key, hash);
 		}
@@ -913,10 +913,10 @@
 		 * sure all cpus see that the new table replaced the old one.
 		 */
-		ASSERT(h->b->order == h->new_b->order);
+		assert(h->b->order == h->new_b->order);
 		/* 
 		 * The resizer must ensure all new bucket heads are visible before
 		 * replacing the old table.
 		 */
-		ASSERT(N_NORMAL == get_mark(new_head));
+		assert(N_NORMAL == get_mark(new_head));
 		return search_bucket(h, new_head, key, hash);
 	}
@@ -961,6 +961,6 @@
 bool cht_insert_unique(cht_t *h, cht_link_t *item, cht_link_t **dup_item)
 {
-	ASSERT(rcu_read_locked());
-	ASSERT(dup_item);
+	assert(rcu_read_locked());
+	assert(dup_item);
 	return insert_impl(h, item, dup_item);
 }
@@ -1060,5 +1060,5 @@
 		return ret == make_link(wnd->cur, jf_mark);
 	} else {
-		ASSERT(walk_mode == WM_LEAVE_JOIN);
+		assert(walk_mode == WM_LEAVE_JOIN);
 
 		item->link = make_link(wnd->cur, N_NORMAL);
@@ -1087,6 +1087,6 @@
 	cht_link_t *cur, cht_link_t **dup_item)
 {
-	ASSERT(cur);
-	ASSERT(cur == &sentinel || hash <= node_hash(h, cur)
+	assert(cur);
+	assert(cur == &sentinel || hash <= node_hash(h, cur)
 		|| node_hash(h, cur) == h->invalid_hash);
 	
@@ -1110,13 +1110,13 @@
 	cht_link_t *start)
 {
-	ASSERT(hash <= node_hash(h, start) || h->invalid_hash == node_hash(h, start));
+	assert(hash <= node_hash(h, start) || h->invalid_hash == node_hash(h, start));
 
 	cht_link_t *cur = start;
 	
 try_again:	
-	ASSERT(cur);
+	assert(cur);
 
 	while (node_hash(h, cur) == hash) {
-		ASSERT(cur != &sentinel);
+		assert(cur != &sentinel);
 		
 		bool deleted = (N_DELETED & get_mark(cur->link));
@@ -1127,5 +1127,5 @@
 		
 		cur = get_next(cur->link);
-		ASSERT(cur);
+		assert(cur);
 	} 
 
@@ -1142,5 +1142,5 @@
 size_t cht_remove_key(cht_t *h, void *key)
 {
-	ASSERT(h);
+	assert(h);
 	
 	size_t hash = calc_key_hash(h, key);
@@ -1163,8 +1163,8 @@
 bool cht_remove_item(cht_t *h, cht_link_t *item)
 {
-	ASSERT(h);
-	ASSERT(item);
+	assert(h);
+	assert(item);
 	/* Otherwise a concurrent cht_remove_key might free the item. */
-	ASSERT(rcu_read_locked());
+	assert(rcu_read_locked());
 
 	/* 
@@ -1262,5 +1262,5 @@
 	bool *deleted_but_gc, bool *resizing)
 {
-	ASSERT(wnd->cur && wnd->cur != &sentinel);
+	assert(wnd->cur && wnd->cur != &sentinel);
 	
 	*deleted_but_gc = false;
@@ -1292,5 +1292,5 @@
 	bool *resizing)
 {
-	ASSERT(cur && cur != &sentinel);
+	assert(cur && cur != &sentinel);
 	
 	/* 
@@ -1310,5 +1310,5 @@
 		}
 	} else {
-		STATIC_ASSERT(N_JOIN == N_JOIN_FOLLOWS);
+		static_assert(N_JOIN == N_JOIN_FOLLOWS, "");
 		
 		/* Keep the N_JOIN/N_JOIN_FOLLOWS mark but strip N_DELETED. */
@@ -1329,6 +1329,6 @@
 	bool *resizing)
 {
-	ASSERT(wnd->cur != &sentinel);
-	ASSERT(wnd->cur && (N_DELETED & get_mark(wnd->cur->link)));
+	assert(wnd->cur != &sentinel);
+	assert(wnd->cur && (N_DELETED & get_mark(wnd->cur->link)));
 	
 	cht_link_t *next = get_next(wnd->cur->link);
@@ -1336,5 +1336,5 @@
 	if (walk_mode == WM_LEAVE_JOIN) {
 		/* Never try to unlink join nodes. */
-		ASSERT(!(N_JOIN & get_mark(wnd->cur->link)));
+		assert(!(N_JOIN & get_mark(wnd->cur->link)));
 
 		mark_t pred_mark = get_mark(*wnd->ppred);
@@ -1348,5 +1348,5 @@
 			return false;
 	} else {
-		ASSERT(walk_mode == WM_MOVE_JOIN_FOLLOWS || walk_mode == WM_NORMAL);
+		assert(walk_mode == WM_MOVE_JOIN_FOLLOWS || walk_mode == WM_NORMAL);
 		/* Move the JF mark if set. Clear DEL mark. */
 		mark_t cur_mark = N_JOIN_FOLLOWS & get_mark(wnd->cur->link);
@@ -1398,5 +1398,5 @@
 	equal_pred_t pred, void *pred_arg, wnd_t *wnd, bool *resizing)
 {
-	ASSERT(wnd->cur);
+	assert(wnd->cur);
 	
 	if (wnd->cur == &sentinel)
@@ -1415,5 +1415,5 @@
 		
 	while (cur_hash <= hash) {
-		ASSERT(wnd->cur && wnd->cur != &sentinel);
+		assert(wnd->cur && wnd->cur != &sentinel);
 		
 		/* GC any deleted nodes on the way. */
@@ -1436,5 +1436,5 @@
 	if (cur_hash == h->invalid_hash) {
 		next_wnd(wnd);
-		ASSERT(wnd->cur);
+		assert(wnd->cur);
 		goto try_again;
 	}
@@ -1469,5 +1469,5 @@
 {
 try_again:
-	ASSERT(wnd->cur);
+	assert(wnd->cur);
 
 	while (node_hash(h, wnd->cur) < hash) {
@@ -1482,5 +1482,5 @@
 		}
 		
-		ASSERT(wnd->cur);
+		assert(wnd->cur);
 	}
 	
@@ -1498,5 +1498,5 @@
 	bool *resizing)
 {
-	ASSERT(N_DELETED & get_mark(wnd->cur->link));
+	assert(N_DELETED & get_mark(wnd->cur->link));
 
 	/* Skip deleted JOIN nodes. */
@@ -1505,5 +1505,5 @@
 	} else {
 		/* Ordinary deleted node or a deleted JOIN_FOLLOWS. */
-		ASSERT(walk_mode != WM_LEAVE_JOIN 
+		assert(walk_mode != WM_LEAVE_JOIN 
 			|| !((N_JOIN | N_JOIN_FOLLOWS) & get_mark(wnd->cur->link)));
 
@@ -1546,6 +1546,6 @@
 	 * it 
 	 */
-	ASSERT(h->b->order > h->new_b->order);
-	ASSERT(wnd->cur);
+	assert(h->b->order > h->new_b->order);
+	assert(wnd->cur);
 	
 	/* Either we did not need the joining link or we have already followed it.*/
@@ -1620,13 +1620,13 @@
 		/* The hash belongs to the moved bucket. */
 		if (move_dest_idx == new_idx) {
-			ASSERT(pmoved_head == pnew_head);
+			assert(pmoved_head == pnew_head);
 			/* 
 			 * move_head() makes the new head of the moved bucket visible. 
 			 * The new head may be marked with a JOIN_FOLLOWS
 			 */
-			ASSERT(!(N_CONST & get_mark(*pmoved_head)));
+			assert(!(N_CONST & get_mark(*pmoved_head)));
 			*walk_mode = WM_MOVE_JOIN_FOLLOWS;
 		} else {
-			ASSERT(pmoved_head != pnew_head);
+			assert(pmoved_head != pnew_head);
 			/* 
 			 * The hash belongs to the bucket that is the result of splitting 
@@ -1643,5 +1643,5 @@
 				 * JOIN_FOLLOWS in this part of split bucket.
 				 */
-				ASSERT(N_NORMAL == get_mark(*pnew_head));
+				assert(N_NORMAL == get_mark(*pnew_head));
 			}
 			
@@ -1675,7 +1675,7 @@
 		
 		/* move_head() or join_buckets() makes it so or makes the mark visible.*/
-		ASSERT(N_INVALID == get_mark(*pold_head));
+		assert(N_INVALID == get_mark(*pold_head));
 		/* move_head() makes it visible. No JOIN_FOLLOWS used when shrinking. */
-		ASSERT(N_NORMAL == get_mark(*pnew_head));
+		assert(N_NORMAL == get_mark(*pnew_head));
 
 		*walk_mode = WM_LEAVE_JOIN;
@@ -1685,5 +1685,5 @@
 		 * readers to notice that the old table had been replaced.
 		 */
-		ASSERT(b == h->new_b);
+		assert(b == h->new_b);
 		*walk_mode = WM_NORMAL;
 	}
@@ -1712,5 +1712,5 @@
 {
 	/* Head move has to in progress already when calling this func. */
-	ASSERT(N_CONST & get_mark(*psrc_head));
+	assert(N_CONST & get_mark(*psrc_head));
 	
 	/* Head already moved. */
@@ -1725,5 +1725,5 @@
 	}
 	
-	ASSERT(!(N_CONST & get_mark(*pdest_head)));
+	assert(!(N_CONST & get_mark(*pdest_head)));
 }
 
@@ -1756,6 +1756,6 @@
 static void complete_head_move(marked_ptr_t *psrc_head, marked_ptr_t *pdest_head)
 {
-	ASSERT(N_JOIN_FOLLOWS != get_mark(*psrc_head));
-	ASSERT(N_CONST & get_mark(*psrc_head));
+	assert(N_JOIN_FOLLOWS != get_mark(*psrc_head));
+	assert(N_CONST & get_mark(*psrc_head));
 	
 	cht_link_t *next = get_next(*psrc_head);
@@ -1763,10 +1763,10 @@
 	DBG(marked_ptr_t ret = )
 		cas_link(pdest_head, &sentinel, N_INVALID, next, N_NORMAL);
-	ASSERT(ret == make_link(&sentinel, N_INVALID) || (N_NORMAL == get_mark(ret)));
+	assert(ret == make_link(&sentinel, N_INVALID) || (N_NORMAL == get_mark(ret)));
 	cas_order_barrier();
 	
 	DBG(ret = ) 
 		cas_link(psrc_head, next, N_CONST, next, N_INVALID);	
-	ASSERT(ret == make_link(next, N_CONST) || (N_INVALID == get_mark(ret)));
+	assert(ret == make_link(next, N_CONST) || (N_INVALID == get_mark(ret)));
 	cas_order_barrier();
 }
@@ -1861,5 +1861,5 @@
 	DBG(marked_ptr_t ret = )
 		cas_link(pdest_head, &sentinel, N_INVALID, wnd.cur, N_NORMAL);
-	ASSERT(ret == make_link(&sentinel, N_INVALID) || (N_NORMAL == get_mark(ret)));
+	assert(ret == make_link(&sentinel, N_INVALID) || (N_NORMAL == get_mark(ret)));
 	cas_order_barrier();
 	
@@ -1905,5 +1905,5 @@
 		
 		/* Must not report that the table is resizing if WM_MOVE_JOIN_FOLLOWS.*/
-		ASSERT(!resizing);
+		assert(!resizing);
 		/* 
 		 * Mark the last node of the first half of the split bucket 
@@ -2042,5 +2042,5 @@
 	DBG(marked_ptr_t ret = )
 		cas_link(psrc_head, join_node, N_CONST, join_node, N_INVALID);
-	ASSERT(ret == make_link(join_node, N_CONST) || (N_INVALID == get_mark(ret)));
+	assert(ret == make_link(join_node, N_CONST) || (N_INVALID == get_mark(ret)));
 	cas_order_barrier();
 	
@@ -2073,9 +2073,9 @@
 			continue;
 
-		ASSERT(!resizing);
+		assert(!resizing);
 		
 		if (wnd.cur != &sentinel) {
 			/* Must be from the new appended bucket. */
-			ASSERT(split_hash <= node_hash(h, wnd.cur) 
+			assert(split_hash <= node_hash(h, wnd.cur) 
 				|| h->invalid_hash == node_hash(h, wnd.cur));
 			return;
@@ -2096,5 +2096,5 @@
 static void free_later(cht_t *h, cht_link_t *item)
 {
-	ASSERT(item != &sentinel);
+	assert(item != &sentinel);
 	
 	/* 
@@ -2156,8 +2156,8 @@
 	
 #ifdef CONFIG_DEBUG
-	ASSERT(h->b);
+	assert(h->b);
 	/* Make resize_reqs visible. */
 	read_barrier();
-	ASSERT(0 < atomic_get(&h->resize_reqs));
+	assert(0 < atomic_get(&h->resize_reqs));
 #endif
 
@@ -2336,5 +2336,5 @@
 		/* Set the invalid joinee head to NULL. */
 		if (old_idx != move_src_idx) {
-			ASSERT(N_INVALID == get_mark(h->b->head[old_idx]));
+			assert(N_INVALID == get_mark(h->b->head[old_idx]));
 			
 			if (&sentinel != get_next(h->b->head[old_idx]))
@@ -2392,6 +2392,6 @@
 	marked_ptr_t *new_head)
 {
-	ASSERT(join_node != &sentinel);
-	ASSERT(join_node && (N_JOIN & get_mark(join_node->link)));
+	assert(join_node != &sentinel);
+	assert(join_node && (N_JOIN & get_mark(join_node->link)));
 	
 	bool done;
@@ -2409,5 +2409,5 @@
 		/* Done if the mark was cleared. Retry if a new node was inserted. */
 		done = (ret == jn_link);
-		ASSERT(ret == jn_link || (get_mark(ret) & N_JOIN));
+		assert(ret == jn_link || (get_mark(ret) & N_JOIN));
 	} while (!done);
 	
@@ -2432,5 +2432,5 @@
 			join_node, &wnd, &resizing);
 		
-		ASSERT(!resizing);
+		assert(!resizing);
 	} while (!done);
 }
@@ -2439,5 +2439,5 @@
 static void cleanup_join_follows(cht_t *h, marked_ptr_t *new_head)
 {
-	ASSERT(new_head);
+	assert(new_head);
 	
 	rcu_read_lock();
@@ -2464,7 +2464,7 @@
 		/* GC any deleted nodes on the way - even deleted JOIN_FOLLOWS. */
 		if (N_DELETED & get_mark(*cur_link)) {
-			ASSERT(cur_link != new_head);
-			ASSERT(wnd.ppred && wnd.cur && wnd.cur != &sentinel);
-			ASSERT(cur_link == &wnd.cur->link);
+			assert(cur_link != new_head);
+			assert(wnd.ppred && wnd.cur && wnd.cur != &sentinel);
+			assert(cur_link == &wnd.cur->link);
 
 			bool dummy;
@@ -2484,5 +2484,5 @@
 					cas_link(cur_link, next, N_JOIN_FOLLOWS, &sentinel, N_NORMAL);
 				
-				ASSERT(next == &sentinel 
+				assert(next == &sentinel 
 					|| ((N_JOIN | N_JOIN_FOLLOWS) & get_mark(ret)));
 
@@ -2505,5 +2505,5 @@
 
 		/* We must encounter a JF node before we reach the end of the bucket. */
-		ASSERT(wnd.cur && wnd.cur != &sentinel);
+		assert(wnd.cur && wnd.cur != &sentinel);
 		cur_link = &wnd.cur->link;
 	}
@@ -2519,5 +2519,5 @@
 static inline size_t calc_split_hash(size_t split_idx, size_t order)
 {
-	ASSERT(1 <= order && order <= 8 * sizeof(size_t));
+	assert(1 <= order && order <= 8 * sizeof(size_t));
 	return split_idx << (8 * sizeof(size_t) - order);
 }
@@ -2526,5 +2526,5 @@
 static inline size_t calc_bucket_idx(size_t hash, size_t order)
 {
-	ASSERT(1 <= order && order <= 8 * sizeof(size_t));
+	assert(1 <= order && order <= 8 * sizeof(size_t));
 	return hash >> (8 * sizeof(size_t) - order);
 }
@@ -2558,5 +2558,5 @@
 static inline size_t node_hash(cht_t *h, const cht_link_t *item)
 {
-	ASSERT(item->hash == h->invalid_hash 
+	assert(item->hash == h->invalid_hash 
 		|| item->hash == sentinel.hash
 		|| item->hash == calc_node_hash(h, item));
@@ -2568,5 +2568,5 @@
 static inline size_t calc_node_hash(cht_t *h, const cht_link_t *item)
 {
-	ASSERT(item != &sentinel);
+	assert(item != &sentinel);
 	/* 
 	 * Clear the lowest order bit in order for sentinel's node hash
@@ -2587,6 +2587,6 @@
 	marked_ptr_t ptr = (marked_ptr_t) next;
 	
-	ASSERT(!(ptr & N_MARK_MASK));
-	ASSERT(!((unsigned)mark & ~N_MARK_MASK));
+	assert(!(ptr & N_MARK_MASK));
+	assert(!((unsigned)mark & ~N_MARK_MASK));
 	
 	return ptr | mark;
@@ -2608,6 +2608,6 @@
 static inline void next_wnd(wnd_t *wnd)
 {
-	ASSERT(wnd);
-	ASSERT(wnd->cur);
+	assert(wnd);
+	assert(wnd->cur);
 
 	wnd->last = wnd->cur;
@@ -2635,5 +2635,5 @@
 	marked_ptr_t new)
 {
-	ASSERT(link != &sentinel.link);
+	assert(link != &sentinel.link);
 	/*
 	 * cas(x) on the same location x on one cpu must be ordered, but do not
