Make the radix tree code compilable in userland. Requested by ru.
Some style fixes requested by bde.
This commit is contained in:
parent
a8c8a6cbc0
commit
8480e03dd7
@ -40,6 +40,8 @@
|
||||
#ifndef _RADIX_H_
|
||||
#include <sys/param.h>
|
||||
#ifdef _KERNEL
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/domain.h>
|
||||
@ -1027,7 +1029,9 @@ rn_inithead(head, off)
|
||||
if (rnh == 0)
|
||||
return (0);
|
||||
Bzero(rnh, sizeof (*rnh));
|
||||
#ifdef _KERNEL
|
||||
RADIX_NODE_HEAD_LOCK_INIT(rnh);
|
||||
#endif
|
||||
*head = rnh;
|
||||
t = rn_newpair(rn_zeros, off, rnh->rnh_nodes);
|
||||
ttt = rnh->rnh_nodes + 2;
|
||||
|
@ -37,8 +37,10 @@
|
||||
#ifndef _RADIX_H_
|
||||
#define _RADIX_H_
|
||||
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#ifdef _KERNEL
|
||||
#include <sys/_lock.h>
|
||||
#include <sys/_mutex.h>
|
||||
#endif
|
||||
|
||||
#ifdef MALLOC_DECLARE
|
||||
MALLOC_DECLARE(M_RTABLE);
|
||||
@ -141,7 +143,9 @@ struct radix_node_head {
|
||||
void (*rnh_close) /* do something when the last ref drops */
|
||||
(struct radix_node *rn, struct radix_node_head *head);
|
||||
struct radix_node rnh_nodes[3]; /* empty tree for common case */
|
||||
struct mtx rnh_mtx;
|
||||
#ifdef _KERNEL
|
||||
struct mtx rnh_mtx; /* locks entire radix tree */
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef _KERNEL
|
||||
@ -157,12 +161,11 @@ struct radix_node_head {
|
||||
#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_NOWAIT))
|
||||
#define Free(p) free((caddr_t)p, M_RTABLE);
|
||||
|
||||
|
||||
#define RADIX_NODE_HEAD_LOCK_INIT(rnh) \
|
||||
#define RADIX_NODE_HEAD_LOCK_INIT(rnh) \
|
||||
mtx_init(&(rnh)->rnh_mtx, "radix node head", NULL, MTX_DEF | MTX_RECURSE)
|
||||
#define RADIX_NODE_HEAD_LOCK(rnh) mtx_lock(&(rnh)->rnh_mtx)
|
||||
#define RADIX_NODE_HEAD_UNLOCK(rnh) mtx_unlock(&(rnh)->rnh_mtx)
|
||||
#define RADIX_NODE_HEAD_DESTROY(rnh) mtx_destroy(&(rnh)->rnh_mtx)
|
||||
#define RADIX_NODE_HEAD_LOCK(rnh) mtx_lock(&(rnh)->rnh_mtx)
|
||||
#define RADIX_NODE_HEAD_UNLOCK(rnh) mtx_unlock(&(rnh)->rnh_mtx)
|
||||
#define RADIX_NODE_HEAD_DESTROY(rnh) mtx_destroy(&(rnh)->rnh_mtx)
|
||||
#define RADIX_NODE_HEAD_LOCK_ASSERT(rnh) mtx_assert(&(rnh)->rnh_mtx, MA_OWNED)
|
||||
#endif /* _KERNEL */
|
||||
|
||||
@ -178,5 +181,4 @@ struct radix_node
|
||||
struct radix_node_head *head),
|
||||
*rn_match(void *, struct radix_node_head *);
|
||||
|
||||
|
||||
#endif /* _RADIX_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user