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