start of new file
[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 #include "dstm.h"
8
9 #define LOADFACTOR 0.5
10 #define HASH_SIZE 100
11
12 typedef struct prehashlistnode {
13         unsigned int key;
14         void *val; //this can be cast to another type or used to point to a larger structure
15         struct prehashlistnode *next;
16 } prehashlistnode_t;
17
18 struct objstr;
19
20 typedef struct prehashtable {
21   prehashlistnode_t *table;     // points to beginning of hash table
22   unsigned int size;
23   unsigned int numelements;
24   float loadfactor;
25   pthread_mutex_t lock;
26   pthread_mutexattr_t prefetchmutexattr;
27   pthread_cond_t cond;
28   struct objstr *hack2;
29   struct objstr *hack;
30 } prehashtable_t;
31
32 /* Prototypes for hash*/
33 unsigned int prehashCreate(unsigned int size, float loadfactor);
34 unsigned int prehashFunction(unsigned int key);
35 unsigned int prehashInsert(unsigned int key, void *val);
36 void *prehashSearch(unsigned int key); //returns val, NULL if not found
37 unsigned int prehashRemove(unsigned int key); //returns -1 if not found
38 unsigned int prehashResize(unsigned int newsize);
39 void prehashClear();
40 /* end hash */
41
42 #endif
43