initial multicore gargbage collection, not finish yet
[IRC.git] / Robust / src / Runtime / garbage.c
index 1ef15582de2d50262d168fae510c5257221b4e91..e43dd3cb3e067e0f3cf025cc56530f096b4c3f8c 100644 (file)
 
 #define NUMPTRS 100
 
-#define INITIALHEAPSIZE 256*1024*1024
-#define GCPOINT(x) ((int)((x)*0.99))
+#define INITIALHEAPSIZE 256*1024*1024L
+#define GCPOINT(x) ((INTPTR)((x)*0.99))
 /* This define takes in how full the heap is initially and returns a new heap size to use */
-#define HEAPSIZE(x,y) ((int)(x+y))*2
+#define HEAPSIZE(x,y) ((INTPTR)(x+y))*2
 
 #ifdef TASK
 extern struct genhashtable * activetasks;
@@ -718,7 +718,7 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) {
       /* Need to allocate base heap */
       curr_heapbase=malloc(INITIALHEAPSIZE);
       if (curr_heapbase==NULL) {
-       printf("malloc failed\n");
+       printf("malloc failed.  Garbage collector couldn't get enough memory.  Try changing heap size.\n");
        exit(-1);
       }
       bzero(curr_heapbase, INITIALHEAPSIZE);
@@ -728,7 +728,7 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) {
 
       to_heapbase=malloc(INITIALHEAPSIZE);
       if (to_heapbase==NULL) {
-       printf("malloc failed\n");
+       printf("malloc failed.  Garbage collector couldn't get enough memory.  Try changing heap size.\n");
        exit(-1);
       }
       to_heaptop=to_heapbase+INITIALHEAPSIZE;
@@ -742,9 +742,9 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) {
 
     /* Grow the to heap if necessary */
     {
-      int curr_heapsize=curr_heaptop-curr_heapbase;
-      int to_heapsize=to_heaptop-to_heapbase;
-      int last_heapsize=0;
+      INTPTR curr_heapsize=curr_heaptop-curr_heapbase;
+      INTPTR to_heapsize=to_heaptop-to_heapbase;
+      INTPTR last_heapsize=0;
       if (lastgcsize>0) {
        last_heapsize=HEAPSIZE(lastgcsize, size);
        if ((last_heapsize&7)!=0)