From: Gabriel Corona Date: Tue, 12 Jan 2016 11:24:12 +0000 (+0100) Subject: Revert "remove a C-like pimple" X-Git-Tag: v3_13~1272 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/580571dfe8586fd74fd66b948d03dbddfb6f58d3 Revert "remove a C-like pimple" This reverts commit 71c619779ed661b50ce589403a0f4df7ab0865de. This commits generates a lot of segfaults. --- diff --git a/src/surf/host_interface.cpp b/src/surf/host_interface.cpp index bc4e28650b..a4367e1e9f 100644 --- a/src/surf/host_interface.cpp +++ b/src/surf/host_interface.cpp @@ -31,10 +31,7 @@ void host_add_traces(){ namespace simgrid { namespace surf { -simgrid::xbt::Extension Host::EXTENSION_ID = - simgrid::Host::extension_create([](void *h) { - static_cast(h)->destroy(); - }); +simgrid::xbt::Extension Host::EXTENSION_ID; /********* * Model * @@ -89,6 +86,15 @@ simgrid::surf::signal Host::onCreation; simgrid::surf::signal Host::onDestruction; simgrid::surf::signal Host::onStateChange; +void Host::classInit() +{ + if (!EXTENSION_ID.valid()) { + EXTENSION_ID = simgrid::Host::extension_create([](void *h) { + static_cast(h)->destroy(); + }); + } +} + Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props, xbt_dynar_t storage, Cpu *cpu) : Resource(model, name) diff --git a/src/surf/host_interface.hpp b/src/surf/host_interface.hpp index a907656cbd..236ccdb038 100644 --- a/src/surf/host_interface.hpp +++ b/src/surf/host_interface.hpp @@ -84,6 +84,7 @@ public: static simgrid::surf::signal onStateChange; /** Called when the machine is turned on or off */ public: + static void classInit(); // must be called before the first use of that class /** * @brief Host constructor * diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index a69aac5714..b8d0eafb36 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -318,6 +318,7 @@ void surf_init(int *argc, char **argv) ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free); XBT_DEBUG("Add SURF levels"); + simgrid::surf::Host::classInit(); SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free); xbt_init(argc, argv);