Fix tabbing.... Please fix your editors so they do tabbing correctly!!! (Spaces...
[IRC.git] / Robust / src / Runtime / garbage.h
1 #ifndef GARBAGE_H
2 #define GARBAGE_H
3 #ifdef STM
4 #include "stmlookup.h"
5 #endif
6 #ifdef JNI
7 #include "jni-private.h"
8 #endif
9
10 #define NUMPTRS 100
11
12 struct pointerblock {
13   void * ptrs[NUMPTRS];
14   struct pointerblock *next;
15 };
16
17 //Need to check if pointers are transaction pointers
18 //this also catches the special flag value of 1 for local copies
19 #ifdef DSTM
20 #define ENQUEUE(orig, dst) \
21   if ((!(((unsigned int)orig)&0x1))) { \
22     if (orig>=curr_heapbase&&orig<curr_heaptop) { \
23       void *copy; \
24       if (gc_createcopy(orig,&copy))                                                                           \
25         enqueue(copy);                                              \
26       dst=copy; \
27     } \
28   }
29 #elif defined(STM)
30 #define ENQUEUE(orig, dst) \
31   if (orig>=curr_heapbase&&orig<curr_heaptop) { \
32     void *copy; \
33     if (gc_createcopy(orig,&copy))                                                                       \
34       enqueue(copy);                                          \
35     dst=copy; \
36   }
37 #define SENQUEUE(orig, dst) \
38   { \
39     void *copy; \
40     if (gc_createcopy(orig,&copy))                                                                       \
41       enqueue(copy);                                          \
42     dst=copy; \
43   }
44 #elif defined(FASTCHECK)
45 #define ENQUEUE(orig, dst) \
46   if (((unsigned int)orig)!=1) { \
47     void *copy; \
48     if (gc_createcopy(orig,&copy))                                                                       \
49       enqueue(copy);                                          \
50     dst=copy; }
51 #else
52 #define ENQUEUE(orig, dst) \
53   if (orig!=NULL) { \
54     void *copy; \
55     if (gc_createcopy(orig,&copy))                                                                       \
56       enqueue(copy);                                           \
57     dst=copy; \
58   }
59 #endif
60
61 struct garbagelist {
62   int size;
63   struct garbagelist *next;
64   void * array[];
65 };
66
67 extern void * curr_heapbase;
68 extern void * curr_heapptr;
69 extern void * curr_heapgcpoint;
70 extern void * curr_heaptop;
71
72 extern void * to_heapbase;
73 extern void * to_heapptr;
74 extern void * to_heaptop;
75
76 struct listitem {
77   struct listitem * prev;
78   struct listitem * next;
79   struct garbagelist * stackptr;
80 #ifdef THREADS
81   struct lockvector * lvector;
82 #endif
83 #ifdef JNI
84   struct jnireferences ** jnirefs;
85 #endif
86 #ifdef STM
87   unsigned int tc_size;
88   cliststruct_t **tc_structs;
89   chashlistnode_t **tc_table;
90   chashlistnode_t **tc_list;
91   struct objlist * objlist;
92 #ifdef STMSTATS
93   struct objlist * lockedlist;
94 #endif
95 #endif
96 #if defined(THREADS)||defined(STM)||defined(MLP)
97   char **base;
98 #endif
99 #ifdef MLP
100   void *seseCommon;
101 #endif
102 };
103
104 #ifdef TASK
105 void fixtags();
106 extern struct pointerblock *taghead;
107 extern int tagindex;
108 #endif
109
110 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
111 extern int needtocollect;
112 void checkcollect(void * ptr);
113 void stopforgc(struct garbagelist * ptr);
114 void restartaftergc();
115 #endif
116 void * tomalloc(int size);
117 void collect(struct garbagelist *stackptr);
118 int gc_createcopy(void * orig, void **);
119 void * mygcmalloc(struct garbagelist * ptr, int size);
120 #endif
121 #ifdef STM
122 void fixtable(chashlistnode_t **, chashlistnode_t **, cliststruct_t **, unsigned int);
123 #endif
124
125 int within(void *ptr);