xref: /illumos-gate/usr/src/lib/udapl/udapl_tavor/include/dapl_hash.h (revision 9e39c5ba00a55fa05777cc94b148296af305e135)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24  */
25 
26 /*
27  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 /*
32  *
33  * HEADER: dapl_hash.h
34  *
35  * PURPOSE: Utility defs & routines for the hash data structure
36  *
37  * $Id: dapl_hash.h,v 1.4 2003/06/13 12:21:09 sjs2 Exp $
38  */
39 
40 #ifndef _DAPL_HASH_H_
41 #define	_DAPL_HASH_H_
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #include "dapl.h"
48 
49 
50 /*
51  *
52  * Defines
53  *
54  */
55 
56 /*
57  * Hash table size.
58  *
59  * Default is small; use the larger sample values for hash tables
60  * known to be heavily used.  The sample values chosen are the
61  * largest primes below 2^8, 2^9, and 2^10.
62  */
63 #define	DAPL_DEF_HASHSIZE	251
64 #define	DAPL_MED_HASHSIZE	509
65 #define	DAPL_LRG_HASHSIZE	1021
66 
67 #define	DAPL_HASH_TABLE_DEFAULT_CAPACITY	DAPL_DEF_HASHSIZE
68 
69 typedef enum {
70 	DAPL_HASH_ITERATE_INIT = 1,
71 	DAPL_HASH_ITERATE_NEXT
72 } DAPL_HASH_ITERATOR;
73 
74 
75 /*
76  *
77  * Function Prototypes
78  *
79  */
80 
81 extern DAT_RETURN
82 dapls_hash_create(
83     IN DAT_COUNT capacity,
84     IN DAT_BOOLEAN locking_required,
85     OUT DAPL_HASH_TABLE **pp_table);
86 
87 extern DAT_RETURN
88 dapls_hash_free(
89     IN DAPL_HASH_TABLE *p_table);
90 
91 extern DAT_RETURN
92 dapls_hash_size(
93     IN DAPL_HASH_TABLE *p_table,
94     OUT DAT_COUNT *p_size);
95 
96 extern DAT_RETURN
97 dapls_hash_insert(
98     IN DAPL_HASH_TABLE *p_table,
99     IN DAPL_HASH_KEY key,
100     IN DAPL_HASH_DATA data);
101 
102 extern DAT_RETURN
103 dapls_hash_search(
104     IN DAPL_HASH_TABLE *p_table,
105     IN DAPL_HASH_KEY key,
106     OUT DAPL_HASH_DATA *p_data);
107 
108 extern DAT_RETURN
109 dapls_hash_remove(
110     IN DAPL_HASH_TABLE *p_table,
111     IN DAPL_HASH_KEY key,
112     OUT DAPL_HASH_DATA *p_data);
113 
114 extern DAT_RETURN
115 dapls_hash_iterate(
116     IN DAPL_HASH_TABLE *p_table,
117     IN DAPL_HASH_ITERATOR op,
118     OUT DAPL_HASH_DATA *p_data);
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* _DAPL_HASH_H_ */
125