Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix https://framagit.org/simgrid/simgrid/issues/28
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 9 Jul 2019 22:11:38 +0000 (00:11 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 9 Jul 2019 22:11:38 +0000 (00:11 +0200)
* move 2 other MSGfunctions to legacy
* do not call MSG from XBT anymore

include/simgrid/actor.h
include/simgrid/msg.h
src/msg/msg_legacy.cpp
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/xbt/xbt_virtu.c

index 4dddd46..f32860d 100644 (file)
@@ -42,6 +42,11 @@ XBT_PUBLIC void sg_actor_yield();
 XBT_PUBLIC void sg_actor_sleep_for(double duration);
 XBT_PUBLIC sg_actor_t sg_actor_attach(const char* name, void* data, sg_host_t host, xbt_dict_t properties);
 XBT_PUBLIC void sg_actor_detach();
+XBT_PUBLIC sg_actor_t sg_actor_self();
+XBT_PUBLIC aid_t sg_actor_self_get_pid();
+XBT_PUBLIC aid_t sg_actor_self_get_ppid();
+XBT_PUBLIC const char* sg_actor_self_get_name();
+
 SG_END_DECL()
 
 #endif /* INCLUDE_SIMGRID_ACTOR_H_ */
index 49026ac..46b6e67 100644 (file)
@@ -235,6 +235,10 @@ XBT_PUBLIC void MSG_process_set_kill_time(msg_process_t process, double kill_tim
 XBT_PUBLIC void MSG_process_yield();
 /*** @brief Sleep for the specified number of seconds */
 XBT_PUBLIC msg_error_t MSG_process_sleep(double nb_sec);
+XBT_PUBLIC msg_process_t MSG_process_self();
+XBT_PUBLIC aid_t MSG_process_self_PID();
+XBT_PUBLIC aid_t MSG_process_self_PPID();
+XBT_PUBLIC const char* MSG_process_self_name();
 
 /** @brief Object representing an ongoing communication between processes.
  *
@@ -320,10 +324,6 @@ XBT_PUBLIC msg_process_t MSG_process_attach(const char* name, void* data, msg_ho
 XBT_PUBLIC void MSG_process_detach();
 
 XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
-XBT_PUBLIC int MSG_process_self_PID();
-XBT_PUBLIC int MSG_process_self_PPID();
-XBT_PUBLIC const char* MSG_process_self_name();
-XBT_PUBLIC msg_process_t MSG_process_self();
 XBT_PUBLIC xbt_dynar_t MSG_processes_as_dynar();
 XBT_PUBLIC int MSG_process_get_number();
 
index 9cedca5..31239fe 100644 (file)
@@ -144,6 +144,33 @@ void MSG_process_detach()
 {
   sg_actor_detach();
 }
+aid_t MSG_process_self_PID()
+{
+  return sg_actor_self_get_pid();
+}
+
+/** @brief Return the PPID of the current process.
+ *
+ * This function returns the PID of the parent of the currently running #msg_process_t.
+ */
+aid_t MSG_process_self_PPID()
+{
+  return sg_actor_self_get_ppid();
+}
+
+/** @brief Return the name of the current process. */
+const char* MSG_process_self_name()
+{
+  return sg_actor_self_get_name();
+}
+/** @brief Return the current process.
+ *
+ * This function returns the currently running #msg_process_t.
+ */
+msg_process_t MSG_process_self()
+{
+  return sg_actor_self();
+}
 
 /* ************************** NetZones *************************** */
 sg_netzone_t MSG_zone_get_root()
index b50cdb5..cb98064 100644 (file)
@@ -168,40 +168,6 @@ int MSG_process_get_number()
   return SIMIX_process_count();
 }
 
-/** @brief Return the PID of the current process.
- *
- * This function returns the PID of the currently running #msg_process_t.
- */
-int MSG_process_self_PID()
-{
-  smx_actor_t self = SIMIX_process_self();
-  return self == nullptr ? 0 : self->get_pid();
-}
-
-/** @brief Return the PPID of the current process.
- *
- * This function returns the PID of the parent of the currently running #msg_process_t.
- */
-int MSG_process_self_PPID()
-{
-  return MSG_process_get_PPID(MSG_process_self());
-}
-
-/** @brief Return the name of the current process. */
-const char* MSG_process_self_name()
-{
-  return SIMIX_process_self_get_name();
-}
-
-/** @brief Return the current process.
- *
- * This function returns the currently running #msg_process_t.
- */
-msg_process_t MSG_process_self()
-{
-  return SIMIX_process_self()->ciface();
-}
-
 /** @brief Add a function to the list of "on_exit" functions for the current process.
  *  The on_exit functions are the functions executed when your process is killed.
  *  You should use them to free the data used by your process.
index 0db6b20..26d0591 100644 (file)
@@ -668,3 +668,23 @@ void sg_actor_detach()
 {
   simgrid::kernel::actor::ActorImpl::detach();
 }
+
+aid_t sg_actor_self_get_pid()
+{
+  return simgrid::s4u::this_actor::get_pid();
+}
+
+aid_t sg_actor_self_get_ppid()
+{
+  return simgrid::s4u::this_actor::get_ppid();
+}
+
+const char* sg_actor_self_get_name()
+{
+  return simgrid::s4u::this_actor::get_cname();
+}
+
+sg_actor_t sg_actor_self()
+{
+  return simgrid::s4u::Actor::self();
+}
index 628911f..9032b78 100644 (file)
@@ -5,15 +5,17 @@
 /* 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/msg.h"
+#include "simgrid/actor.h"
+#include "simgrid/simix.h"
 #include "xbt/virtu.h"
 
 int xbt_getpid()
 {
-  return MSG_process_self_PID();
+  smx_actor_t self = SIMIX_process_self();
+  return self == NULL ? 0 : sg_actor_self_get_pid();
 }
 
 const char *xbt_procname(void)
 {
-  return MSG_process_self_name();
+  return SIMIX_process_self_get_name();
 }