Module Name: src Committed By: jdc Date: Sat Nov 24 18:15:22 UTC 2012
Modified Files: src/common/lib/libc/gen [netbsd-6]: ptree.c src/sys/sys [netbsd-6]: ptree.h Log Message: Pull up revisions: src/common/lib/libc/gen/ptree.c revision 1.10 src/sys/sys/ptree.h revision 1.8 (requested by rmind in ticket #717). Add a ptree_mask_node_p to determine if an item is a mask node, and what its non-mask length is. To generate a diff of this commit: cvs rdiff -u -r1.5.8.2 -r1.5.8.3 src/common/lib/libc/gen/ptree.c cvs rdiff -u -r1.4.8.2 -r1.4.8.3 src/sys/sys/ptree.h 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/ptree.c diff -u src/common/lib/libc/gen/ptree.c:1.5.8.2 src/common/lib/libc/gen/ptree.c:1.5.8.3 --- src/common/lib/libc/gen/ptree.c:1.5.8.2 Mon Jul 16 22:10:46 2012 +++ src/common/lib/libc/gen/ptree.c Sat Nov 24 18:15:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ptree.c,v 1.5.8.2 2012/07/16 22:10:46 riz Exp $ */ +/* $NetBSD: ptree.c,v 1.5.8.3 2012/11/24 18:15:22 jdc 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.5.8.2 2012/07/16 22:10:46 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.5.8.3 2012/11/24 18:15:22 jdc Exp $"); #else #include <stddef.h> #include <stdint.h> @@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1. #else #define KASSERT(e) do { } while (/*CONSTCOND*/ 0) #endif -__RCSID("$NetBSD: ptree.c,v 1.5.8.2 2012/07/16 22:10:46 riz Exp $"); +__RCSID("$NetBSD: ptree.c,v 1.5.8.3 2012/11/24 18:15:22 jdc Exp $"); #endif /* _KERNEL || _STANDALONE */ #ifdef _LIBC @@ -1214,3 +1214,17 @@ ptree_check(const pt_tree_t *pt) #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; +} Index: src/sys/sys/ptree.h diff -u src/sys/sys/ptree.h:1.4.8.2 src/sys/sys/ptree.h:1.4.8.3 --- src/sys/sys/ptree.h:1.4.8.2 Mon Jul 16 22:10:47 2012 +++ src/sys/sys/ptree.h Sat Nov 24 18:15:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ptree.h,v 1.4.8.2 2012/07/16 22:10:47 riz Exp $ */ +/* $NetBSD: ptree.h,v 1.4.8.3 2012/11/24 18:15:22 jdc Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -184,6 +184,7 @@ typedef bool (*pt_filter_t)(void *, cons 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)