]> AND Public Git Repository - simgrid.git/blobdiff - src/msg/msg_legacy.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sonar cleanups: pass large objects by const reference
[simgrid.git] / src / msg / msg_legacy.cpp
index 80c28e0a531bb0a97764439c37767458823d5bf2..f39efe177caecf93d8a19382dcd7627abf7cf3a8 100644 (file)
@@ -1,10 +1,12 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * 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)
 
@@ -23,13 +25,17 @@ msg_error_t MSG_main()
   simgrid_run();
   return MSG_OK;
 }
-void MSG_function_register(const char* name, xbt_main_func_t code)
+void MSG_function_register(const char* name, int (*code)(int, char**))
 {
-  simgrid_register_function(name, code);
+  simgrid::kernel::actor::ActorCodeFactory code_factory = [code](std::vector<std::string> args) {
+    return simgrid::xbt::wrap_main(code, std::move(args));
+  };
+  simgrid::s4u::Engine::get_instance()->register_function(name, code_factory);
 }
-void MSG_function_register_default(xbt_main_func_t code)
+void MSG_function_register_default(int (*code)(int, char**))
 {
-  simgrid_register_default(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()
 {
@@ -47,6 +53,11 @@ int MSG_task_listen(const char* alias)
 }
 
 /* ************************** Actors *************************** */
+void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data)
+{
+  sg_actor_on_exit(fun, data);
+}
+
 int MSG_process_get_PID(const_sg_actor_t actor)
 {
   return sg_actor_get_PID(actor);
@@ -197,12 +208,12 @@ msg_process_t MSG_process_self()
 }
 
 /** @brief Take an extra reference on that process to prevent it to be garbage-collected */
-void MSG_process_ref(msg_process_t process)
+void MSG_process_ref(const_sg_actor_t process)
 {
   sg_actor_ref(process);
 }
 /** @brief Release a reference on that process so that it can get be garbage-collected */
-void MSG_process_unref(msg_process_t process)
+void MSG_process_unref(const_sg_actor_t process)
 {
   sg_actor_unref(process);
 }
@@ -216,7 +227,7 @@ sg_netzone_t MSG_zone_get_root()
 {
   return sg_zone_get_root();
 }
-const char* MSG_zone_get_name(sg_netzone_t zone)
+const char* MSG_zone_get_name(const_sg_netzone_t zone)
 {
   return sg_zone_get_name(zone);
 }
@@ -224,25 +235,25 @@ sg_netzone_t MSG_zone_get_by_name(const char* name)
 {
   return sg_zone_get_by_name(name);
 }
-void MSG_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto)
+void MSG_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto)
 {
   return sg_zone_get_sons(zone, whereto);
 }
-const char* MSG_zone_get_property_value(sg_netzone_t zone, const char* name)
+const char* MSG_zone_get_property_value(const_sg_netzone_t zone, const char* name)
 {
   return sg_zone_get_property_value(zone, name);
 }
-void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, char* value)
+void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, const char* value)
 {
   sg_zone_set_property_value(zone, name, value);
 }
-void MSG_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto)
+void MSG_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto)
 {
   sg_zone_get_hosts(zone, whereto);
 }
 
 /* ************************** Storages *************************** */
-const char* MSG_storage_get_name(sg_storage_t storage)
+const char* MSG_storage_get_name(const_sg_storage_t storage)
 {
   return sg_storage_get_name(storage);
 }
@@ -250,7 +261,7 @@ sg_storage_t MSG_storage_get_by_name(const char* name)
 {
   return sg_storage_get_by_name(name);
 }
-xbt_dict_t MSG_storage_get_properties(sg_storage_t storage)
+xbt_dict_t MSG_storage_get_properties(const_sg_storage_t storage)
 {
   return sg_storage_get_properties(storage);
 }
@@ -258,7 +269,7 @@ void MSG_storage_set_property_value(sg_storage_t storage, const char* name, cons
 {
   sg_storage_set_property_value(storage, name, value);
 }
-const char* MSG_storage_get_property_value(sg_storage_t storage, const char* name)
+const char* MSG_storage_get_property_value(const_sg_storage_t storage, const char* name)
 {
   return sg_storage_get_property_value(storage, name);
 }
@@ -270,11 +281,11 @@ void MSG_storage_set_data(sg_storage_t storage, void* data)
 {
   sg_storage_set_data(storage, data);
 }
-void* MSG_storage_get_data(sg_storage_t storage)
+void* MSG_storage_get_data(const_sg_storage_t storage)
 {
   return sg_storage_get_data(storage);
 }
-const char* MSG_storage_get_host(sg_storage_t storage)
+const char* MSG_storage_get_host(const_sg_storage_t storage)
 {
   return sg_storage_get_host(storage);
 }
@@ -316,7 +327,7 @@ void MSG_host_set_data(sg_host_t host, void* data)
 {
   return sg_host_data_set(host, data);
 }
-xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host)
+xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host) // XBT_ATTRIB_DEPRECATED_v330
 {
   return sg_host_get_mounted_storage_list(host);
 }
@@ -414,11 +425,11 @@ void MSG_vm_set_ramsize(sg_vm_t vm, size_t size)
 {
   sg_vm_set_ramsize(vm, size);
 }
-size_t MSG_vm_get_ramsize(sg_vm_t vm)
+size_t MSG_vm_get_ramsize(const_sg_vm_t vm)
 {
   return sg_vm_get_ramsize(vm);
 }
-sg_host_t MSG_vm_get_pm(sg_vm_t vm)
+sg_host_t MSG_vm_get_pm(const_sg_vm_t vm)
 {
   return sg_vm_get_pm(vm);
 }
@@ -482,7 +493,7 @@ int MSG_sem_get_capacity(sg_sem_t sem)
 {
   return sg_sem_get_capacity(sem);
 }
-void MSG_sem_destroy(sg_sem_t sem)
+void MSG_sem_destroy(const_sg_sem_t sem)
 {
   sg_sem_destroy(sem);
 }