Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix MC builds
[simgrid.git] / src / mc / remote / Client.cpp
index 9759c21..51b37af 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved.          */
 
 /* 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. */
@@ -24,8 +23,9 @@
 #include "src/mc/remote/Client.hpp"
 #include "src/mc/remote/mc_protocol.h"
 
+#include "src/smpi/private.hpp"
+
 // We won't need those once the separation MCer/MCed is complete:
-#include "src/mc/mc_ignore.h"
 #include "src/mc/mc_smx.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic");
@@ -39,7 +39,7 @@ Client* Client::initialize()
 {
   // We are not in MC mode:
   // TODO, handle this more gracefully.
-  if (!std::getenv(MC_ENV_SOCKET_FD))
+  if (not std::getenv(MC_ENV_SOCKET_FD))
     return nullptr;
 
   // Do not break if we are called multiple times:
@@ -50,7 +50,7 @@ Client* Client::initialize()
 
   // Fetch socket from MC_ENV_SOCKET_FD:
   char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
-  if (!fd_env)
+  if (not fd_env)
     xbt_die("No MC socket passed in the environment");
   int fd =
       xbt_str_parse_int(fd_env, bprintf("Variable %s should contain a number but contains '%%s'", MC_ENV_SOCKET_FD));
@@ -103,7 +103,7 @@ void Client::handleMessages()
       case MC_MESSAGE_DEADLOCK_CHECK: {
         // Check deadlock:
         bool deadlock = false;
-        if (!simix_global->process_list.empty()) {
+        if (not simix_global->process_list.empty()) {
           deadlock = true;
           for (auto kv : simix_global->process_list)
             if (simgrid::mc::actor_is_enabled(kv.second)) {
@@ -128,7 +128,7 @@ void Client::handleMessages()
           xbt_die("Unexpected size for SIMCALL_HANDLE");
         memcpy(&message, message_buffer, sizeof(message));
         smx_actor_t process = SIMIX_process_from_PID(message.pid);
-        if (!process)
+        if (not process)
           xbt_die("Invalid pid %lu", (unsigned long)message.pid);
         SIMIX_simcall_handle(&process->simcall, message.value);
         if (channel_.send(MC_MESSAGE_WAITING))
@@ -151,7 +151,7 @@ void Client::handleMessages()
   }
 }
 
-void Client::mainLoop(void)
+void Client::mainLoop()
 {
   while (1) {
     simgrid::mc::wait_for_requests();
@@ -233,7 +233,7 @@ void Client::declareStack(void* stack, size_t size, smx_actor_t process, ucontex
   region.block   = ((char*)stack - (char*)heap->heapbase) / BLOCKSIZE + 1;
 #if HAVE_SMPI
   if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP && process)
-    region.process_index = smpi_process_index_of_smx_process(process);
+    region.process_index = process->pid - 1;
   else
 #endif
     region.process_index = -1;
@@ -242,7 +242,7 @@ void Client::declareStack(void* stack, size_t size, smx_actor_t process, ucontex
   message.type         = MC_MESSAGE_STACK_REGION;
   message.stack_region = region;
   if (channel_.send(message))
-    xbt_die("Coule not send STACK_REGION to model-checker");
+    xbt_die("Could not send STACK_REGION to model-checker");
 }
 }
 }