Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MSG aliasing instead of macro-ization to keep ABI safe
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 22 Mar 2018 08:13:38 +0000 (09:13 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 22 Mar 2018 08:13:38 +0000 (09:13 +0100)
13 files changed:
include/simgrid/actor.h [new file with mode: 0644]
include/simgrid/forward.h
include/simgrid/msg.h
src/bindings/java/jmsg_process.cpp
src/msg/instr_msg_process.cpp
src/msg/msg_process.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_actor.cpp
src/s4u/s4u_netzone.cpp
src/s4u/s4u_storage.cpp
src/simgrid/host.cpp
src/simix/smx_host.cpp
tools/cmake/DefinePackages.cmake

diff --git a/include/simgrid/actor.h b/include/simgrid/actor.h
new file mode 100644 (file)
index 0000000..63e3eb8
--- /dev/null
@@ -0,0 +1,40 @@
+/* Public interface to the Link datatype                                    */
+
+/* Copyright (c) 2018. 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. */
+
+#ifndef INCLUDE_SIMGRID_ACTOR_H_
+#define INCLUDE_SIMGRID_ACTOR_H_
+
+#include <simgrid/forward.h>
+#include <xbt/base.h>
+#include <xbt/dict.h>
+
+/* C interface */
+SG_BEGIN_DECL()
+/** @brief Actor datatype.
+    @ingroup m_actor_management
+
+    An actor may be defined as a <em>code</em>, with some <em>private data</em>, executing in a <em>location</em>.
+
+    You should not access directly to the fields of the pointed structure, but always use the provided API to interact
+    with actors.
+ */
+
+XBT_PUBLIC int sg_actor_get_PID(sg_actor_t actor);
+XBT_PUBLIC int sg_actor_get_PPID(sg_actor_t actor);
+XBT_PUBLIC const char* sg_actor_get_name(sg_actor_t actor);
+XBT_PUBLIC sg_host_t sg_actor_get_host(sg_actor_t actor);
+XBT_PUBLIC const char* sg_actor_get_property_value(sg_actor_t actor, const char* name);
+XBT_PUBLIC xbt_dict_t sg_actor_get_properties(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_suspend(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_resume(sg_actor_t actor);
+XBT_PUBLIC int sg_actor_is_suspended(sg_actor_t actor);
+XBT_PUBLIC sg_actor_t sg_actor_restart(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
+
+SG_END_DECL()
+
+#endif /* INCLUDE_SIMGRID_ACTOR_H_ */
index 392a3f8..7851a60 100644 (file)
@@ -132,6 +132,7 @@ typedef s4u_Link* sg_link_t;
 typedef s4u_Storage* sg_storage_t;
 typedef s4u_File* sg_file_t;
 typedef s4u_VM* sg_vm_t;
+typedef s4u_Actor* sg_actor_t;
 
 typedef routing_NetPoint* sg_netpoint_t;
 typedef surf_Resource *sg_resource_t;
index 8c160a5..b7a1fd5 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_MSG_H
 #define SIMGRID_MSG_H
 
+#include <simgrid/actor.h>
 #include <simgrid/forward.h>
 #include <simgrid/host.h>
 #include <simgrid/instr.h>
@@ -36,43 +37,44 @@ SG_BEGIN_DECL()
 #define msg_as_t msg_netzone_t /* portability macro */
 typedef sg_netzone_t msg_netzone_t;
 
-#define MSG_zone_get_root() sg_zone_get_root()
-#define MSG_zone_get_name(zone) sg_zone_get_name(zone)
-#define MSG_zone_get_by_name(name) sg_zone_get_by_name(name)
-#define MSG_zone_get_sons(zone, whereto) sg_zone_get_sons(zone, whereto)
-#define MSG_zone_get_property_value(zone, name) sg_zone_get_property_value(zone, name)
-#define MSG_zone_set_property_value(zone, name, value) sg_zone_set_property_value(zone, name, value)
-#define MSG_zone_get_hosts(zone, whereto) sg_zone_get_hosts(zone, whereto)
+XBT_PUBLIC msg_netzone_t MSG_zone_get_root();
+XBT_PUBLIC const char* MSG_zone_get_name(msg_netzone_t zone);
+XBT_PUBLIC msg_netzone_t MSG_zone_get_by_name(const char* name);
+XBT_PUBLIC void MSG_zone_get_sons(msg_netzone_t zone, xbt_dict_t whereto);
+XBT_PUBLIC const char* MSG_zone_get_property_value(msg_netzone_t zone, const char* name);
+XBT_PUBLIC void MSG_zone_set_property_value(msg_netzone_t zone, const char* name, char* value);
+XBT_PUBLIC void MSG_zone_get_hosts(msg_netzone_t zone, xbt_dynar_t whereto);
 
 /* ******************************** Hosts ************************************ */
 typedef sg_host_t msg_host_t;
 
-#define MSG_get_host_number() sg_host_count()
-#define MSG_get_host_by_name(n) sg_host_by_name(n) /* Rewrite the old name into the new one transparently */
-
-#define MSG_hosts_as_dynar() sg_hosts_as_dynar()
-
-#define MSG_host_by_name(name) sg_host_by_name(name)
-#define MSG_host_get_name(host) sg_host_get_name(host)
-#define MSG_host_get_data(host) sg_host_user(host)
-#define MSG_host_set_data(host, data) sg_host_user_set(host, data)
-#define MSG_host_get_mounted_storage_list(host) sg_host_get_mounted_storage_list(host)
-#define MSG_host_get_attached_storage_list(host) host_get_attached_storage_list(host)
-#define MSG_host_get_speed(host) sg_host_speed(host)
-#define MSG_host_get_power_peak_at(host, pstate_index) sg_host_get_pstate_speed(host, pstate_index)
-#define MSG_host_get_core_number(host) sg_host_core_count(host)
-#define MSG_host_self() sg_host_self()
-#define MSG_host_get_nb_pstates(host) sg_host_get_nb_pstates(host)
-#define MSG_host_get_pstate(h) sg_host_get_pstate(h)
-#define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate)
-#define MSG_host_on(h) sg_host_turn_on(h)
-#define MSG_host_off(h) sg_host_turn_off(h)
-#define MSG_host_is_on(h) sg_host_is_on(h)
-#define MSG_host_is_off(h) sg_host_is_off(h)
-#define MSG_host_get_properties(host) sg_host_get_properties(host)
-#define MSG_host_get_property_value(host, name) sg_host_get_property_value(host, name)
-#define MSG_host_set_property_value(host, name, value) sg_host_set_property_value(host, name, value)
-#define MSG_host_get_process_list(host, whereto) sg_host_get_actor_list(host, whereto)
+XBT_PUBLIC size_t MSG_get_host_number();
+XBT_PUBLIC sg_host_t MSG_get_host_by_name(const char* name);
+XBT_PUBLIC sg_host_t MSG_host_by_name(const char* name);
+
+XBT_PUBLIC xbt_dynar_t MSG_hosts_as_dynar();
+
+XBT_PUBLIC const char* MSG_host_get_name(sg_host_t host);
+XBT_PUBLIC void* MSG_host_get_data(sg_host_t host);
+XBT_PUBLIC void MSG_host_set_data(sg_host_t host, void* data);
+XBT_PUBLIC xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host);
+XBT_PUBLIC xbt_dynar_t MSG_host_get_attached_storage_listsg_host_t(sg_host_t host);
+XBT_PUBLIC double MSG_host_get_speed(sg_host_t host);
+XBT_PUBLIC double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index);
+XBT_PUBLIC int MSG_host_get_core_number(sg_host_t host);
+XBT_PUBLIC int MSG_host_get_nb_pstates(sg_host_t host);
+XBT_PUBLIC int MSG_host_get_pstate(sg_host_t host);
+XBT_PUBLIC void MSG_host_set_pstate(sg_host_t host, int pstate);
+XBT_PUBLIC void MSG_host_on(sg_host_t h);
+XBT_PUBLIC void MSG_host_off(sg_host_t h);
+XBT_PUBLIC int MSG_host_is_on(sg_host_t h);
+XBT_PUBLIC int MSG_host_is_off(sg_host_t h);
+XBT_PUBLIC xbt_dict_t MSG_host_get_properties(sg_host_t host);
+XBT_PUBLIC const char* MSG_host_get_property_value(sg_host_t host, const char* name);
+XBT_PUBLIC void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value);
+XBT_PUBLIC void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto);
+
+XBT_PUBLIC sg_host_t MSG_host_self();
 
 XBT_ATTRIB_DEPRECATED_v320("Use MSG_host_get_speed(): v3.20 will drop MSG_host_get_current_power_peak() "
                            "completely.") static inline double MSG_host_get_current_power_peak(msg_host_t host)
