Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the API between Engine and EngineImpl when registering functions
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Feb 2020 16:36:28 +0000 (17:36 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Feb 2020 16:50:59 +0000 (17:50 +0100)
Engine is providing several prototypes to serve S4U, SMPI, MSG and all
friends. It was providing all these prototypes to EngineImpl which was
in charge of building the ActorCodeFactory, ie the lambda in charge of
building a lambda code that the actor can execute.

Now, Engine is building the ActorCodeFactory and EngineImpl is only
providing one prototype.

While I was at it, I moved the registered functions and default
function from simix_global (which should die at some point) to the
EngineImpl, and killed a SIMIX function defined in Context.hpp (yuk).

I also made ActorCodeFactory a public type in forward.h, which
requires to include <vector> in forward.h. I guess we can live with it.

I also introduced an EngineImpl::get_instance() even if that require a
circular dependency between Engine and EngineImpl. I did not find a
better solution.

Now, MSG can directly build its ActorCodeFactory and pass it to the
Engine. It fixes the casting issues we had on user code, and remove
the need for an extra flag to calm the compiler about this ugly cast.

19 files changed:
include/simgrid/forward.h
include/simgrid/s4u/Engine.hpp
include/simgrid/simix.hpp
src/bindings/java/jmsg_process.cpp
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/kernel/actor/ActorImpl.cpp
src/kernel/actor/ActorImpl.hpp
src/kernel/context/Context.hpp
src/msg/msg_legacy.cpp
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Engine.cpp
src/simix/smx_deployment.cpp
src/simix/smx_global.cpp
src/simix/smx_private.hpp
src/smpi/internals/smpi_global.cpp
src/surf/sg_platf.cpp
tools/cmake/MakeLib.cmake

index 7ee6e4f..608bd91 100644 (file)
@@ -11,6 +11,7 @@
 #ifdef __cplusplus
 
 #include <boost/intrusive_ptr.hpp>
+#include <vector>
 
 namespace simgrid {
 
@@ -103,6 +104,11 @@ class EngineImpl;
 namespace actor {
 class ActorImpl;
 typedef boost::intrusive_ptr<ActorImpl> ActorImplPtr;
+
+// What's executed as an actor code:
+typedef std::function<void()> ActorCode;
+// Create an ActorCode from the parameters parsed in the XML file (or elsewhere)
+typedef std::function<ActorCode(std::vector<std::string> args)> ActorCodeFactory;
 } // namespace actor
 
 namespace activity {
index f62b955..e2e0c86 100644 (file)
@@ -25,6 +25,8 @@ namespace s4u {
  * This is a singleton containing all the main functions of the simulation.
  */
 class XBT_PUBLIC Engine {
+  friend simgrid::kernel::EngineImpl;
+
 public:
   /** Constructor, taking the command line parameters of your main function */
   explicit Engine(int* argc, char** argv);
@@ -57,21 +59,22 @@ public:
   XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_default(
       int (*code)(int, char**));
   void register_default(void (*code)(int, char**));
+  void register_default(kernel::actor::ActorCodeFactory factory);
 
+  void register_function(const std::string& name, kernel::actor::ActorCodeFactory factory);
   template <class F> void register_actor(const std::string& name)
   {
-    simix::register_function(name, [](std::vector<std::string> args) {
-      return simix::ActorCode([args] {
+    register_function(name, [](std::vector<std::string> args) {
+      return kernel::actor::ActorCode([args] {
         F code(std::move(args));
         code();
       });
     });
   }
-
   template <class F> void register_actor(const std::string& name, F code)
   {
-    simix::register_function(name, [code](std::vector<std::string> args) {
-      return simix::ActorCode([code, args] { code(std::move(args)); });
+    register_function(name, [code](std::vector<std::string> args) {
+      return kernel::actor::ActorCode([code, args] { code(std::move(args)); });
     });
   }
 
index 685e8eb..115fdff 100644 (file)
@@ -95,13 +95,6 @@ template <class R, class F> R simcall_blocking(F&& code, mc::SimcallInspector* t
 namespace simgrid {
 namespace simix {
 
-// What's executed as SIMIX actor code:
-typedef std::function<void()> ActorCode;
-
-// Create an ActorCode based on a std::string
-typedef std::function<ActorCode(std::vector<std::string> args)> ActorCodeFactory;
-
-XBT_PUBLIC void register_function(const std::string& name, const ActorCodeFactory& factory);
 
 typedef std::pair<double, Timer*> TimerQelt;
 static boost::heap::fibonacci_heap<TimerQelt, boost::heap::compare<xbt::HeapComparator<TimerQelt>>> simix_timers;
@@ -131,8 +124,4 @@ public:
 } // namespace simix
 } // namespace simgrid
 
-XBT_PUBLIC smx_actor_t simcall_process_create(const std::string& name, const simgrid::simix::ActorCode& code,
-                                              void* data, sg_host_t host,
-                                              std::unordered_map<std::string, std::string>* properties);
-
 #endif
index 3e77209..7f6ee40 100644 (file)
@@ -70,13 +70,14 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv* env, jobject
   jobject jprocess = jprocess_ref(jprocess_arg, env);
 
   /* Actually build the MSG process */
-  jstring jname         = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
-  const char* name      = env->GetStringUTFChars(jname, 0);
-  simgrid::simix::ActorCode function = [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); };
-  smx_actor_t self                   = SIMIX_process_self();
-  sg_host_t host                     = jhost_get_native(env, jhost);
-  smx_actor_t actor                  = simgrid::kernel::actor::simcall([name, function, host, self] {
-    return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(function), nullptr, host, nullptr, self)
+  jstring jname     = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
+  const char* name  = env->GetStringUTFChars(jname, 0);
+  auto actor_code   = [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); };
+  smx_actor_t self  = SIMIX_process_self();
+  sg_host_t host    = jhost_get_native(env, jhost);
+  smx_actor_t actor = simgrid::kernel::actor::simcall([name, actor_code, host, self] {
+    return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, nullptr,
+                                                     self)
         .get();
   });
   MSG_process_yield();
index e8c2235..b0ca669 100644 (file)
@@ -48,37 +48,14 @@ void EngineImpl::load_deployment(const std::string& file)
   surf_parse();
   surf_parse_close();
 }
-void EngineImpl::register_function(const std::string& name, int (*code)(int, char**)) // deprecated
-{
-  simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
-    return xbt::wrap_main(code, std::move(args));
-  };
-}
-void EngineImpl::register_function(const std::string& name, xbt_main_func_t code)
-{
-  simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
-    return xbt::wrap_main(code, std::move(args));
-  };
-}
-
-void EngineImpl::register_function(const std::string& name, void (*code)(std::vector<std::string>))
-{
-  simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
-    return std::bind(std::move(code), std::move(args));
-  };
-}
 
-void EngineImpl::register_default(int (*code)(int, char**)) // deprecated
+void EngineImpl::register_function(const std::string& name, actor::ActorCodeFactory code)
 {
-  simix_global->default_function = [code](std::vector<std::string> args) {
-    return xbt::wrap_main(code, std::move(args));
-  };
+  registered_functions[name] = code;
 }
-void EngineImpl::register_default(xbt_main_func_t code)
+void EngineImpl::register_default(actor::ActorCodeFactory code)
 {
-  simix_global->default_function = [code](std::vector<std::string> args) {
-    return xbt::wrap_main(code, std::move(args));
-  };
+  default_function = code;
 }
 
 } // namespace kernel
index cf4828f..5712dc9 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <map>
+#include <simgrid/s4u/Engine.hpp>
 #include <simgrid/s4u/NetZone.hpp>
 #include <simgrid/simix.hpp>
 #include <string>
@@ -17,6 +18,9 @@ class EngineImpl {
   std::map<std::string, resource::LinkImpl*> links_;
   std::map<std::string, resource::StorageImpl*> storages_;
   std::unordered_map<std::string, routing::NetPoint*> netpoints_;
+  std::unordered_map<std::string, actor::ActorCodeFactory> registered_functions; // Maps function names to actor code
+  actor::ActorCodeFactory default_function; // Function to use as a fallback when the provided name matches nothing
+
   friend s4u::Engine;
 
 public:
@@ -27,13 +31,19 @@ public:
   virtual ~EngineImpl();
 
   void load_deployment(const std::string& file);
-  void register_function(const std::string& name, int (*code)(int, char**)); // deprecated
-  void register_function(const std::string& name, xbt_main_func_t code);
-  void register_function(const std::string& name, void (*code)(std::vector<std::string>));
-  void register_default(int (*code)(int, char**)); // deprecated
-  void register_default(xbt_main_func_t code);
+  void register_function(const std::string& name, actor::ActorCodeFactory code);
+  void register_default(actor::ActorCodeFactory code);
 
   routing::NetZoneImpl* netzone_root_ = nullptr;
+  static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; }
+  actor::ActorCodeFactory get_function(const std::string& name)
+  {
+    auto res = registered_functions.find(name);
+    if (res == registered_functions.end())
+      return default_function;
+    else
+      return res->second;
+  }
 };
 
 } // namespace kernel
index 621c4c1..c695f42 100644 (file)
@@ -461,7 +461,7 @@ ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host)
   return ActorImplPtr(actor);
 }
 
-ActorImpl* ActorImpl::start(const simix::ActorCode& code)
+ActorImpl* ActorImpl::start(const ActorCode& code)
 {
   xbt_assert(code && host_ != nullptr, "Invalid parameters");
 
@@ -473,7 +473,7 @@ ActorImpl* ActorImpl::start(const simix::ActorCode& code)
 
   this->code_ = code;
   XBT_VERB("Create context %s", get_cname());
-  context_.reset(simix_global->context_factory->create_context(simix::ActorCode(code), this));
+  context_.reset(simix_global->context_factory->create_context(ActorCode(code), this));
 
   XBT_DEBUG("Start context '%s'", get_cname());
 
@@ -488,7 +488,7 @@ ActorImpl* ActorImpl::start(const simix::ActorCode& code)
   return this;
 }
 
-ActorImplPtr ActorImpl::create(const std::string& name, const simix::ActorCode& code, void* data, s4u::Host* host,
+ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
                                const std::unordered_map<std::string, std::string>* properties, ActorImpl* parent_actor)
 {
   XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
@@ -517,9 +517,9 @@ void create_maestro(const std::function<void()>& code)
   ActorImpl* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr);
 
   if (not code) {
-    maestro->context_.reset(simix_global->context_factory->create_context(simix::ActorCode(), maestro));
+    maestro->context_.reset(simix_global->context_factory->create_context(ActorCode(), maestro));
   } else {
-    maestro->context_.reset(simix_global->context_factory->create_maestro(simix::ActorCode(code), maestro));
+    maestro->context_.reset(simix_global->context_factory->create_maestro(ActorCode(code), maestro));
   }
 
   maestro->simcall.issuer_      = maestro;
@@ -602,7 +602,7 @@ void SIMIX_process_on_exit(smx_actor_t actor,
  * @param host where the new agent is executed.
  * @param properties the properties of the process
  */
-smx_actor_t simcall_process_create(const std::string& name, const simgrid::simix::ActorCode& code, void* data,
+smx_actor_t simcall_process_create(const std::string& name, const simgrid::kernel::actor::ActorCode& code, void* data,
                                    sg_host_t host, std::unordered_map<std::string, std::string>* properties)
 {
   smx_actor_t self = simgrid::kernel::actor::ActorImpl::self();
index 74b0b8c..bbbcd60 100644 (file)
@@ -115,9 +115,9 @@ public:
   s4u::Actor* ciface() { return &piface_; }
 
   ActorImplPtr init(const std::string& name, s4u::Host* host);
-  ActorImpl* start(const simix::ActorCode& code);
+  ActorImpl* start(const ActorCode& code);
 
-  static ActorImplPtr create(const std::string& name, const simix::ActorCode& code, void* data, s4u::Host* host,
+  static ActorImplPtr create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
                              const std::unordered_map<std::string, std::string>* properties, ActorImpl* parent_actor);
   static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host,
                              const std::unordered_map<std::string, std::string>* properties);
@@ -200,4 +200,8 @@ XBT_PUBLIC int get_maxpid();
 
 extern void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr actor);
 
+XBT_PUBLIC smx_actor_t simcall_process_create(const std::string& name, const simgrid::kernel::actor::ActorCode& code,
+                                              void* data, sg_host_t host,
+                                              std::unordered_map<std::string, std::string>* properties);
+
 #endif
index e4f3d66..84dc108 100644 (file)
@@ -109,7 +109,4 @@ XBT_PRIVATE void SIMIX_context_mod_exit();
 #ifndef WIN32
 XBT_PUBLIC_DATA unsigned char sigsegv_stack[SIGSTKSZ];
 #endif
-
-XBT_PRIVATE simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const std::string& name);
-
 #endif
index 93d126e..b38a12c 100644 (file)
@@ -4,7 +4,9 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/Exception.hpp"
+#include "simgrid/s4u/Engine.hpp"
 #include "src/msg/msg_private.hpp"
+#include "xbt/functional.hpp"
 
 #define MSG_CALL(type, oldname, args)
 
@@ -25,11 +27,13 @@ msg_error_t MSG_main()
 }
 void MSG_function_register(const char* name, int (*code)(int, char**))
 {
-  simgrid_register_function(name, (void (*)(int, char**))code);
+  simgrid::s4u::Engine::get_instance()->register_function(
+      name, [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); });
 }
 void MSG_function_register_default(int (*code)(int, char**))
 {
-  simgrid_register_default((void (*)(int, char**))code);
+  simgrid::s4u::Engine::get_instance()->register_default(
+      [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); });
 }
 double MSG_get_clock()
 {
index 9b53e16..1c349b0 100644 (file)
@@ -70,7 +70,7 @@ msg_process_t MSG_process_create_with_environment(const char* name, int (*code)(
       xbt_dict_foreach (properties, cursor, key, value)
         actor->set_property(key, value);
     }
-    sg_actor_start(actor, (void (*)(int, char**))code, argc, argv);
+    actor->start(std::move(simgrid::xbt::wrap_main(code, argc, argv)));
   } catch (simgrid::HostFailureException const&) {
     xbt_die("Could not launch a new process on failed host %s.", host->get_cname());
   }
index 02f2ba7..f2d5612 100644 (file)
@@ -11,6 +11,7 @@
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/VirtualMachine.hpp"
 #include "src/include/mc/mc.h"
+#include "src/kernel/EngineImpl.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/HostImpl.hpp"
@@ -73,7 +74,8 @@ ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::func
 ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::string& function,
                        std::vector<std::string> args)
 {
-  const simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
+  const simgrid::kernel::actor::ActorCodeFactory& factory =
+      simgrid::kernel::EngineImpl::get_instance()->get_function(function);
   return create(name, host, factory(std::move(args)));
 }
 
