Module Name: src Committed By: rmind Date: Wed Jul 11 00:19:28 UTC 2012
Modified Files: src/common/lib/libc/gen: ptree.c src/sys/sys: ptree.h Log Message: ptree: add context argument. OK matt@ To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/gen/ptree.c cvs rdiff -u -r1.5 -r1.6 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 src/common/lib/libc/gen/ptree.c:1.6 --- src/common/lib/libc/gen/ptree.c:1.5 Sun Jun 7 03:12:40 2009 +++ src/common/lib/libc/gen/ptree.c Wed Jul 11 00:19:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $ */ +/* $NetBSD: ptree.c,v 1.6 2012/07/11 00:19:28 rmind 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 2009/06/07 03:12:40 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.6 2012/07/11 00:19:28 rmind 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 2009/06/07 03:12:40 yamt Exp $"); +__RCSID("$NetBSD: ptree.c,v 1.6 2012/07/11 00:19:28 rmind Exp $"); #endif /* _KERNEL || _STANDALONE */ #ifdef _LIBC @@ -124,8 +124,8 @@ ptree_matchnode(const pt_tree_t *pt, con pt_bitoff_t *bitoff_p, pt_slot_t *slots_p) { return (*pt->pt_ops->ptto_matchnode)(NODETOKEY(pt, target), - (ptn != NULL ? NODETOKEY(pt, ptn) : NULL), max_bitoff, - bitoff_p, slots_p); + (ptn != NULL ? NODETOKEY(pt, ptn) : NULL), + max_bitoff, bitoff_p, slots_p, pt->pt_context); } static inline pt_slot_t @@ -136,8 +136,7 @@ ptree_testnode(const pt_tree_t *pt, cons if (bitlen == 0) return PT_SLOT_ROOT; return (*pt->pt_ops->ptto_testnode)(NODETOKEY(pt, target), - PTN_BRANCH_BITOFF(ptn), - bitlen); + PTN_BRANCH_BITOFF(ptn), bitlen, pt->pt_context); } static inline bool @@ -145,15 +144,14 @@ ptree_matchkey(const pt_tree_t *pt, cons const pt_node_t *ptn, pt_bitoff_t bitoff, pt_bitlen_t bitlen) { return (*pt->pt_ops->ptto_matchkey)(key, NODETOKEY(pt, ptn), - bitoff, bitlen); + bitoff, bitlen, pt->pt_context); } static inline pt_slot_t ptree_testkey(const pt_tree_t *pt, const void *key, const pt_node_t *ptn) { - return (*pt->pt_ops->ptto_testkey)(key, - PTN_BRANCH_BITOFF(ptn), - PTN_BRANCH_BITLEN(ptn)); + return (*pt->pt_ops->ptto_testkey)(key, PTN_BRANCH_BITOFF(ptn), + PTN_BRANCH_BITLEN(ptn), pt->pt_context); } static inline void @@ -166,12 +164,13 @@ ptree_set_position(uintptr_t node, pt_sl } void -ptree_init(pt_tree_t *pt, const pt_tree_ops_t *ops, size_t node_offset, - size_t key_offset) +ptree_init(pt_tree_t *pt, const pt_tree_ops_t *ops, void *context, + size_t node_offset, size_t key_offset) { memset(pt, 0, sizeof(*pt)); pt->pt_node_offset = node_offset; pt->pt_key_offset = key_offset; + pt->pt_context = context; pt->pt_ops = ops; } Index: src/sys/sys/ptree.h diff -u src/sys/sys/ptree.h:1.5 src/sys/sys/ptree.h:1.6 --- src/sys/sys/ptree.h:1.5 Fri Mar 9 15:35:28 2012 +++ src/sys/sys/ptree.h Wed Jul 11 00:19:28 2012 @@ -1,4 +1,5 @@ -/* $NetBSD: ptree.h,v 1.5 2012/03/09 15:35:28 christos Exp $ */ +/* $NetBSD: ptree.h,v 1.6 2012/07/11 00:19:28 rmind Exp $ */ + /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -27,6 +28,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + #ifndef _SYS_PTREE_H_ #define _SYS_PTREE_H_ @@ -155,12 +157,14 @@ typedef struct pt_node { #endif /* _PT_PRIVATE */ typedef struct pt_tree_ops { - bool (*ptto_matchnode)(const void *, const void *, pt_bitoff_t, - pt_bitoff_t *, pt_slot_t *); - bool (*ptto_matchkey)(const void *, const void *, pt_bitoff_t, - pt_bitlen_t); - pt_slot_t (*ptto_testnode)(const void *, pt_bitoff_t, pt_bitlen_t); - pt_slot_t (*ptto_testkey)(const void *, pt_bitoff_t, pt_bitlen_t); + bool (*ptto_matchnode)(const void *, const void *, + pt_bitoff_t, pt_bitoff_t *, pt_slot_t *, void *); + bool (*ptto_matchkey)(const void *, const void *, + pt_bitoff_t, pt_bitlen_t, void *); + pt_slot_t (*ptto_testnode)(const void *, + pt_bitoff_t, pt_bitlen_t, void *); + pt_slot_t (*ptto_testkey)(const void *, + pt_bitoff_t, pt_bitlen_t, void *); } pt_tree_ops_t; typedef struct pt_tree { @@ -170,13 +174,14 @@ typedef struct pt_tree { const pt_tree_ops_t *pt_ops; size_t pt_node_offset; size_t pt_key_offset; - uintptr_t pt_spare[4]; + void *pt_context; + uintptr_t pt_spare[3]; } pt_tree_t; #define PT_FILTER_MASK 0x00000001 /* node is a mask */ typedef bool (*pt_filter_t)(void *, const void *, int); -void ptree_init(pt_tree_t *, const pt_tree_ops_t *, size_t, size_t); +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); void * ptree_find_filtered_node(pt_tree_t *, void *, pt_filter_t, void *);