@@ -83,42 +85,61 @@ XBT_ATTRIB_DEPRECATED_v320("Use MSG_host_get_speed(): v3.20 will drop MSG_host_g
 /* ******************************** VMs ************************************* */
 typedef sg_vm_t msg_vm_t;
 
-#define MSG_vm_create_core(vm, name) sg_vm_create_core(vm, name)
-#define MSG_vm_create_multicore(vm, name, coreAmount) sg_vm_create_multicore(vm, name, coreAmount)
 XBT_ATTRIB_DEPRECATED_v322("Use sg_vm_create_migratable() from the live migration plugin: "
                            "v3.22 will drop MSG_vm_create() completely.") XBT_PUBLIC sg_vm_t
     MSG_vm_create(sg_host_t ind_pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity);
 
-#define MSG_vm_is_created(vm) sg_vm_is_created(vm)
-#define MSG_vm_is_running(vm) sg_vm_is_running(vm)
-#define MSG_vm_is_suspended(vm) sg_vm_is_suspended(vm)
+XBT_PUBLIC msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name);
+XBT_PUBLIC msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount);
 
-#define MSG_vm_get_name(vm) sg_vm_get_name(vm)
-#define MSG_vm_set_ramsize(vm, size) sg_vm_set_ramsize(vm, size)
-#define MSG_vm_get_ramsize(vm) sg_vm_get_ramsize(vm)
-#define MSG_vm_set_bound(vm, bound) sg_vm_set_bound(vm, bound)
-#define MSG_vm_get_pm(vm) sg_vm_get_pm(vm)
+XBT_PUBLIC int MSG_vm_is_created(msg_vm_t vm);
+XBT_PUBLIC int MSG_vm_is_running(msg_vm_t vm);
+XBT_PUBLIC int MSG_vm_is_suspended(msg_vm_t vm);
 
