// Allocate a new g, with a stack big enough for stacksize bytes. G* runtime_malg(int32 stacksize, byte** ret_stack, size_t* ret_stacksize) { G *newg; newg = runtime_malloc(sizeof(G)); if(stacksize >= 0) { #if USING_SPLIT_STACK int dont_block_signals = 0; *ret_stack = __splitstack_makecontext(stacksize, &newg->stack_context[0], ret_stacksize); __splitstack_block_signals_context(&newg->stack_context[0], &dont_block_signals, nil); #else *ret_stack = runtime_mallocgc(stacksize, FlagNoProfiling|FlagNoGC, 0, 0); *ret_stacksize = stacksize; newg->gcinitial_sp = *ret_stack; newg->gcstack_size = stacksize; runtime_xadd(&runtime_stacks_sys, stacksize); #endif } return newg; }
void segmented_stack_allocator::allocate( stack_context & ctx, std::size_t size) { void * limit = __splitstack_makecontext( size, ctx.segments_ctx, & ctx.size); BOOST_ASSERT( limit); ctx.sp = static_cast< char * >( limit) + ctx.size; int off = 0; __splitstack_block_signals_context( ctx.segments_ctx, & off, 0); }
void allocate( stack_context & ctx, std::size_t size = traits_type::minimum_size() ) { void * limit = __splitstack_makecontext( size, ctx.segments_ctx, & ctx.size); if ( ! limit) throw std::bad_alloc(); // ctx.size is already filled by __splitstack_makecontext ctx.sp = static_cast< char * >( limit) + ctx.size; int off = 0; __splitstack_block_signals_context( ctx.segments_ctx, & off, 0); }
void* allocate(std::size_t size) const { HPX_ASSERT(default_stacksize() <= size); void* limit = __splitstack_makecontext(size, segments_ctx_, &size); if (!limit) boost::throw_exception(std::bad_alloc()); int off = 0; __splitstack_block_signals_context(segments_ctx_, &off, 0); return static_cast<char *>(limit) + size; }
void stack_allocator_split_segment::allocate(stack_context & ctx, std::size_t size) { void* start_ptr = __splitstack_makecontext( size, ctx.segments_ctx, &ctx.size); assert(start_ptr); if (!start_ptr) { ctx.sp = NULL; return; } ctx.sp = static_cast<char *>(start_ptr) + ctx.size; // stack down int off = 0; __splitstack_block_signals_context(ctx.segments_ctx, &off, 0); }
G* runtime_malg(int32 stacksize, byte** ret_stack, size_t* ret_stacksize) { G *newg; newg = runtime_malloc(sizeof(G)); if(stacksize >= 0) { #if USING_SPLIT_STACK *ret_stack = __splitstack_makecontext(stacksize, &newg->stack_context[0], ret_stacksize); #else *ret_stack = runtime_mallocgc(stacksize, FlagNoProfiling|FlagNoGC, 0, 0); *ret_stacksize = stacksize; newg->gcinitial_sp = *ret_stack; newg->gcstack_size = stacksize; #endif } return newg; }