-#if HAVE_THREAD_CONTEXTS
- /* determine the next context */
- boost::optional<smx_actor_t> next_work = raw_parmap->next();
- RawContext* next_context;
- if (next_work) {
- /* there is a next process to resume */
- XBT_DEBUG("Run next process");
- next_context = static_cast<RawContext*>(next_work.get()->context);
- } else {
- /* all processes were run, go to the barrier */
- XBT_DEBUG("No more processes to run");
- uintptr_t worker_id = (uintptr_t)
- xbt_os_thread_get_specific(raw_worker_id_key);
- next_context = static_cast<RawContext*>(raw_workers_context[worker_id]);
- XBT_DEBUG("Restoring worker stack %zu (working threads = %zu)",
- worker_id, raw_threads_working);
- }
-
- SIMIX_context_set_current(next_context);
- raw_swapcontext(&this->stack_top_, next_context->stack_top_);
-#endif
-}
-
-void RawContext::resume()
-{
- if (raw_context_parallel)
- resume_parallel();
- else
- resume_serial();
-}
-
-void RawContext::resume_serial()
-{
- SIMIX_context_set_current(this);
- raw_swapcontext(&raw_maestro_context->stack_top_, this->stack_top_);
-}
-
-void RawContext::resume_parallel()
-{
-#if HAVE_THREAD_CONTEXTS
- uintptr_t worker_id = __sync_fetch_and_add(&raw_threads_working, 1);
- xbt_os_thread_set_specific(raw_worker_id_key, (void*) worker_id);
- RawContext* worker_context = static_cast<RawContext*>(SIMIX_context_self());
- raw_workers_context[worker_id] = worker_context;
- XBT_DEBUG("Saving worker stack %zu", worker_id);
- SIMIX_context_set_current(this);
- raw_swapcontext(&worker_context->stack_top_, this->stack_top_);
-#else
- xbt_die("Parallel execution disabled");
-#endif
+ RawContext* to = static_cast<RawContext*>(to_);
+ ASAN_ONLY(void* fake_stack = nullptr);
+ ASAN_ONLY(to->asan_ctx_ = this);
+ ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+ raw_swapcontext(&this->stack_top_, to->stack_top_);
+ ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);