@@ -464,7 +466,7 @@ sg_actor_t sg_actor_init(const char* name, sg_host_t host)
 
 void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, const char* const* argv)
 {
-  simgrid::simix::ActorCode function;
+  simgrid::kernel::actor::ActorCode function;
   if (code)
     function = simgrid::xbt::wrap_main(code, argc, argv);
   actor->start(std::move(function));
index 78e4b4b..bf7f744 100644 (file)
@@ -92,23 +92,24 @@ void Engine::load_platform(const std::string& platf)
 
 void Engine::register_function(const std::string& name, int (*code)(int, char**)) // deprecated
 {
-  pimpl->register_function(name, code);
+  register_function(name, [code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
 }
 void Engine::register_default(int (*code)(int, char**)) // deprecated
 {
-  pimpl->register_default(code);
+  register_default([code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
 }
 
 /** Registers the main function of an actor that will be launched from the deployment file */
 void Engine::register_function(const std::string& name, void (*code)(int, char**))
 {
-  pimpl->register_function(name, code);
+  register_function(name, [code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
 }
 
 /** Registers the main function of an actor that will be launched from the deployment file */
 void Engine::register_function(const std::string& name, void (*code)(std::vector<std::string>))
 {
-  pimpl->register_function(name, code);
+  register_function(name,
+                    [code](std::vector<std::string> args) { return std::bind(std::move(code), std::move(args)); });
 }
 /** Registers a function as the default main function of actors
  *
@@ -117,7 +118,16 @@ void Engine::register_function(const std::string& name, void (*code)(std::vector
  */
 void Engine::register_default(void (*code)(int, char**))
 {
-  pimpl->register_default(code);
+  register_default([code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
+}
+void Engine::register_default(kernel::actor::ActorCodeFactory code)
+{
+  simgrid::kernel::actor::simcall([this, code]() { pimpl->register_default(code); });
+}
+
+void Engine::register_function(const std::string& name, kernel::actor::ActorCodeFactory code)
+{
+  simgrid::kernel::actor::simcall([this, name, code]() { pimpl->register_function(name, code); });
 }
 
 /** Load a deployment file and launch the actors that it contains
index 17b354c..bbe3b7d 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "simgrid/s4u/Host.hpp"
 #include "smx_private.hpp"
+#include "src/kernel/EngineImpl.hpp"
 #include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
 #include <simgrid/engine.h>
 #include <simgrid/s4u/Engine.hpp>
@@ -37,28 +38,7 @@ void SIMIX_function_register_default(xbt_main_func_t code) // XBT_DEPRECATED_v32
   simgrid::s4u::Engine::get_instance()->register_default(code);
 }
 
-/**
- * @brief Gets a #smx_actor_t code from the global table.
- *
- * Gets a code function from the global table. Returns nullptr if there are no function registered with the name.
- * This table is then used by #SIMIX_launch_application.
- * @param name the reference name of the function.
- * @return The #smx_actor_t or nullptr.
- */
-simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const std::string& name)
-{
-  xbt_assert(simix_global,
-              "SIMIX_global_init has to be called before SIMIX_get_actor_code_factory.");
-
-  auto i = simix_global->registered_functions.find(name);
-  if (i == simix_global->registered_functions.end())
-    return simix_global->default_function;
-  else
-    return i->second;
-}
-
 /** @brief Bypass the parser, get arguments, and set function to each process */
-
 void SIMIX_process_set_function(const char* process_host, const char* process_function, xbt_dynar_t arguments,
                                 double process_start_time, double process_kill_time) // XBT_ATTRIB_DEPRECATED_v329
 {
@@ -77,7 +57,8 @@ void SIMIX_process_set_function(const char* process_host, const char* process_fu
   }
 
   // Check we know how to handle this function name:
-  const simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
+  const simgrid::kernel::actor::ActorCodeFactory& parse_code =
+      simgrid::kernel::EngineImpl::get_instance()->get_function(process_function);
   xbt_assert(parse_code, "Function '%s' unknown", process_function);
 
   actor.function           = process_function;
@@ -87,14 +68,3 @@ void SIMIX_process_set_function(const char* process_host, const char* process_fu
   actor.restart_on_failure = false;
   sg_platf_new_actor(&actor);
 }
-
-namespace simgrid {
-namespace simix {
-
-void register_function(const std::string& name, const ActorCodeFactory& factory)
-{
-  simix_global->registered_functions[name] = factory;
-}
-
-}
-}
index fa70127..20b1f4a 100644 (file)
@@ -264,7 +264,7 @@ config::Flag<double> cfg_breakpoint{
 } // namespace simix
 } // namespace simgrid
 
-static simgrid::simix::ActorCode maestro_code;
+static simgrid::kernel::actor::ActorCode maestro_code;
 void SIMIX_set_maestro(void (*code)(void*), void* data)
 {
 #ifdef _WIN32
index 81da1ce..54fdcac 100644 (file)
@@ -55,12 +55,6 @@ public:
 #endif
   kernel::actor::ActorImpl* maestro_ = nullptr;
 
-  // Maps function names to actor code:
-  std::unordered_map<std::string, simix::ActorCodeFactory> registered_functions;
-
-  // This might be used when no corresponding function name is registered:
-  simix::ActorCodeFactory default_function;
-
   std::mutex mutex;
 
   std::vector<xbt::Task<void()>> tasks;
index b768c45..3374038 100644 (file)
@@ -446,7 +446,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
     }
   }
 
-  simix_global->default_function = [executable, fdin_size](std::vector<std::string> args) {
+  simgrid::s4u::Engine::get_instance()->register_default([executable, fdin_size](std::vector<std::string> args) {
     return std::function<void()>([executable, fdin_size, args] {
       static std::size_t rank = 0;
       // Copy the dynamic library:
@@ -501,7 +501,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
       xbt_assert(entry_point, "Could not resolve entry point");
       smpi_run_entry_point(entry_point, executable, args);
     });
-  };
+  });
 }
 
 static void smpi_init_privatization_no_dlopen(const std::string& executable)
@@ -520,10 +520,10 @@ static void smpi_init_privatization_no_dlopen(const std::string& executable)
     smpi_backup_global_memory_segment();
 
   // Execute the same entry point for each simulated process:
-  simix_global->default_function = [entry_point, executable](std::vector<std::string> args) {
+  simgrid::s4u::Engine::get_instance()->register_default([entry_point, executable](std::vector<std::string> args) {
     return std::function<void()>(
         [entry_point, executable, args] { smpi_run_entry_point(entry_point, executable, args); });
-  };
+  });
 }
 
 int smpi_main(const char* executable, int argc, char* argv[])
index 8f89621..01cbb71 100644 (file)
@@ -451,7 +451,8 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
     }
     xbt_die("%s", msg.c_str());
   }
-  const simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(actor->function);
+  const simgrid::kernel::actor::ActorCodeFactory& factory =
+      simgrid::kernel::EngineImpl::get_instance()->get_function(actor->function);
   xbt_assert(factory, "Error while creating an actor from the XML file: Function '%s' not registered", actor->function);
 
   double start_time = actor->start_time;
@@ -459,7 +460,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
   bool auto_restart = actor->restart_on_failure;
 
   std::string actor_name     = actor->args[0];
-  simgrid::simix::ActorCode code = factory(std::move(actor->args));
+  simgrid::kernel::actor::ActorCode code = factory(std::move(actor->args));
   std::shared_ptr<std::unordered_map<std::string, std::string>> properties(actor->properties);
 
   simgrid::kernel::actor::ProcessArg* arg =
index 1343667..b29b592 100644 (file)
@@ -24,16 +24,6 @@ set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
 set_property(TARGET simgrid
              APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
-# Don't complain when we cast (int (*)(int,char**)) into (void(*)(int,char**))
-# This will stop when MSG goes away
-if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-  set_property(SOURCE ${CMAKE_HOME_DIRECTORY}/src/msg/msg_legacy.cpp  PROPERTY COMPILE_FLAGS -Wno-error=bad-function-cast)
-  set_property(SOURCE ${CMAKE_HOME_DIRECTORY}/src/msg/msg_process.cpp PROPERTY COMPILE_FLAGS -Wno-error=bad-function-cast)
-elseif(CMAKE_COMPILER_IS_GNUCXX)
-  set_property(SOURCE ${CMAKE_HOME_DIRECTORY}/src/msg/msg_legacy.cpp  PROPERTY COMPILE_FLAGS -Wno-error=cast-function-type)
-  set_property(SOURCE ${CMAKE_HOME_DIRECTORY}/src/msg/msg_process.cpp PROPERTY COMPILE_FLAGS -Wno-error=cast-function-type)
-endif()
-
 add_dependencies(simgrid maintainer_files)
 
 if(enable_model-checking)