xref: /titanic_41/usr/src/cmd/lvm/rpc.metamedd/med_hash.h (revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1994, 2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_MED_HASH_H
28 #define	_MED_HASH_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifndef NULL
37 #define	NULL	0
38 #endif	/* NULL */
39 
40 typedef struct item_t {
41     void *key;
42     int	  keyl;
43     void *data;
44     int	  datal;
45 } Item;
46 
47 #define	Null_Item ((Item *) NULL)
48 
49 typedef struct bucket_t {
50 	int nent;
51 	int nalloc;
52 	Item **itempp;
53 } Bucket;
54 
55 typedef struct cache_t {
56 	int	hsz;
57 	int	bsz;
58 	Bucket *bp;
59 	int (*hfunc)(void *, int, int);
60 	int (*cfunc)(void *, void *, int);
61 	void (*kffunc)(void *);
62 	void (*dffunc)(void *);
63 } Cache;
64 
65 #ifdef _KERNEL
66 #define	malloc	bkmem_alloc
67 #endif	/* _KERNEL */
68 
69 extern int	init_cache(Cache **cp, int hsz, int bsz,
70 			    int (*hfunc)(void *, int, int),
71 			    int (*cfunc)(void *, void *, int),
72 			    void (*kffunc)(void *), void (*dffunc)(void *));
73 extern int	add_cache(Cache *cp, Item *itemp);
74 extern Item	*lookup_cache(Cache *cp, void *datap, int datalen);
75 extern Item	*first_item(Cache *cp, int *bidx, int *iidx);
76 extern Item	*next_item(Cache *cp, int *bidx, int *iidx);
77 extern void	des_cache(Cache **cpp);
78 extern int	del_cache(Cache *cp, Item *itemp);
79 extern void	cache_stat(Cache *cp, char *tag);
80 extern void	pr_cache(Cache *cp, char *tag,
81 		    void (*pfunc)(void *, int, void *, int));
82 
83 #ifdef	__cplusplus
84 }
85 #endif
86 
87 #endif	/* _MED_HASH_H */
88