Add HASH_PSLIST (pslist(9)) type for hashinit()

This commit is contained in:
ozaki-r 2016-07-06 05:20:48 +00:00
parent 062c64dfec
commit 058d974b09
2 changed files with 16 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_hash.c,v 1.6 2014/05/29 21:15:55 rmind Exp $ */
/* $NetBSD: subr_hash.c,v 1.7 2016/07/06 05:20:48 ozaki-r Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 1993
@ -37,12 +37,13 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_hash.c,v 1.6 2014/05/29 21:15:55 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_hash.c,v 1.7 2016/07/06 05:20:48 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/bitops.h>
#include <sys/kmem.h>
#include <sys/systm.h>
#include <sys/pslist.h>
static size_t
hash_list_size(enum hashtype htype)
@ -50,12 +51,16 @@ hash_list_size(enum hashtype htype)
LIST_HEAD(, generic) *hashtbl_list;
SLIST_HEAD(, generic) *hashtbl_slist;
TAILQ_HEAD(, generic) *hashtbl_tailq;
struct pslist_head *hashtbl_pslist;
size_t esize;
switch (htype) {
case HASH_LIST:
esize = sizeof(*hashtbl_list);
break;
case HASH_PSLIST:
esize = sizeof(*hashtbl_pslist);
break;
case HASH_SLIST:
esize = sizeof(*hashtbl_slist);
break;
@ -80,6 +85,7 @@ hashinit(u_int elements, enum hashtype htype, bool waitok, u_long *hashmask)
LIST_HEAD(, generic) *hashtbl_list;
SLIST_HEAD(, generic) *hashtbl_slist;
TAILQ_HEAD(, generic) *hashtbl_tailq;
struct pslist_head *hashtbl_pslist;
u_long hashsize, i;
size_t esize;
void *p;
@ -103,6 +109,11 @@ hashinit(u_int elements, enum hashtype htype, bool waitok, u_long *hashmask)
for (i = 0; i < hashsize; i++)
LIST_INIT(&hashtbl_list[i]);
break;
case HASH_PSLIST:
hashtbl_pslist = p;
for (i = 0; i < hashsize; i++)
PSLIST_INIT(&hashtbl_pslist[i]);
break;
case HASH_SLIST:
hashtbl_slist = p;
for (i = 0; i < hashsize; i++)

View File

@ -1,4 +1,4 @@
/* $NetBSD: systm.h,v 1.270 2016/01/23 20:44:06 christos Exp $ */
/* $NetBSD: systm.h,v 1.271 2016/07/06 05:20:48 ozaki-r Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@ -177,7 +177,8 @@ int eopnotsupp(void);
enum hashtype {
HASH_LIST,
HASH_SLIST,
HASH_TAILQ
HASH_TAILQ,
HASH_PSLIST
};
#ifdef _KERNEL