-#define MSG_vm_start(vm) sg_vm_start(vm)
-#define MSG_vm_suspend(vm) sg_vm_suspend(vm)
-#define MSG_vm_resume(vm) sg_vm_resume(vm)
-#define MSG_vm_shutdown(vm) sg_vm_shutdown(vm)
-#define MSG_vm_destroy(vm) sg_vm_destroy(vm)
+XBT_PUBLIC const char* MSG_vm_get_name(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_set_ramsize(msg_vm_t vm, size_t size);
+XBT_PUBLIC size_t MSG_vm_get_ramsize(msg_vm_t vm);
+XBT_PUBLIC msg_host_t MSG_vm_get_pm(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_set_bound(msg_vm_t vm, double bound);
 
-/* ******************************** Storage ************************************ */
+XBT_PUBLIC void MSG_vm_start(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_suspend(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_resume(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_shutdown(msg_vm_t vm);
+XBT_PUBLIC void MSG_vm_destroy(msg_vm_t vm);
+
+/* ******************************** Storage ********************************* */
 typedef sg_storage_t msg_storage_t;
 
-#define MSG_storage_get_name(storage) sg_storage_get_name(storage)
-#define MSG_storage_get_by_name(name) sg_storage_get_by_name(name)
-#define MSG_storage_get_properties(storage) sg_storage_get_properties(storage)
-#define MSG_storage_set_property_value(storage, name, value) sg_storage_set_property_value(storage, name, value)
-#define MSG_storage_get_property_value(storage, name) sg_storage_get_property_value(storage, name)
-#define MSG_storages_as_dynar() sg_storages_as_dynar()
-#define MSG_storage_set_data(storage, data) sg_storage_set_data(storage, data)
-#define MSG_storage_get_data(storage) sg_storage_get_data(storage)
-#define MSG_storage_get_host(storage) sg_storage_get_host(storage)
-#define MSG_storage_read(storage, size) sg_storage_read(storage, size)
-#define MSG_storage_write(storage, size) sg_storage_write(storage, size)
+XBT_PUBLIC const char* MSG_storage_get_name(msg_storage_t storage);
+XBT_PUBLIC msg_storage_t MSG_storage_get_by_name(const char* name);
+XBT_PUBLIC xbt_dict_t MSG_storage_get_properties(msg_storage_t storage);
+XBT_PUBLIC void MSG_storage_set_property_value(msg_storage_t storage, const char* name, const char* value);
+XBT_PUBLIC const char* MSG_storage_get_property_value(msg_storage_t storage, const char* name);
+XBT_PUBLIC xbt_dynar_t MSG_storages_as_dynar();
+XBT_PUBLIC void MSG_storage_set_data(msg_storage_t storage, void* data);
+XBT_PUBLIC void* MSG_storage_get_data(msg_storage_t storage);
+XBT_PUBLIC const char* MSG_storage_get_host(msg_storage_t storage);
+XBT_PUBLIC sg_size_t MSG_storage_read(msg_storage_t storage, sg_size_t size);
+XBT_PUBLIC sg_size_t MSG_storage_write(msg_storage_t storage, sg_size_t size);
+
+/* ******************************** Actor/process *************************** */
+typedef sg_actor_t msg_process_t;
+
+XBT_PUBLIC int MSG_process_get_PID(msg_process_t process);
+XBT_PUBLIC int MSG_process_get_PPID(msg_process_t process);
+XBT_PUBLIC const char* MSG_process_get_name(msg_process_t process);
+XBT_PUBLIC sg_host_t MSG_process_get_host(msg_process_t process);
+
+/*property handlers*/
+XBT_PUBLIC xbt_dict_t MSG_process_get_properties(msg_process_t process);
+XBT_PUBLIC const char* MSG_process_get_property_value(msg_process_t process, const char* name);
+
+XBT_PUBLIC void MSG_process_suspend(msg_process_t process);
+XBT_PUBLIC void MSG_process_resume(msg_process_t process);
+XBT_PUBLIC int MSG_process_is_suspended(msg_process_t process);
+XBT_PUBLIC void MSG_process_restart(msg_process_t process);
+XBT_PUBLIC void MSG_process_daemonize(msg_process_t process);
 
 /* ******************************** File ************************************ */
 typedef sg_file_t msg_file_t;
@@ -159,20 +180,6 @@ typedef struct msg_task* msg_task_t;
 */
 #define MSG_TASK_UNINITIALIZED NULL
 
-/* ****************************** Process *********************************** */
-
-/** @brief Process datatype.
-    @ingroup m_process_management
-
-    A process may be defined as a <em>code</em>, with some
-    <em>private data</em>, executing in a <em>location</em>.
-
-    You should not access directly to the fields of the pointed
-    structure, but always use the provided API to interact with
-    processes.
- */
-typedef s4u_Actor* msg_process_t;
-
 /** @brief Return code of most MSG functions
     @ingroup msg_simulation
     @{ */
@@ -235,14 +242,8 @@ XBT_PUBLIC int MSG_process_killall();
 XBT_PUBLIC msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host);
 XBT_PUBLIC void MSG_process_yield();
 
-XBT_PUBLIC void* MSG_process_get_data(msg_process_t process);
-XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
 XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
-XBT_PUBLIC msg_host_t MSG_process_get_host(msg_process_t process);
 XBT_PUBLIC msg_process_t MSG_process_from_PID(int PID);
-XBT_PUBLIC int MSG_process_get_PID(msg_process_t process);
-XBT_PUBLIC int MSG_process_get_PPID(msg_process_t process);
-XBT_PUBLIC const char* MSG_process_get_name(msg_process_t process);
 XBT_PUBLIC int MSG_process_self_PID();
 XBT_PUBLIC int MSG_process_self_PPID();
 XBT_PUBLIC const char* MSG_process_self_name();
@@ -252,18 +253,12 @@ XBT_PUBLIC int MSG_process_get_number();
 
 XBT_PUBLIC msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time);
 
-/*property handlers*/
-XBT_PUBLIC xbt_dict_t MSG_process_get_properties(msg_process_t process);
-XBT_PUBLIC const char* MSG_process_get_property_value(msg_process_t process, const char* name);
+XBT_PUBLIC void* MSG_process_get_data(msg_process_t process);
+XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
 
-XBT_PUBLIC msg_error_t MSG_process_suspend(msg_process_t process);
-XBT_PUBLIC msg_error_t MSG_process_resume(msg_process_t process);
-XBT_PUBLIC int MSG_process_is_suspended(msg_process_t process);
 XBT_PUBLIC void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void* data);
 XBT_PUBLIC void MSG_process_auto_restart_set(msg_process_t process, int auto_restart);
 
-XBT_PUBLIC void MSG_process_daemonize(msg_process_t process);
-XBT_PUBLIC msg_process_t MSG_process_restart(msg_process_t process);
 XBT_PUBLIC void MSG_process_ref(msg_process_t process);
 XBT_PUBLIC void MSG_process_unref(msg_process_t process);
 
index 1e13c93..63d5673 100644 (file)
@@ -100,7 +100,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_daemonize(JNIEnv* env, jobje
     return;
   }
 
-  MSG_process_daemonize(process);
+  process->daemonize();
 }
 
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll(JNIEnv* env, jclass cls)
@@ -171,10 +171,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobjec
     return;
   }
 
