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>
13 void SIMIX_process_set_cleanup_function(
14 smx_process_t process, void_pfn_smxprocess_t cleanup)
16 process->context->set_cleanup(cleanup);
22 ContextFactoryInitializer factory_initializer = nullptr;
24 ContextFactory::~ContextFactory() {}
26 Context* ContextFactory::self()
28 return SIMIX_context_get_current();
31 void ContextFactory::declare_context(void* context, std::size_t size)
34 /* Store the address of the stack in heap to compare it apart of heap comparison */
36 MC_ignore_heap(context, size);
40 Context::Context(xbt_main_func_t code,
41 int argc, char **argv,
42 void_pfn_smxprocess_t cleanup_func,
43 smx_process_t process)
44 : process_(process), iwannadie(false)
46 /* If the user provided a function for the process then use it.
47 Otherwise, it is the context for maestro and we should set it as the
50 this->cleanup_func_ = cleanup_func;
55 SIMIX_context_set_current(this);
62 for (int i = 0; i < this->argc_; i++)
70 if (this->cleanup_func_)
71 this->cleanup_func_(this->process_);
72 this->process_->suspended = 0;
74 this->iwannadie = false;
75 simcall_process_cleanup(this->process_);
76 this->iwannadie = true;