5 #include "runtime_arch.h"
7 void * mycalloc(int m, int size) {
10 BAMBOO_START_CRITICAL_SECTION_MEM();
11 p = BAMBOO_LOCAL_MEM_CALLOC(m, isize); // calloc(m, isize);
15 BAMBOO_CLOSE_CRITICAL_SECTION_MEM();
20 void * mycalloc_share(struct garbagelist * stackptr, int m, int size) {
22 int isize = 2*BAMBOO_CACHE_LINE_SIZE-4+(size-1)&(~BAMBOO_CACHE_LINE_MASK);
24 BAMBOO_START_CRITICAL_SECTION_MEM();
25 p = BAMBOO_SHARE_MEM_CALLOC_I(m, isize); // calloc(m, isize);
27 // no more global shared memory
28 BAMBOO_CLOSE_CRITICAL_SECTION_MEM();
32 // try to malloc again
35 BAMBOO_CLOSE_CRITICAL_SECTION_MEM();
36 void * alignedp = (void *)(BAMBOO_CACHE_LINE_SIZE+((int)p-1)&(~BAMBOO_CACHE_LINE_MASK));
37 memset(p, -2, (alignedp - p));
38 memset(alignedp + size, -2, p + isize - alignedp - size);
42 void * mycalloc_share(int m, int size) {
44 int isize = 2*BAMBOO_CACHE_LINE_SIZE-4+(size-1)&(~BAMBOO_CACHE_LINE_MASK);
45 BAMBOO_START_CRITICAL_SECTION_MEM();
46 p = BAMBOO_SHARE_MEM_CALLOC_I(m, isize); // calloc(m, isize);
48 // no more global shared memory
51 BAMBOO_CLOSE_CRITICAL_SECTION_MEM();
52 return (void *)(BAMBOO_CACHE_LINE_SIZE+((int)p-1)&(~BAMBOO_CACHE_LINE_MASK));
56 void * mycalloc_i(int m, int size) {
59 p = BAMBOO_LOCAL_MEM_CALLOC(m, isize); // calloc(m, isize);
66 void myfree(void * ptr) {
67 BAMBOO_LOCAL_MEM_FREE(ptr);