Fix tabbing.... Please fix your editors so they do tabbing correctly!!! (Spaces...
[IRC.git] / Robust / src / Runtime / DSTM / interface / altprelookup.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 PLOADFACTOR 0.25
10 #define PHASH_SIZE 1024
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
19 struct prelockarray {
20   volatile unsigned int lock;
21   int buf[15];
22 };
23
24 #define PRENUMLOCKS 16
25 #define PRELOCKMASK (PRENUMLOCKS-1)
26
27
28 struct objstr;
29
30 typedef struct prehashtable {
31   prehashlistnode_t *table;     // points to beginning of hash table
32   unsigned int size;
33   unsigned int mask;
34   unsigned int numelements;
35   unsigned int threshold;
36   double loadfactor;
37   struct prelockarray larray[PRENUMLOCKS];
38 } prehashtable_t;
39
40 /* Prototypes for hash*/
41 unsigned int prehashCreate(unsigned int size, float loadfactor);
42 unsigned int prehashFunction(unsigned int key);
43 void prehashInsert(unsigned int key, void *val);
44 void *prehashSearch(unsigned int key); //returns val, NULL if not found
45 unsigned int prehashRemove(unsigned int key); //returns -1 if not found
46 unsigned int prehashResize(unsigned int newsize);
47 void prehashClear();
48 /* end hash */
49
50 #endif
51