ia64/xen-unstable

view tools/vtpm_manager/util/hashtable_private.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children 06d84bf87159
line source
1 /*
2 * Copyright (c) 2005, Intel Corp
3 * Copyright (c) 2002, Christopher Clark <firstname.lastname@cl.cam.ac.uk>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * * Neither the name of the original author; nor the names of any contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
26 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
35 #ifndef __HASHTABLE_PRIVATE_CWC22_H__
36 #define __HASHTABLE_PRIVATE_CWC22_H__
38 #include "hashtable.h"
39 #ifdef HASHTABLE_THREADED
40 #include <pthread.h>
41 #endif
43 /*****************************************************************************/
44 struct entry
45 {
46 void *k, *v;
47 unsigned int h;
48 struct entry *next;
49 };
51 struct hashtable {
52 unsigned int tablelength;
53 struct entry **table;
54 unsigned int entrycount;
55 unsigned int loadlimit;
56 unsigned int primeindex;
57 unsigned int (*hashfn) (void *k);
58 int (*eqfn) (void *k1, void *k2);
59 #ifdef HASHTABLE_THREADED
60 pthread_mutex_t mutex;
61 #endif
62 };
64 /*****************************************************************************/
65 unsigned int
66 hash(struct hashtable *h, void *k);
68 /*****************************************************************************/
69 /* indexFor */
70 static inline unsigned int
71 indexFor(unsigned int tablelength, unsigned int hashvalue) {
72 return (hashvalue % tablelength);
73 };
75 /* Only works if tablelength == 2^N */
76 /*static inline unsigned int
77 indexFor(unsigned int tablelength, unsigned int hashvalue)
78 {
79 return (hashvalue & (tablelength - 1u));
80 }
81 */
83 /*****************************************************************************/
84 #define freekey(X) free(X)
85 /*define freekey(X) ; */
88 /*****************************************************************************/
90 #endif /* __HASHTABLE_PRIVATE_CWC22_H__*/