summaryrefslogtreecommitdiff
path: root/sys/kern/kern_subr.c
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1995-04-04 02:01:13 +0000
committerDavid Greenman <dg@FreeBSD.org>1995-04-04 02:01:13 +0000
commit22e53424b295b4155e4c090aa469d652faaaa4d2 (patch)
tree68f8b7afc54e8eb8e88174f20ec57f9253dd8ae0 /sys/kern/kern_subr.c
parent2e837708b18d4e2441cf01000071a472b8a00366 (diff)
Notes
Diffstat (limited to 'sys/kern/kern_subr.c')
-rw-r--r--sys/kern/kern_subr.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c
index 0c1d970493bb..c1912394176f 100644
--- a/sys/kern/kern_subr.c
+++ b/sys/kern/kern_subr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_subr.c 8.3 (Berkeley) 1/21/94
- * $Id: kern_subr.c,v 1.3 1994/08/02 07:42:14 davidg Exp $
+ * $Id: kern_subr.c,v 1.4 1995/02/12 09:11:47 davidg Exp $
*/
#include <sys/param.h>
@@ -90,6 +90,8 @@ uiomove(cp, n, uio)
else
bcopy(iov->iov_base, (caddr_t)cp, cnt);
break;
+ case UIO_NOCOPY:
+ break;
}
iov->iov_base += cnt;
iov->iov_len -= cnt;
@@ -213,3 +215,36 @@ hashinit(elements, type, hashmask)
*hashmask = hashsize - 1;
return (hashtbl);
}
+
+#define NPRIMES 24
+static int primes[] = { 61, 127, 251, 509, 761, 1021, 1531, 2039, 2557,
+ 3067, 3583, 4093, 4603, 5119, 5623, 6143, 6653,
+ 7159, 7673, 8191, 12281, 16381, 24571, 32749 };
+
+/*
+ * General routine to allocate a prime number sized hash table.
+ */
+void *
+phashinit(elements, type, nentries)
+ int elements, type;
+ u_long *nentries;
+{
+ long hashsize;
+ LIST_HEAD(generic, generic) *hashtbl;
+ int i;
+
+ if (elements <= 0)
+ panic("hashinit: bad cnt");
+ for (i = 1, hashsize = primes[1]; hashsize <= elements;) {
+ i++;
+ if (i == NPRIMES)
+ break;
+ hashsize = primes[i];
+ }
+ hashsize = primes[i - 1];
+ hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl), type, M_WAITOK);
+ for (i = 0; i < hashsize; i++)
+ LIST_INIT(&hashtbl[i]);
+ *nentries = hashsize;
+ return (hashtbl);
+}