Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove deprecated features for next release (3.30).
[simgrid.git] / src / msg / msg_legacy.cpp
index 93d126e..bc717ec 100644 (file)
@@ -1,10 +1,12 @@
-/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2021. 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)
 
@@ -25,11 +27,15 @@ 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::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(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()
 {
@@ -47,17 +53,24 @@ int MSG_task_listen(const char* alias)
 }
 
 /* ************************** Actors *************************** */
+void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data)
+{
+  /* We can't use the sg_actor_on_exit, as the return type of the callback changed: the int in MSG is ignored and was
+   * removed in sg */
+  simgrid::s4u::this_actor::on_exit([fun, data](bool failed) { fun(failed ? 1 /*FAILURE*/ : 0 /*SUCCESS*/, data); });
+}
+
 int MSG_process_get_PID(const_sg_actor_t actor)
 {
-  return sg_actor_get_PID(actor);
+  return sg_actor_get_pid(actor);
 }
 int MSG_process_get_PPID(const_sg_actor_t actor)
 {
-  return sg_actor_get_PPID(actor);
+  return sg_actor_get_ppid(actor);
 }
-msg_process_t MSG_process_from_PID(int PID)
+msg_process_t MSG_process_from_PID(int pid)
 {
-  return sg_actor_by_PID(PID);
+  return sg_actor_by_pid(pid);
 }
 const char* MSG_process_get_name(const_sg_actor_t actor)
 {
@@ -83,7 +96,7 @@ void MSG_process_resume(sg_actor_t actor)
 {
   sg_actor_resume(actor);
 }
-int MSG_process_is_suspended(sg_actor_t actor)
+int MSG_process_is_suspended(const_sg_actor_t actor)
 {
   return sg_actor_is_suspended(actor);
 }
@@ -104,7 +117,7 @@ void MSG_process_migrate(sg_actor_t actor, sg_host_t host)
 {
   sg_actor_set_host(actor, host);
 }
-void MSG_process_join(sg_actor_t actor, double timeout)
+void MSG_process_join(const_sg_actor_t actor, double timeout)
 {
   sg_actor_join(actor, timeout);
 }
@@ -144,7 +157,7 @@ void* MSG_process_get_data(const_sg_actor_t process)
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
   /* get from SIMIX the MSG process data, and then the user data */
-  return sg_actor_data(process);
+  return sg_actor_get_data(process);
 }
 
 /** @brief Sets the user data of a process.
@@ -154,7 +167,7 @@ void* MSG_process_get_data(const_sg_actor_t process)
 msg_error_t MSG_process_set_data(msg_process_t process, void* data)
 {
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
-  sg_actor_data_set(process, data);
+  sg_actor_set_data(process, data);
 
   return MSG_OK;
 }
@@ -206,11 +219,7 @@ void MSG_process_unref(const_sg_actor_t process)
 {
   sg_actor_unref(process);
 }
-/** @brief Return the current number MSG processes. */
-int MSG_process_get_number()
-{
-  return simgrid_get_actor_count();
-}
+
 /* ************************** NetZones *************************** */
 sg_netzone_t MSG_zone_get_root()
 {
@@ -241,57 +250,7 @@ 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(const_sg_storage_t storage)
-{
-  return sg_storage_get_name(storage);
-}
-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(const_sg_storage_t storage)
-{
-  return sg_storage_get_properties(storage);
-}
-void MSG_storage_set_property_value(sg_storage_t storage, const char* name, const char* value)
-{
-  sg_storage_set_property_value(storage, name, value);
-}
-const char* MSG_storage_get_property_value(const_sg_storage_t storage, const char* name)
-{
-  return sg_storage_get_property_value(storage, name);
-}
-xbt_dynar_t MSG_storages_as_dynar()
-{
-  return sg_storages_as_dynar();
-}
-void MSG_storage_set_data(sg_storage_t storage, void* data)
-{
-  sg_storage_set_data(storage, data);
-}
-void* MSG_storage_get_data(const_sg_storage_t storage)
-{
-  return sg_storage_get_data(storage);
-}
-const char* MSG_storage_get_host(const_sg_storage_t storage)
-{
-  return sg_storage_get_host(storage);
-}
-sg_size_t MSG_storage_read(sg_storage_t storage, sg_size_t size)
-{
-  return sg_storage_read(storage, size);
-}
-sg_size_t MSG_storage_write(sg_storage_t storage, sg_size_t size)
-{
-  return sg_storage_write(storage, size);
-}
-
 /* ************************** hosts *************************** */
-xbt_dynar_t MSG_hosts_as_dynar()
-{
-  return sg_hosts_as_dynar();
-}
 size_t MSG_get_host_number()
 {
   return sg_host_count();
@@ -310,23 +269,15 @@ const char* MSG_host_get_name(const_sg_host_t host)
 }
 void* MSG_host_get_data(const_sg_host_t host)
 {
-  return sg_host_data(host);
+  return sg_host_get_data(host);
 }
 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)
-{
-  return sg_host_get_mounted_storage_list(host);
-}
-xbt_dynar_t MSG_host_get_attached_storage_lists(const_sg_host_t host)
-{
-  return sg_host_get_attached_storage_list(host);
+  return sg_host_set_data(host, data);
 }
 double MSG_host_get_speed(const_sg_host_t host)
 {
-  return sg_host_speed(host);
+  return sg_host_get_speed(host);
 }
 double MSG_host_get_power_peak_at(const_sg_host_t host, int pstate_index)
 {
@@ -383,7 +334,7 @@ sg_host_t MSG_host_self()
 
 double MSG_host_get_load(const_sg_host_t host)
 {
-  return sg_host_load(host);
+  return sg_host_get_load(host);
 }
 /* ************************** Virtual Machines *************************** */
 sg_vm_t MSG_vm_create_core(sg_host_t pm, const char* name)
@@ -394,15 +345,15 @@ sg_vm_t MSG_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount)
 {
   return sg_vm_create_multicore(pm, name, coreAmount);
 }
-int MSG_vm_is_created(sg_vm_t vm)
+int MSG_vm_is_created(const_sg_vm_t vm)
 {
   return sg_vm_is_created(vm);
 }
-int MSG_vm_is_running(sg_vm_t vm)
+int MSG_vm_is_running(const_sg_vm_t vm)
 {
   return sg_vm_is_running(vm);
 }
-int MSG_vm_is_suspended(sg_vm_t vm)
+int MSG_vm_is_suspended(const_sg_vm_t vm)
 {
   return sg_vm_is_suspended(vm);
 }
@@ -478,7 +429,7 @@ void MSG_sem_release(sg_sem_t sem)
 {
   sg_sem_release(sem);
 }
-int MSG_sem_get_capacity(sg_sem_t sem)
+int MSG_sem_get_capacity(const_sg_sem_t sem)
 {
   return sg_sem_get_capacity(sem);
 }
@@ -486,7 +437,7 @@ void MSG_sem_destroy(const_sg_sem_t sem)
 {
   sg_sem_destroy(sem);
 }
-int MSG_sem_would_block(sg_sem_t sem)
+int MSG_sem_would_block(const_sg_sem_t sem)
 {
   return sg_sem_would_block(sem);
 }