diff options
author | hsu <hsu@FreeBSD.org> | 2003-02-08 01:44:09 +0000 |
---|---|---|
committer | hsu <hsu@FreeBSD.org> | 2003-02-08 01:44:09 +0000 |
commit | 7d8a20cfb408ed95a173c94b409ea9234af1ee1f (patch) | |
tree | 1c1d94baa562b374c44daa82b76e62b51604f0ff /sys | |
parent | d16e9e6edf003ccccf92dd21ef781d051906cad7 (diff) | |
download | FreeBSD-src-7d8a20cfb408ed95a173c94b409ea9234af1ee1f.zip FreeBSD-src-7d8a20cfb408ed95a173c94b409ea9234af1ee1f.tar.gz |
Make the radix tree code compilable in userland. Requested by ru.
Some style fixes requested by bde.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/radix.c | 4 | ||||
-rw-r--r-- | sys/net/radix.h | 20 |
2 files changed, 15 insertions, 9 deletions
diff --git a/sys/net/radix.c b/sys/net/radix.c index 17449c2..345ed58 100644 --- a/sys/net/radix.c +++ b/sys/net/radix.c @@ -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; diff --git a/sys/net/radix.h b/sys/net/radix.h index 0f4b20c..81a3766 100644 --- a/sys/net/radix.h +++ b/sys/net/radix.h @@ -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_ */ |