/* We need to pass the bottom of the stack to make_fcontext,
depending on the stack direction it may be the lower or higher address: */
#if PTH_STACKGROWTH == -1
- void* stack = static_cast<char*>(this->stack_) + smx_context_usable_stack_size;
+ void* stack = static_cast<char*>(get_stack()) + smx_context_usable_stack_size;
#else
- void* stack = this->stack_;
+ void* stack = get_stack();
#endif
ASAN_ONLY(this->asan_stack_ = stack);
#if BOOST_VERSION < 106100
{
if (has_code()) {
#if PTH_STACKGROWTH == -1
- ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);
+ ASAN_ONLY(this->asan_stack_ = static_cast<char*>(get_stack()) + smx_context_usable_stack_size);
#else
- ASAN_ONLY(this->asan_stack_ = this->stack_);
+ ASAN_ONLY(this->asan_stack_ = get_stack());
#endif
- this->stack_top_ = raw_makecontext(this->stack_, smx_context_usable_stack_size, RawContext::wrapper, this);
+ this->stack_top_ = raw_makecontext(get_stack(), smx_context_usable_stack_size, RawContext::wrapper, this);
} else {
set_maestro(this); // save maestro for run_all()
if (MC_is_active())
factory_->workers_context_[0] = ctx;
}
+void* SwappedContext::get_stack()
+{
+ return stack_;
+}
+
void SwappedContext::stop()
{
Context::stop();
virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
void set_maestro(SwappedContext* ctx);
+ void* get_stack();
// FIXME: Killme
static thread_local uintptr_t worker_id_;
-protected:
- void* stack_ = nullptr; /* the thread stack */
-
private:
- SwappedContextFactory* factory_; // for sequential and parallel run_all()
+ void* stack_ = nullptr; /* the thread stack */
+ SwappedContextFactory* const factory_; // for sequential and parallel run_all()
};
} // namespace context
if (has_code()) {
getcontext(&this->uc_);
this->uc_.uc_link = nullptr;
- this->uc_.uc_stack.ss_sp = sg_makecontext_stack_addr(this->stack_);
+ this->uc_.uc_stack.ss_sp = sg_makecontext_stack_addr(get_stack());
this->uc_.uc_stack.ss_size = sg_makecontext_stack_size(smx_context_usable_stack_size);
#if PTH_STACKGROWTH == -1
ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);