-  /* try to suspend the process */
-  msg_error_t rv = MSG_process_suspend(process);
-
-  jxbt_check_res("MSG_process_suspend()", rv, MSG_OK, "unexpected error , please report this bug");
+  /* suspend the process */
+  process->suspend();
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject jprocess)
@@ -186,9 +184,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject
     return;
   }
 
-  /* try to resume the process */
-  msg_error_t res = MSG_process_resume(process);
-  jxbt_check_res("MSG_process_resume()", res, MSG_OK, "unexpected error , please report this bug");
+  /* resume the process */
+  process->resume();
 }
 
 JNIEXPORT void
@@ -211,7 +208,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *env, jobjec
     return;
   }
 
-  MSG_process_restart(process);
+  process->restart();
 }
 
 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env, jobject jprocess)
@@ -224,7 +221,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env
   }
 
   /* true is the process is suspended, false otherwise */
-  return (jboolean) MSG_process_is_suspended(process);
+  return (jboolean)process->isSuspended();
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cls, jlong jmillis, jint jnanos)
index 076996c..b4abc6a 100644 (file)
@@ -7,6 +7,7 @@
 #include "src/instr/instr_private.hpp"
 #include "src/msg/msg_private.hpp"
 #include "src/simix/ActorImpl.hpp"
