Module Name: src Committed By: matt Date: Sat Oct 6 22:15:09 UTC 2012
Modified Files: src/common/lib/libc/gen: ptree.c src/sys/sys: ptree.h Log Message: 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.9 -r1.10 src/common/lib/libc/gen/ptree.c cvs rdiff -u -r1.7 -r1.8 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.9 src/common/lib/libc/gen/ptree.c:1.10 --- src/common/lib/libc/gen/ptree.c:1.9 Sun Jul 15 00:16:28 2012 +++ src/common/lib/libc/gen/ptree.c Sat Oct 6 22:15:09 2012 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1. #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 @@ 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.7 src/sys/sys/ptree.h:1.8 --- src/sys/sys/ptree.h:1.7 Sun Jul 15 00:16:28 2012 +++ src/sys/sys/ptree.h Sat Oct 6 22:15:09 2012 @@ -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 @@ 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)