Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add a ptree_mask_node_p to determine if an item is a mask no...



details:   https://anonhg.NetBSD.org/src/rev/beac25e727d3
branches:  trunk
changeset: 781918:beac25e727d3
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Oct 06 22:15:09 2012 +0000

description:
Add a ptree_mask_node_p to determine if an item is a mask node, and what
its non-mask length is.

diffstat:

 common/lib/libc/gen/ptree.c |  20 +++++++++++++++++---
 sys/sys/ptree.h             |   3 ++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r 3a31a8b498d8 -r beac25e727d3 common/lib/libc/gen/ptree.c
--- a/common/lib/libc/gen/ptree.c       Sat Oct 06 20:54:58 2012 +0000
+++ b/common/lib/libc/gen/ptree.c       Sat Oct 06 22:15:09 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptree.c,v 1.9 2012/07/15 00:16:28 rmind Exp $  */
+/*     $NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #include <sys/types.h>
 #include <sys/systm.h>
 #include <lib/libkern/libkern.h>
-__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.9 2012/07/15 00:16:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $");
 #else
 #include <stddef.h>
 #include <stdint.h>
@@ -53,7 +53,7 @@
 #else
 #define        KASSERT(e)      do { } while (/*CONSTCOND*/ 0)
 #endif
-__RCSID("$NetBSD: ptree.c,v 1.9 2012/07/15 00:16:28 rmind Exp $");
+__RCSID("$NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $");
 #endif /* _KERNEL || _STANDALONE */
 
 #ifdef _LIBC
@@ -1214,3 +1214,17 @@
 #endif
        return ok;
 }
+
+bool
+ptree_mask_node_p(pt_tree_t *pt, const void *item, pt_bitlen_t *lenp)
+{
+       const pt_node_t * const mask = ITEMTONODE(pt, item);
+
+       if (!PTN_ISMASK_P(mask))
+               return false;
+
+       if (lenp != NULL)
+               *lenp = PTN_MASK_BITLEN(mask);
+
+       return true;
+}
diff -r 3a31a8b498d8 -r beac25e727d3 sys/sys/ptree.h
--- a/sys/sys/ptree.h   Sat Oct 06 20:54:58 2012 +0000
+++ b/sys/sys/ptree.h   Sat Oct 06 22:15:09 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptree.h,v 1.7 2012/07/15 00:16:28 rmind Exp $  */
+/*     $NetBSD: ptree.h,v 1.8 2012/10/06 22:15:09 matt Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -184,6 +184,7 @@
 void   ptree_init(pt_tree_t *, const pt_tree_ops_t *, void *, size_t, size_t);
 bool   ptree_insert_node(pt_tree_t *, void *);
 bool   ptree_insert_mask_node(pt_tree_t *, void *, pt_bitlen_t);
+bool   ptree_mask_node_p(pt_tree_t *, const void *, pt_bitlen_t *);
 void * ptree_find_filtered_node(pt_tree_t *, const void *, pt_filter_t, void *);
 #define        ptree_find_node(pt,key) \
        ptree_find_filtered_node((pt), (key), NULL, NULL)



Home | Main Index | Thread Index | Old Index