Module Name:    src
Committed By:   yamt
Date:           Thu May 19 10:00:30 UTC 2011

Modified Files:
        src/common/lib/libc/gen: radixtree.c

Log Message:
radixtree: comments


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/gen/radixtree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/gen/radixtree.c
diff -u src/common/lib/libc/gen/radixtree.c:1.4 src/common/lib/libc/gen/radixtree.c:1.5
--- src/common/lib/libc/gen/radixtree.c:1.4	Thu May 19 09:58:28 2011
+++ src/common/lib/libc/gen/radixtree.c	Thu May 19 10:00:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: radixtree.c,v 1.4 2011/05/19 09:58:28 yamt Exp $	*/
+/*	$NetBSD: radixtree.c,v 1.5 2011/05/19 10:00:30 yamt Exp $	*/
 
 /*-
  * Copyright (c)2011 YAMAMOTO Takashi,
@@ -41,7 +41,7 @@
 #include <sys/cdefs.h>
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.4 2011/05/19 09:58:28 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.5 2011/05/19 10:00:30 yamt Exp $");
 #include <sys/param.h>
 #include <sys/errno.h>
 #include <sys/pool.h>
@@ -51,7 +51,7 @@
 #include <lib/libsa/stand.h>
 #endif /* defined(_STANDALONE) */
 #else /* defined(_KERNEL) || defined(_STANDALONE) */
-__RCSID("$NetBSD: radixtree.c,v 1.4 2011/05/19 09:58:28 yamt Exp $");
+__RCSID("$NetBSD: radixtree.c,v 1.5 2011/05/19 10:00:30 yamt Exp $");
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
@@ -325,6 +325,25 @@
 	return 0;
 }
 
+/*
+ * radix_tree_lookup_ptr:
+ *
+ * an internal helper function used for various exported functions.
+ *
+ * return the pointer to store the node for the given index.
+ *
+ * if alloc is true, try to allocate the storage.  (note for _KERNEL:
+ * in that case, this function can block.)  if the allocation failed or
+ * alloc is false, return NULL.
+ *
+ * if path is not NULL, fill it for the caller's investigation.
+ *
+ * if tagmask is not zero, search only for nodes with the tag set.
+ *
+ * while this function is a bit large, as it's called with some constant
+ * arguments, inlining might have benefits.  anyway, a compiler will decide.
+ */
+
 static inline void **
 radix_tree_lookup_ptr(struct radix_tree *t, uint64_t idx,
     struct radix_tree_path *path, bool alloc, const unsigned int tagmask)
@@ -336,6 +355,9 @@
 	const uint64_t mask = (UINT64_C(1) << RADIX_TREE_BITS_PER_HEIGHT) - 1;
 	struct radix_tree_node_ref *refs = NULL;
 
+	/*
+	 * check unsupported combinations
+	 */
 	KASSERT(tagmask == 0 || !alloc);
 	KASSERT(path == NULL || !alloc);
 	vpp = &t->t_root;

Reply via email to