Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
inline a function called once
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 1 Mar 2016 11:08:53 +0000 (12:08 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 1 Mar 2016 11:08:53 +0000 (12:08 +0100)
include/simgrid/host.h
src/msg/msg_global.cpp
src/simgrid/host.cpp
src/simix/smx_global.cpp
src/surf/surf_interface.cpp

index b73a25d..2555b46 100644 (file)
@@ -46,9 +46,6 @@ XBT_PUBLIC(smx_host_priv_t) sg_host_simix(sg_host_t host);
 XBT_PUBLIC(void) sg_host_simix_set(sg_host_t host, smx_host_priv_t priv);
 XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host);
 
-// Module initializer. Won't survive the conversion to C++. Hopefully.
-XBT_PUBLIC(void) sg_host_init(void);
-
 // ========= storage related functions ============
 XBT_PUBLIC(xbt_dict_t) sg_host_get_mounted_storage_list(sg_host_t host);
 XBT_PUBLIC(xbt_dynar_t) sg_host_get_attached_storage_list(sg_host_t host);
index ba38cae..bc81e86 100644 (file)
@@ -63,6 +63,10 @@ void MSG_init_nocheck(int *argc, char **argv) {
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       MSG_host_create_(&host);
     });
+    MSG_HOST_LEVEL = simgrid::s4u::Host::extension_create([](void *p) {
+      __MSG_host_priv_free((msg_host_priv_t) p);
+    });
+
   }
 
   if(MC_is_active()){
index 98049d9..7963b08 100644 (file)
@@ -75,21 +75,9 @@ xbt_dynar_t sg_hosts_as_dynar(void)
 
 // ========= Layering madness ==============*
 
-#include "src/msg/msg_private.h" // MSG_host_priv_free. FIXME: killme by initializing that level in msg when used
-#include "src/simix/smx_host_private.h" // SIMIX_host_destroy. FIXME: killme by initializing that level in simix when used
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/surf_routing.hpp"
 
-void sg_host_init()
-{
-  MSG_HOST_LEVEL = simgrid::s4u::Host::extension_create([](void *p) {
-    __MSG_host_priv_free((msg_host_priv_t) p);
-  });
-
-  SIMIX_HOST_LEVEL = simgrid::s4u::Host::extension_create(SIMIX_host_destroy);
-  USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(NULL);
-}
-
 // ========== User data Layer ==========
 void *sg_host_user(sg_host_t host) {
   return host->extension(USER_HOST_LEVEL);
index 9786b8c..68e296f 100644 (file)
@@ -253,6 +253,8 @@ void SIMIX_global_init(int *argc, char **argv)
     simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
       SIMIX_host_create(&host);
     });
+    SIMIX_HOST_LEVEL = simgrid::s4u::Host::extension_create(SIMIX_host_destroy);
+
     simgrid::surf::storageCreatedCallbacks.connect([](simgrid::surf::Storage* storage) {
       const char* id = storage->getName();
         // TODO, create sg_storage_by_name
index 6f02607..62b0fc5 100644 (file)
@@ -303,13 +303,14 @@ void surf_init(int *argc, char **argv)
     simgrid::s4u::Host::onDestruction(*host);
     delete host;
   });
+  USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(NULL);
+
   as_router_lib = xbt_lib_new();
   storage_lib = xbt_lib_new();
   storage_type_lib = xbt_lib_new();
   file_lib = xbt_lib_new();
   watched_hosts_lib = xbt_dict_new_homogeneous(NULL);
 
-  sg_host_init();
 
   XBT_DEBUG("Add routing levels");
   ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib, NULL);