bug fixes
[IRC.git] / Robust / src / Runtime / DSTM / interface / prelookup.h
1 #ifndef _PRELOOKUP_H_
2 #define _PRELOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <pthread.h>
7
8 #define LOADFACTOR 0.75
9 #define HASH_SIZE 100
10
11 typedef struct prehashlistnode {
12         unsigned int key;
13         void *val; //this can be cast to another type or used to point to a larger structure
14         struct prehashlistnode *next;
15 } prehashlistnode_t;
16
17 typedef struct prehashtable {
18         prehashlistnode_t *table;       // points to beginning of hash table
19         unsigned int size;
20         unsigned int numelements;
21         float loadfactor;
22         pthread_mutex_t lock;
23         pthread_mutexattr_t prefetchmutexattr;
24         pthread_cond_t cond;
25 } prehashtable_t;
26
27 /* Prototypes for hash*/
28 unsigned int prehashCreate(unsigned int size, float loadfactor);
29 unsigned int prehashFunction(unsigned int key);
30 unsigned int prehashInsert(unsigned int key, void *val);
31 void *prehashSearch(unsigned int key); //returns val, NULL if not found
32 unsigned int prehashRemove(unsigned int key); //returns -1 if not found
33 unsigned int prehashResize(unsigned int newsize);
34 /* end hash */
35
36 #endif
37