+#include <simgrid/actor.h>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process");
 
index b283bd6..d352e3e 100644 (file)
@@ -277,15 +277,6 @@ XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup)
   msg_global->process_data_cleanup = data_cleanup;
 }
 
-msg_host_t MSG_process_get_host(msg_process_t process)
-{
-  if (process == nullptr) {
-    return SIMIX_process_self()->host;
-  } else {
-    return process->getHost();
-  }
-}
-
 /** \ingroup m_process_management
  *
  * \brief Return a #msg_process_t given its PID.
@@ -327,70 +318,6 @@ msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time)
   return MSG_OK;
 }
 
-/** \ingroup m_process_management
- * \brief Returns the process ID of \a process.
- *
- * This function checks whether \a process is a valid pointer and return its PID (or 0 in case of problem).
- */
-int MSG_process_get_PID(msg_process_t process)
-{
-  /* Do not raise an exception here: this function is called by the logs
-   * and the exceptions, so it would be called back again and again */
-  if (process == nullptr || process->getImpl() == nullptr)
-    return 0;
-  return process->getPid();
-}
-
-/** \ingroup m_process_management
- * \brief Returns the process ID of the parent of \a process.
- *
- * This function checks whether \a process is a valid pointer and return its PID.
- * Returns -1 if the process has not been created by any other process.
- */
-int MSG_process_get_PPID(msg_process_t process)
-{
-  return process->getPpid();
-}
-
-/** \ingroup m_process_management
- * \brief Return the name of a process.
- *
- * This function checks whether \a process is a valid pointer and return its name.
- */
-const char *MSG_process_get_name(msg_process_t process)
-{
-  return process->getCname();
-}
-
-/** \ingroup m_process_management
- * \brief Returns the value of a given process property
- *
- * \param process a process
- * \param name a property name
- * \return value of a property (or nullptr if the property is not set)
- */
-const char *MSG_process_get_property_value(msg_process_t process, const char *name)
-{
-  return process->getProperty(name);
-}
-
-/** \ingroup m_process_management
- * \brief Return the list of properties
- *
- * This function returns all the parameters associated with a process
- */
-xbt_dict_t MSG_process_get_properties(msg_process_t process)
-{
-  xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
-  std::map<std::string, std::string>* props = process->getProperties();
-  if (props == nullptr)
-    return nullptr;
-  for (auto const& elm : *props) {
-    xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
-  }
-  return as_dict;
-}
 
 /** \ingroup m_process_management
  * \brief Return the PID of the current process.
@@ -431,40 +358,6 @@ msg_process_t MSG_process_self()
   return SIMIX_process_self()->ciface();
 }
 
-/** \ingroup m_process_management
- * \brief Suspend the process.
- *
- * This function suspends the process by suspending the task on which it was waiting for the completion.
- */
-msg_error_t MSG_process_suspend(msg_process_t process)
-{
-  xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  process->suspend();
-  return MSG_OK;
-}
-
-/** \ingroup m_process_management
- * \brief Resume a suspended process.
- *
- * This function resumes a suspended process by resuming the task on which it was waiting for the completion.
- */
-msg_error_t MSG_process_resume(msg_process_t process)
-{
-  xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  process->resume();
-  return MSG_OK;
-}
-
-/** \ingroup m_process_management
- * \brief Returns true if the process is suspended .
- *
- * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
- */
-int MSG_process_is_suspended(msg_process_t process)
-{
-  return process->isSuspended();
-}
-
 smx_context_t MSG_process_get_smx_ctx(msg_process_t process) {
   return process->getImpl()->context;
 }
