1*5c51f124SMoriah Waterland /* 2*5c51f124SMoriah Waterland * CDDL HEADER START 3*5c51f124SMoriah Waterland * 4*5c51f124SMoriah Waterland * The contents of this file are subject to the terms of the 5*5c51f124SMoriah Waterland * Common Development and Distribution License (the "License"). 6*5c51f124SMoriah Waterland * You may not use this file except in compliance with the License. 7*5c51f124SMoriah Waterland * 8*5c51f124SMoriah Waterland * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5c51f124SMoriah Waterland * or http://www.opensolaris.org/os/licensing. 10*5c51f124SMoriah Waterland * See the License for the specific language governing permissions 11*5c51f124SMoriah Waterland * and limitations under the License. 12*5c51f124SMoriah Waterland * 13*5c51f124SMoriah Waterland * When distributing Covered Code, include this CDDL HEADER in each 14*5c51f124SMoriah Waterland * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5c51f124SMoriah Waterland * If applicable, add the following below this CDDL HEADER, with the 16*5c51f124SMoriah Waterland * fields enclosed by brackets "[]" replaced with your own identifying 17*5c51f124SMoriah Waterland * information: Portions Copyright [yyyy] [name of copyright owner] 18*5c51f124SMoriah Waterland * 19*5c51f124SMoriah Waterland * CDDL HEADER END 20*5c51f124SMoriah Waterland */ 21*5c51f124SMoriah Waterland 22*5c51f124SMoriah Waterland /* 23*5c51f124SMoriah Waterland * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*5c51f124SMoriah Waterland * Use is subject to license terms. 25*5c51f124SMoriah Waterland */ 26*5c51f124SMoriah Waterland 27*5c51f124SMoriah Waterland #ifndef _NHASH_H 28*5c51f124SMoriah Waterland #define _NHASH_H 29*5c51f124SMoriah Waterland 30*5c51f124SMoriah Waterland 31*5c51f124SMoriah Waterland #ifdef __cplusplus 32*5c51f124SMoriah Waterland extern "C" { 33*5c51f124SMoriah Waterland #endif 34*5c51f124SMoriah Waterland 35*5c51f124SMoriah Waterland #ifndef NULL 36*5c51f124SMoriah Waterland #define NULL 0 37*5c51f124SMoriah Waterland #endif /* NULL */ 38*5c51f124SMoriah Waterland 39*5c51f124SMoriah Waterland typedef struct item_t { 40*5c51f124SMoriah Waterland void *key; 41*5c51f124SMoriah Waterland int keyl; 42*5c51f124SMoriah Waterland void *data; 43*5c51f124SMoriah Waterland int datal; 44*5c51f124SMoriah Waterland } Item; 45*5c51f124SMoriah Waterland 46*5c51f124SMoriah Waterland #define Null_Item ((Item *) NULL) 47*5c51f124SMoriah Waterland 48*5c51f124SMoriah Waterland typedef struct bucket_t { 49*5c51f124SMoriah Waterland int nent; 50*5c51f124SMoriah Waterland int nalloc; 51*5c51f124SMoriah Waterland Item **itempp; 52*5c51f124SMoriah Waterland } Bucket; 53*5c51f124SMoriah Waterland 54*5c51f124SMoriah Waterland typedef struct cache_t { 55*5c51f124SMoriah Waterland int hsz; 56*5c51f124SMoriah Waterland int bsz; 57*5c51f124SMoriah Waterland Bucket *bp; 58*5c51f124SMoriah Waterland int (*hfunc)(void *, int, int); 59*5c51f124SMoriah Waterland int (*cfunc)(void *, void *, int); 60*5c51f124SMoriah Waterland } Cache; 61*5c51f124SMoriah Waterland 62*5c51f124SMoriah Waterland #ifdef _KERNEL 63*5c51f124SMoriah Waterland #define malloc bkmem_alloc 64*5c51f124SMoriah Waterland #endif /* _KERNEL */ 65*5c51f124SMoriah Waterland 66*5c51f124SMoriah Waterland extern int init_cache(Cache **cp, int hsz, int bsz, 67*5c51f124SMoriah Waterland int (*hfunc)(void *, int, int), int (*cfunc)(void *, void *, int)); 68*5c51f124SMoriah Waterland extern int add_cache(Cache *cp, Item *itemp); 69*5c51f124SMoriah Waterland extern Item *lookup_cache(Cache *cp, void *datap, int datalen); 70*5c51f124SMoriah Waterland 71*5c51f124SMoriah Waterland #ifdef __cplusplus 72*5c51f124SMoriah Waterland } 73*5c51f124SMoriah Waterland #endif 74*5c51f124SMoriah Waterland 75*5c51f124SMoriah Waterland #endif /* _NHASH_H */ 76