#endif
#ifdef MULTICORE_GC
-struct freeMemItem * findFreeMemChunk(int coren,
- int isize,
- int * tofindb) {
+struct freeMemItem * findFreeMemChunk_I(int coren,
+ int isize,
+ int * tofindb) {
struct freeMemItem * freemem = bamboo_free_mem_list->head;
struct freeMemItem * prev = NULL;
int i = 0;
} while(freemem != NULL);
return freemem;
-} // struct freeMemItem * findFreeMemChunk(int, int, int *)
+} // struct freeMemItem * findFreeMemChunk_I(int, int, int *)
-void * localmalloc(int tofindb,
- int isize,
- struct freeMemItem * freemem,
- int * allocsize) {
+void * localmalloc_I(int tofindb,
+ int isize,
+ struct freeMemItem * freemem,
+ int * allocsize) {
void * mem = NULL;
int startb = freemem->startblock;
int endb = freemem->endblock;
BLOCKINDEX(((int)mem)-1, &(freemem->endblock));
} else {
struct freeMemItem * tmp =
- (struct freeMemItem *)RUNMALLOC(sizeof(struct freeMemItem));
+ (struct freeMemItem *)RUNMALLOC_I(sizeof(struct freeMemItem));
tmp->ptr = (int)mem+*allocsize;
tmp->size = freemem->ptr+freemem->size-(int)mem-*allocsize;
BLOCKINDEX(tmp->ptr, &(tmp->startblock));
BLOCKINDEX(((int)mem-1), &(freemem->endblock));
}
return mem;
-} // void * localmalloc(int, int, struct freeMemItem *, int *)
+} // void * localmalloc_I(int, int, struct freeMemItem *, int *)
-void * globalmalloc(int isize,
- struct freeMemItem * freemem,
- int * allocsize) {
+void * globalmalloc_I(int isize,
+ struct freeMemItem * freemem,
+ int * allocsize) {
void * mem = (void *)(freemem->ptr);
// check the remaining space in this block
int remain = (int)(mem-(BAMBOO_BASE_VA));
freemem->ptr = ((void*)freemem->ptr) + (*allocsize);
freemem->size -= *allocsize;
return mem;
-} // void * globalmalloc(int, struct freeMemItem *, int *)
+} // void * globalmalloc_I(int, struct freeMemItem *, int *)
#endif
// malloc from the shared memory
-void * smemalloc(int coren,
- int size,
- int * allocsize) {
+void * smemalloc_I(int coren,
+ int size,
+ int * allocsize) {
void * mem = NULL;
#ifdef MULTICORE_GC
int isize = size+(BAMBOO_CACHE_LINE_SIZE);
int toallocate = (isize>(BAMBOO_SMEM_SIZE)) ? (isize):(BAMBOO_SMEM_SIZE);
// go through free mem list for suitable chunks
int tofindb = 0;
- struct freeMemItem * freemem = findFreeMemChunk(coren, isize, &tofindb);
+ struct freeMemItem * freemem = findFreeMemChunk_I(coren, isize, &tofindb);
// allocate shared mem if available
if(freemem != NULL) {
switch(bamboo_smem_mode) {
case SMEMLOCAL: {
- mem = localmalloc(tofindb, isize, freemem, allocsize);
+ mem = localmalloc_I(tofindb, isize, freemem, allocsize);
break;
}
int endb = freemem->endblock;
if(startb > tofindb) {
// malloc on global mem
- mem = globalmalloc(isize, freemem, allocsize);
+ mem = globalmalloc_I(isize, freemem, allocsize);
} else {
// malloc on local mem
- mem = localmalloc(tofindb, isize, freemem, allocsize);
+ mem = localmalloc_I(tofindb, isize, freemem, allocsize);
}
break;
}
}
case SMEMGLOBAL: {
- mem = globalmalloc(isize,freemem, allocsize);
+ mem = globalmalloc_I(isize,freemem, allocsize);
break;
}
#endif
}
return mem;
-} // void * smemalloc(int, int, int)
+} // void * smemalloc_I(int, int, int)
// receive object transferred from other cores
// or the terminate message from other cores
}
#endif
int allocsize = 0;
- void * mem = smemalloc(msgdata[2], msgdata[1], &allocsize);
+ void * mem = smemalloc_I(msgdata[2], msgdata[1], &allocsize);
if(mem == NULL) {
break;
}