@@ -486,22 +379,6 @@ XBT_PUBLIC void MSG_process_auto_restart_set(msg_process_t process, int auto_res
 {
   process->setAutoRestart(auto_restart);
 }
-/**
- * \ingroup m_process_management
- * \brief Restarts a process from the beginning.
- */
-XBT_PUBLIC msg_process_t MSG_process_restart(msg_process_t process)
-{
-  return process->restart();
-}
-
-/** @ingroup m_process_management
- * @brief This process will be terminated automatically when the last non-daemon process finishes
- */
-XBT_PUBLIC void MSG_process_daemonize(msg_process_t process)
-{
-  process->daemonize();
-}
 
 /** @ingroup m_process_management
  * @brief Take an extra reference on that process to prevent it to be garbage-collected
index acc61c3..c08518a 100644 (file)
@@ -309,4 +309,25 @@ void sg_vm_destroy(sg_vm_t vm)
 {
   vm->destroy();
 }
+/* ************************** Backward ABI compatibility *************************** */
+sg_vm_t MSG_vm_create_core(sg_host_t pm, const char* name) __attribute__((alias("sg_vm_create_core")));
+sg_vm_t MSG_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount)
+    __attribute__((alias("sg_vm_create_multicore")));
+
+int MSG_vm_is_created(sg_vm_t vm) __attribute__((alias("sg_vm_is_created")));
+int MSG_vm_is_running(sg_vm_t vm) __attribute__((alias("sg_vm_is_running")));
+int MSG_vm_is_suspended(sg_vm_t vm) __attribute__((alias("sg_vm_is_suspended")));
+
+const char* MSG_vm_get_name(sg_vm_t vm) __attribute__((alias("sg_vm_get_name")));
+void MSG_vm_set_ramsize(sg_vm_t vm, size_t size) __attribute__((alias("sg_vm_set_ramsize")));
+size_t MSG_vm_get_ramsize(sg_vm_t vm) __attribute__((alias("sg_vm_get_ramsize")));
+sg_host_t MSG_vm_get_pm(sg_vm_t vm) __attribute__((alias("sg_vm_get_pm")));
+void MSG_vm_set_bound(sg_vm_t vm, double bound) __attribute__((alias("sg_vm_set_bound")));
+
+void MSG_vm_start(sg_vm_t vm) __attribute__((alias("sg_vm_start")));
+void MSG_vm_suspend(sg_vm_t vm) __attribute__((alias("sg_vm_suspend")));
+void MSG_vm_resume(sg_vm_t vm) __attribute__((alias("sg_vm_resume")));
+void MSG_vm_shutdown(sg_vm_t vm) __attribute__((alias("sg_vm_shutdown")));
+void MSG_vm_destroy(sg_vm_t vm) __attribute__((alias("sg_vm_destroy")));
+
 SG_END_DECL()
index b9957b2..abb52ce 100644 (file)
@@ -403,6 +403,140 @@ void migrate(Host* new_host)
 {
   SIMIX_process_self()->iface()->migrate(new_host);
 }
+} // namespace this_actor
+} // namespace s4u
+} // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+SG_BEGIN_DECL()
+/** \ingroup m_actor_management
+ * \brief Returns the process ID of \a actor.
+ *
+ * This function checks whether \a actor is a valid pointer and return its PID (or 0 in case of problem).
+ */
+int sg_actor_get_PID(sg_actor_t actor)
+{
+  /* Do not raise an exception here: this function is called by the logs
+   * and the exceptions, so it would be called back again and again */
+  if (actor == nullptr || actor->getImpl() == nullptr)
+    return 0;
+  return actor->getPid();
+}
+
+/** \ingroup m_actor_management
+ * \brief Returns the process ID of the parent of \a actor.
+ *
+ * This function checks whether \a actor is a valid pointer and return its parent's PID.
+ * Returns -1 if the actor has not been created by any other actor.
+ */
+int sg_actor_get_PPID(sg_actor_t actor)
+{
+  return actor->getPpid();
+}
+
+/** \ingroup m_actor_management
+ * \brief Return the name of an actor.
+ */
+const char* sg_actor_get_name(sg_actor_t actor)
+{
+  return actor->getCname();
+}
+
+sg_host_t sg_actor_get_host(sg_actor_t actor)
+{
+  return actor->getHost();
+}
+
+/** \ingroup m_actor_management
+ * \brief Returns the value of a given actor property
+ *
+ * \param actor an actor
+ * \param name a property name
+ * \return value of a property (or nullptr if the property is not set)
+ */
+const char* sg_actor_get_property_value(sg_actor_t actor, const char* name)
+{
+  return actor->getProperty(name);
+}
+
+/** \ingroup m_actor_management
+ * \brief Return the list of properties
+ *
+ * This function returns all the parameters associated with an actor
+ */
+xbt_dict_t sg_actor_get_properties(sg_actor_t actor)
+{
+  xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
+  xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
+  std::map<std::string, std::string>* props = actor->getProperties();
+  if (props == nullptr)
+    return nullptr;
+  for (auto const& elm : *props) {
+    xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
+  }
+  return as_dict;
+}
+
+/** \ingroup m_actor_management
+ * \brief Suspend the actor.
+ *
+ * This function suspends the actor by suspending the task on which it was waiting for the completion.
+ */
+void sg_actor_suspend(sg_actor_t actor)
+{
+  xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
+  actor->suspend();
+}
+
+/** \ingroup m_actor_management
+ * \brief Resume a suspended actor.
+ *
+ * This function resumes a suspended actor by resuming the task on which it was waiting for the completion.
+ */
+void sg_actor_resume(sg_actor_t actor)
+{
+  xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
+  actor->resume();
 }
