Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src ptree: add context argument. OK matt@
details: https://anonhg.NetBSD.org/src/rev/620a19a0c0f4
branches: trunk
changeset: 780076:620a19a0c0f4
user: rmind <rmind%NetBSD.org@localhost>
date: Wed Jul 11 00:19:28 2012 +0000
description:
ptree: add context argument. OK matt@
diffstat:
common/lib/libc/gen/ptree.c | 25 ++++++++++++-------------
sys/sys/ptree.h | 23 ++++++++++++++---------
2 files changed, 26 insertions(+), 22 deletions(-)
diffs (139 lines):
diff -r bbc48fa9be56 -r 620a19a0c0f4 common/lib/libc/gen/ptree.c
--- a/common/lib/libc/gen/ptree.c Tue Jul 10 22:50:41 2012 +0000
+++ b/common/lib/libc/gen/ptree.c Wed Jul 11 00:19:28 2012 +0000
@@ -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 @@
#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 @@
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 @@
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 @@
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 @@
}
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;
}
diff -r bbc48fa9be56 -r 620a19a0c0f4 sys/sys/ptree.h
--- a/sys/sys/ptree.h Tue Jul 10 22:50:41 2012 +0000
+++ b/sys/sys/ptree.h Wed Jul 11 00:19:28 2012 +0000
@@ -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 @@
#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 @@
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 *);
Home |
Main Index |
Thread Index |
Old Index