Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ongoing attempt for sthread, an automatic intercepter of pthread operations
[simgrid.git] / src / xbt / xbt_main.cpp
index 1dc8020..f452565 100644 (file)
@@ -10,6 +10,7 @@
 #include "simgrid/config.h"
 #include "simgrid/sg_config.hpp"
 #include "src/internal_config.h"
+#include "src/sthread/sthread.h" // sthread_inside_simgrid
 #include "xbt/config.hpp"
 #include "xbt/coverage.h"
 #include "xbt/dynar.h"
@@ -40,6 +41,8 @@ std::string binary_name;          /* Name of the system process containing us (m
 std::vector<std::string> cmdline; /* all we got in argv */
 } // namespace simgrid::xbt
 
+int sthread_inside_simgrid = 0; // whether sthread should leave pthread operations or intercept them.
+
 int xbt_initialized = 0;
 simgrid::config::Flag<bool> cfg_dbg_clean_atexit{
     "debug/clean-atexit",
@@ -79,6 +82,7 @@ static BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserv
 
 static void xbt_preinit()
 {
+  sthread_inside_simgrid = 1;
 #ifdef _WIN32
   SYSTEM_INFO si;
   GetSystemInfo(&si);
@@ -98,6 +102,7 @@ static void xbt_preinit()
   xbt_log_preinit();
   xbt_dict_preinit();
   atexit(xbt_postexit);
+  sthread_inside_simgrid = 0;
 }
 
 static void xbt_postexit()