static void check_limitraise(struct chanset_t *chan) { /* only check every other time for now */ chan->checklimit++; if (chan->checklimit == 2) { chan->checklimit = 0; if (chan->limitraise && dolimit(chan)) raise_limit(chan); } }
LogicalAddress ReserveMemoryForHeap(LogicalAddress want, natural totalsize) { void raise_limit(void); LogicalAddress start; raise_limit(); #ifdef WINDOWS start = VirtualAlloc((void *)want, totalsize + heap_segment_size, MEM_RESERVE, PAGE_NOACCESS); if (!start) { #if DEBUG_MEMORY fprintf(dbgout, "Can't get desired heap address at 0x" LISP "\n", want); #endif start = VirtualAlloc(0, totalsize + heap_segment_size, MEM_RESERVE, PAGE_NOACCESS); if (!start) { return NULL; } } #else start = mmap((void *)want, totalsize + heap_segment_size, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, -1, 0); if (start == MAP_FAILED) { return NULL; } if (start != want) { munmap(start, totalsize+heap_segment_size); start = (void *)((((natural)start)+heap_segment_size-1) & ~(heap_segment_size-1)); if(mmap(start, totalsize, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, -1, 0) != start) { return NULL; } } mprotect(start, totalsize, PROT_NONE); #endif #if DEBUG_MEMORY fprintf(dbgout, "Reserving heap at 0x" LISP ", size 0x" LISP "\n", start, totalsize); #endif return start; }