#include <sstream>
#include <stdio.h>
#include <stdlib.h>
+#include <string_view>
#include <thread>
XBT_LOG_NEW_DEFAULT_CATEGORY(sthread, "pthread intercepter");
{
/* Do not intercept the main when run from SMPI: it will initialize the simulation properly */
for (int i = 0; envp[i] != nullptr; i++)
- if (strncmp(envp[i], "SMPI_GLOBAL_SIZE", strlen("SMPI_GLOBAL_SIZE")) == 0)
+ if (std::string_view(envp[i]).rfind("SMPI_GLOBAL_SIZE", 0) == 0)
return raw_main(argc, argv, envp);
/* If not in SMPI, the old main becomes an actor in a newly created simulation */
double secs = trunc(now);
double usecs = (now - secs) * 1e6;
tv->tv_sec = static_cast<time_t>(secs);
- tv->tv_usec = static_cast<decltype(tv->tv_usec)>(usecs); // suseconds_t (or useconds_t on WIN32)
+ tv->tv_usec = static_cast<decltype(tv->tv_usec)>(usecs); // suseconds_t
}
return 0;
}