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