+
+/** \ingroup m_actor_management
+ * \brief Returns true if the actor is suspended .
+ *
+ * This checks whether an actor is suspended or not by inspecting the task on which it was waiting for the completion.
+ */
+int sg_actor_is_suspended(sg_actor_t actor)
+{
+  return actor->isSuspended();
 }
+
+/**
+ * \ingroup m_actor_management
+ * \brief Restarts an actor from the beginning.
+ */
+sg_actor_t sg_actor_restart(sg_actor_t actor)
+{
+  return actor->restart();
 }
+
+/** @ingroup m_actor_management
+ * @brief This actor will be terminated automatically when the last non-daemon actor finishes
+ */
+void sg_actor_daemonize(sg_actor_t actor)
+{
+  actor->daemonize();
+}
+
+/* ************************** Backward ABI compatibility *************************** */
+int MSG_process_get_PID(sg_actor_t actor) __attribute__((alias("sg_actor_get_PID")));
+int MSG_process_get_PPID(sg_actor_t actor) __attribute__((alias("sg_actor_get_PPID")));
+const char* MSG_process_get_name(sg_actor_t actor) __attribute__((alias("sg_actor_get_name")));
+sg_host_t MSG_process_get_host(sg_actor_t actor) __attribute__((alias("sg_actor_get_host")));
+xbt_dict_t MSG_process_get_properties(sg_actor_t actor) __attribute__((alias("sg_actor_get_properties")));
+const char* MSG_process_get_property_value(sg_actor_t actor, const char* name)
+    __attribute__((alias("sg_actor_get_property_value")));
+void MSG_process_suspend(sg_actor_t actor) __attribute__((alias("sg_actor_suspend")));
+void MSG_process_resume(sg_actor_t actor) __attribute__((alias("sg_actor_resume")));
+int MSG_process_is_suspended(sg_actor_t actor) __attribute__((alias("sg_actor_is_suspended")));
+void MSG_process_restart(sg_actor_t actor) __attribute__((alias("sg_actor_restart")));
+void MSG_process_daemonize(sg_actor_t actor) __attribute__((alias("sg_actor_daemonize")));
+SG_END_DECL()
index b17967d..b526fbf 100644 (file)
@@ -156,4 +156,22 @@ void sg_zone_get_hosts(sg_netzone_t netzone, xbt_dynar_t whereto)
     xbt_dynar_push(whereto, &host);
 }
 
+/* ************************** Backward ABI compatibility *************************** */
+sg_netzone_t MSG_zone_get_root() __attribute__((alias("sg_zone_get_root")));
+;
+const char* MSG_zone_get_name(sg_netzone_t zone) __attribute__((alias("sg_zone_get_name")));
+;
+sg_netzone_t MSG_zone_get_by_name(const char* name) __attribute__((alias("sg_zone_get_by_name")));
+;
+void MSG_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto) __attribute__((alias("sg_zone_get_sons")));
+;
+const char* MSG_zone_get_property_value(sg_netzone_t zone, const char* name)
+    __attribute__((alias("sg_zone_get_property_value")));
+;
+void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, char* value)
+    __attribute__((alias("sg_zone_set_property_value")));
+;
+void MSG_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto) __attribute__((alias("sg_zone_get_hosts")));
+;
+
 SG_END_DECL()
index e2f66aa..f08f242 100644 (file)
@@ -202,4 +202,20 @@ sg_size_t sg_storage_write(sg_storage_t storage, sg_size_t size)
 {
   return storage->write(size);
 }
