dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libsip / common / sip_hash.h
blob00072201e6b5c3468377da6aa93075e8a03ecb02
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SIP_HASH_H
28 #define _SIP_HASH_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #include <pthread.h>
38 /* A prime number */
39 #define SIP_HASH_SZ 6037
41 #define SIP_DIGEST_TO_HASH(digest) \
42 ((digest[0] + digest[1] + digest[2] + digest[3] + digest[4] + \
43 digest[5] + digest[6] + digest[7]) % SIP_HASH_SZ)
45 /* An entry in the hash table, sip_obj is opaque */
46 typedef struct sip_hash_obj_s {
47 void *sip_obj;
48 struct sip_hash_obj_s *next_obj;
49 struct sip_hash_obj_s *prev_obj;
50 } sip_hash_obj_t;
53 /* A hash list in the table */
54 typedef struct sip_hash_s {
55 sip_hash_obj_t *hash_head;
56 sip_hash_obj_t *hash_tail;
57 int hash_count;
58 pthread_mutex_t sip_hash_mutex;
59 }sip_hash_t;
61 int sip_hash_add(sip_hash_t *, void *, int);
62 void *sip_hash_find(sip_hash_t *, void *, int,
63 boolean_t (*)(void *, void *));
64 void sip_walk_hash(sip_hash_t *, void (*)(void *, void *), void *);
65 void sip_hash_delete(sip_hash_t *, void *, int,
66 boolean_t (*)(void *, void *, int *));
67 void sip_hash_init();
69 #ifdef __cplusplus
71 #endif
73 #endif /* _SIP_HASH_H */