38fbb9d69800baca4cfe48c2a5f760f1860cb2d0
[IRC.git] / Robust / src / Runtime / oooJava / hashRCR.h
1 #ifndef _HASHRCR_H_
2 #define _HASHRCR_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 #ifndef INTPTR
8 #ifdef BIT64
9 #define INTPTR long
10 #else
11 #define INTPTR int
12 #endif
13 #endif
14
15 //TODO consider changing loadfactor?
16 #define CLOADFACTOR 0.25
17 #define CHASH_SIZE 1024
18
19 #define INLINE    inline __attribute__((always_inline))
20
21 typedef struct chashlistnode {
22   void * keyAndVal;     //this can be cast to another type or used to point to a larger structure
23   struct chashlistnode *next;
24   struct chashlistnode *lnext;
25 } chashlistnode_t;
26
27 typedef struct chashtable {
28   chashlistnode_t *table;       // points to beginning of hash table
29   unsigned int size;
30   unsigned int mask;
31   unsigned int numelements;
32   unsigned int threshold;
33   double loadfactor;
34 } chashtable_t;
35
36 #define NUMCLIST 250
37 typedef struct clist {
38   struct chashlistnode array[NUMCLIST];
39   int num;
40   struct clist *next;
41 } cliststruct_t;
42
43
44 void hashRCRCreate(unsigned int size, double loadfactor);
45 void hashRCRInsert(void * addrIn);
46 void * hashRCRSearch(void * key);
47 unsigned int hashRCRResize(unsigned int newsize);
48 void hashRCRDelete();
49 void hashRCRreset();
50
51 //TODO add __thread after extern for all of these
52 //TODO consider changing names to avoid conflicts
53 extern chashlistnode_t *c_table;
54 extern chashlistnode_t *c_list;
55 extern unsigned int c_size;
56 extern unsigned INTPTR c_mask;
57 extern unsigned int c_numelements;
58 extern unsigned int c_threshold;
59 extern double c_loadfactor;
60 extern cliststruct_t *c_structs;
61
62 #endif