Change the local hashtable for recording the pointer mapping info used in the gc...
[IRC.git] / Robust / src / Runtime / MGCHash.h
1 #ifndef MGCHASH_H
2 #define MGCHASH_H
3
4 #ifndef bool
5 #define bool int
6 #endif
7
8 #ifndef true
9 #define true 1
10 #endif
11
12 #ifndef false
13 #define false 0
14 #endif
15
16 #ifndef INLINE
17 #define INLINE    inline __attribute__((always_inline))
18 #endif
19
20 #include "mem.h"
21
22 /* mgchash *********************************************************/
23 typedef struct mgchashlistnode {
24   void * key;
25   void * val; //this can be cast to another type or used to point to a
26               //larger structure
27   struct mgchashlistnode *next;
28 } mgchashlistnode_t;
29
30 #define NUMMGCLIST 250
31 typedef struct mgclist {
32   struct mgchashlistnode array[NUMMGCLIST];
33   int num;
34   struct mgclist *next;
35 } mgcliststruct_t;
36
37 typedef struct mgchashtable {
38   mgchashlistnode_t * table;       // points to beginning of hash table
39   mgchashlistnode_t * list;
40   mgcliststruct_t * structs;
41   unsigned int size;
42   unsigned int mask;
43   unsigned int numelements;
44   unsigned int threshold;
45   double loadfactor;
46 } mgchashtable_t;
47
48 mgchashtable_t * mgchashCreate(unsigned int size, double loadfactor);
49 void mgchashInsert(mgchashtable_t * tbl, void * key, void *val);
50 void * mgchashSearch(mgchashtable_t * tbl, void * key);
51 unsigned int mgchashResize(mgchashtable_t * tbl, unsigned int newsize);
52 #ifdef MULTICORE_GC
53 mgchashtable_t * mgchashCreate_I(unsigned int size, double loadfactor);
54 void mgchashInsert_I(mgchashtable_t * tbl, void * key, void *val);
55 unsigned int mgchashResize_I(mgchashtable_t * tbl, unsigned int newsize);
56 #endif
57 void mgchashDelete(mgchashtable_t * tbl);
58 void mgchashreset(mgchashtable_t * tbl);
59
60
61 /** MGCHash *******************************************************************/
62 struct MGCHash * allocateMGCHash(int size, int conflicts);
63 void freeMGCHash(struct MGCHash *);
64
65 //void MGCHashrehash(struct MGCHash * thisvar);
66 int MGCHashadd(struct MGCHash *, int data);
67 #ifdef MULTICORE
68 struct MGCHash * allocateMGCHash_I(int size, int conflicts);
69 int MGCHashadd_I(struct MGCHash *, int data);
70 #endif
71 int MGCHashcontains(struct MGCHash *,int data);
72
73 struct MGCHash {
74   int num4conflicts;
75   int size;
76   struct MGCNode *bucket;
77 };
78
79 /* MGCHashException  *************************************************/
80
81 struct MGCNode {
82   struct MGCNode * next;
83   int data;
84 };
85
86 #endif