+
+/* ************************** Backward ABI compatibility *************************** */
+const char* MSG_storage_get_name(sg_storage_t storage) __attribute__((alias("sg_storage_get_name")));
+sg_storage_t MSG_storage_get_by_name(const char* name) __attribute__((alias("sg_storage_get_by_name")));
+xbt_dict_t MSG_storage_get_properties(sg_storage_t storage) __attribute__((alias("sg_storage_get_properties")));
+void MSG_storage_set_property_value(sg_storage_t storage, const char* name, const char* value)
+    __attribute__((alias("sg_storage_set_property_value")));
+const char* MSG_storage_get_property_value(sg_storage_t storage, const char* name)
+    __attribute__((alias("sg_storage_get_property_value")));
+xbt_dynar_t MSG_storages_as_dynar() __attribute__((alias("sg_storages_as_dynar")));
+void MSG_storage_set_data(sg_storage_t storage, void* data) __attribute__((alias("sg_storage_set_data")));
+void* MSG_storage_get_data(sg_storage_t storage) __attribute__((alias("sg_storage_get_data")));
+const char* MSG_storage_get_host(sg_storage_t storage) __attribute__((alias("sg_storage_get_host")));
+sg_size_t MSG_storage_read(sg_storage_t storage, sg_size_t size) __attribute__((alias("sg_storage_read")));
+sg_size_t MSG_storage_write(sg_storage_t storage, sg_size_t size) __attribute__((alias("sg_storage_write")));
+
 SG_END_DECL()
index 9e24002..a663add 100644 (file)
@@ -333,4 +333,41 @@ void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto)
   }
 }
 
+sg_host_t sg_host_self()
+{
+  smx_actor_t process = SIMIX_process_self();
+  return (process == nullptr) ? nullptr : process->host;
+}
+
+/* ************************** Backward ABI compatibility *************************** */
+xbt_dynar_t MSG_hosts_as_dynar() __attribute__((alias("sg_hosts_as_dynar")));
+
+size_t MSG_get_host_number() __attribute__((alias("sg_host_count")));
+sg_host_t MSG_get_host_by_name(const char* name) __attribute__((alias("sg_host_by_name")));
+sg_host_t MSG_host_by_name(const char* name) __attribute__((alias("sg_host_by_name")));
+
+const char* MSG_host_get_name(sg_host_t host) __attribute__((alias("sg_host_get_name")));
+void* MSG_host_get_data(sg_host_t host) __attribute__((alias("sg_host_user")));
+void MSG_host_set_data(sg_host_t host, void* data) __attribute__((alias("sg_host_user_set")));
+xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host) __attribute__((alias("sg_host_get_mounted_storage_list")));
+xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host)
+    __attribute__((alias("sg_host_get_attached_storage_list")));
+double MSG_host_get_speed(sg_host_t host) __attribute__((alias("sg_host_speed")));
+double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index) __attribute__((alias("sg_host_get_pstate_speed")));
+int MSG_host_get_core_number(sg_host_t host) __attribute__((alias("sg_host_core_count")));
+int MSG_host_get_nb_pstates(sg_host_t host) __attribute__((alias("sg_host_get_nb_pstates")));
+int MSG_host_get_pstate(sg_host_t host) __attribute__((alias("sg_host_get_pstate")));
+void MSG_host_set_pstate(sg_host_t host, int pstate) __attribute__((alias("sg_host_set_pstate")));
+void MSG_host_on(sg_host_t h) __attribute__((alias("sg_host_turn_on")));
+void MSG_host_off(sg_host_t h) __attribute__((alias("sg_host_turn_off")));
+int MSG_host_is_on(sg_host_t h) __attribute__((alias("sg_host_is_on")));
+int MSG_host_is_off(sg_host_t h) __attribute__((alias("sg_host_is_off")));
+xbt_dict_t MSG_host_get_properties(sg_host_t host) __attribute__((alias("sg_host_get_properties")));
+const char* MSG_host_get_property_value(sg_host_t host, const char* name)
+    __attribute__((alias("sg_host_get_property_value")));
+void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value)
+    __attribute__((alias("sg_host_set_property_value")));
+void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto) __attribute__((alias("sg_host_get_actor_list")));
+sg_host_t MSG_host_self() __attribute__((alias("sg_host_self")));
+
 } // extern "C"
index 1dea2c9..a51febd 100644 (file)
@@ -85,12 +85,6 @@ void SIMIX_host_off(sg_host_t h, smx_actor_t issuer)
   }
 }
 
-sg_host_t sg_host_self()
-{
-  smx_actor_t process = SIMIX_process_self();
-  return (process == nullptr) ? nullptr : process->host;
-}
-
 /* needs to be public and without simcall for exceptions and logging events */
 const char* sg_host_self_get_name()
 {
index 168cacd..1138002 100644 (file)
@@ -659,6 +659,7 @@ set(MC_SIMGRID_MC_SRC  src/mc/checker/simgrid_mc.cpp)
 
 set(headers_to_install
 
+  include/simgrid/actor.h
   include/simgrid/chrono.hpp
   include/simgrid/plugins/dvfs.h
   include/simgrid/plugins/energy.h