1 /* Copyright (c) 2007-2010, 2012-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include <simgrid/simix.hpp>
11 #include <src/simix/smx_private.h>
16 ContextFactoryInitializer factory_initializer = nullptr;
18 ContextFactory::~ContextFactory() {}
20 Context* ContextFactory::self()
22 return SIMIX_context_get_current();
25 void ContextFactory::declare_context(void* context, std::size_t size)
28 /* Store the address of the stack in heap to compare it apart of heap comparison */
30 MC_ignore_heap(context, size);
34 Context::Context(xbt_main_func_t code,
35 int argc, char **argv,
36 void_pfn_smxprocess_t cleanup_func,
37 smx_process_t process)
38 : process_(process), iwannadie(false)
40 /* If the user provided a function for the process then use it.
41 Otherwise, it is the context for maestro and we should set it as the
44 this->cleanup_func_ = cleanup_func;
49 SIMIX_context_set_current(this);
56 for (int i = 0; i < this->argc_; i++)
64 if (this->cleanup_func_)
65 this->cleanup_func_(this->process_);
66 this->process_->suspended = 0;
68 this->iwannadie = false;
69 simcall_process_cleanup(this->process_);
70 this->iwannadie = true;