Commit 6d7bb479 authored by Dominik Charousset's avatar Dominik Charousset

some cleanup in fiber impl

parent 49881cc2
...@@ -89,35 +89,24 @@ inline void fc_jump(fc_member& from, fc_member& to, fiber_impl* ptr) { ...@@ -89,35 +89,24 @@ inline void fc_jump(fc_member& from, fc_member& to, fiber_impl* ptr) {
ctx::jump_fcontext(&from, &to, (intptr_t) ptr); ctx::jump_fcontext(&from, &to, (intptr_t) ptr);
} }
inline void fc_make(fc_member& storage, fc_allocator& alloc, vg_member& vgm) { inline void fc_make(fc_member& storage, fc_allocator& alloc, vg_member& vgm) {
size_t stacksize = ctx::minimum_stacksize(); size_t mss = ctx::minimum_stacksize();
storage.fc_stack.base = alloc.allocate(stacksize); storage.fc_stack.base = alloc.allocate(mss);
storage.fc_stack.limit = reinterpret_cast<void*>( storage.fc_stack.limit = reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(storage.fc_stack.base) - stacksize); reinterpret_cast<intptr_t>(storage.fc_stack.base) - mss);
ctx::make_fcontext(&storage, fiber_trampoline); ctx::make_fcontext(&storage, fiber_trampoline);
vg_register(vgm, vg_register(vgm,
storage.fc_stack.base, storage.fc_stack.base,
reinterpret_cast<void*>( reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(storage.fc_stack.base) - stacksize)); reinterpret_cast<intptr_t>(storage.fc_stack.base) - mss));
}
#elif BOOST_VERSION < 105300
namespace ctx = boost::context;
typedef ctx::fcontext_t* fc_member;
typedef ctx::guarded_stack_allocator fc_allocator
inline void fc_jump(fc_member& from, fc_member& to, fiber_impl* ptr) {
ctx::jump_fcontext(from, to, (intptr_t) ptr);
}
inline void fc_make(fc_member& storage, fc_allocator& alloc, vg_member& vgm) {
size_t mss = fc_allocator::minimum_stacksize();
storage = ctx::make_fcontext(alloc.allocate(mss), mss, fiber_trampoline);
vg_register(vgm,
storage->fc_stack.sp,
reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(storage->fc_stack.sp) - mss));
} }
#else #else
namespace ctx = boost::context; namespace ctx = boost::context;
typedef ctx::fcontext_t* fc_member; typedef ctx::fcontext_t* fc_member;
typedef boost::coroutines::stack_allocator fc_allocator; # if BOOST_VERSION < 105300
typedef ctx::guarded_stack_allocator fc_allocator;
# else
typedef boost::coroutines::stack_allocator fc_allocator;
# endif
inline void fc_jump(fc_member& from, fc_member& to, fiber_impl* ptr) { inline void fc_jump(fc_member& from, fc_member& to, fiber_impl* ptr) {
ctx::jump_fcontext(from, to, (intptr_t) ptr); ctx::jump_fcontext(from, to, (intptr_t) ptr);
} }
...@@ -129,7 +118,6 @@ inline void fc_make(fc_member& storage, fc_allocator& alloc, vg_member& vgm) { ...@@ -129,7 +118,6 @@ inline void fc_make(fc_member& storage, fc_allocator& alloc, vg_member& vgm) {
reinterpret_cast<void*>( reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(storage->fc_stack.sp) - mss)); reinterpret_cast<intptr_t>(storage->fc_stack.sp) - mss));
} }
#endif #endif
} // namespace <anonymous> } // namespace <anonymous>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment