Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Enum class for MC call types, and MC comm pattern differences.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 18 Nov 2020 20:23:15 +0000 (21:23 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 25 Nov 2020 20:47:01 +0000 (21:47 +0100)
22 files changed:
doc/doxygen/inside_extending.doc
doc/doxygen/uhood_switch.doc
src/kernel/activity/CommImpl.cpp
src/kernel/activity/ConditionVariableImpl.cpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/actor/ActorImpl.cpp
src/mc/checker/LivenessChecker.cpp
src/mc/checker/SafetyChecker.cpp
src/mc/mc_base.cpp
src/mc/mc_comm_pattern.hpp
src/mc/mc_record.cpp
src/mc/mc_request.cpp
src/mc/mc_state.cpp
src/mc/mc_state.hpp
src/simix/libsmx.cpp
src/simix/popping_bodies.cpp
src/simix/popping_enum.hpp
src/simix/popping_generated.cpp
src/simix/popping_private.hpp
src/simix/simcalls.py
src/simix/smx_global.cpp

index d9ae393..54f7dcc 100644 (file)
@@ -165,7 +165,7 @@ generates the following files:
 - popping_bodies.cpp:
   The BODY function of each simcall
 - popping_enum.hpp:
-  Definition of type `enum e_smx_simcall_t` (one value per existing simcall)
+  Definition of type `enum class Simcall` (one value per existing simcall)
 - popping_generated.cpp:
   Definitions of `simcall_names[]` (debug name of each simcall), and
   ActorImpl::simcall_handle() that deals with the simcall from within the kernel
index ff66dbf..ae65213 100644 (file)
@@ -328,7 +328,7 @@ number and its arguments (among some other things):
 @code{cpp}
 struct s_smx_simcall {
   // Simcall number:
-  e_smx_simcall_t call;
+  Simcall call;
   // Issuing actor:
   smx_actor_t issuer;
   // Arguments of the simcall:
index d213694..c10e7b2 100644 (file)
@@ -581,9 +581,9 @@ void CommImpl::finish()
      * list. Afterwards, get the position of the actual synchro in the waitany list and return it as the result of the
      * simcall */
 
-    if (simcall->call_ == SIMCALL_NONE) // FIXME: maybe a better way to handle this case
-      continue;                         // if actor handling comm is killed
-    if (simcall->call_ == SIMCALL_COMM_WAITANY) {
+    if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
+      continue;                                 // if actor handling comm is killed
+    if (simcall->call_ == simix::Simcall::COMM_WAITANY) {
       SIMIX_waitany_remove_simcall_from_actions(simcall);
       if (simcall->timeout_cb_) {
         simcall->timeout_cb_->remove();
@@ -674,15 +674,15 @@ void CommImpl::finish()
     }
     /* if there is an exception during a waitany or a testany, indicate the position of the failed communication */
     if (simcall->issuer_->exception_ &&
-        (simcall->call_ == SIMCALL_COMM_WAITANY || simcall->call_ == SIMCALL_COMM_TESTANY)) {
+        (simcall->call_ == simix::Simcall::COMM_WAITANY || simcall->call_ == simix::Simcall::COMM_TESTANY)) {
       // First retrieve the rank of our failing synchro
       CommImpl** comms;
       size_t count;
-      if (simcall->call_ == SIMCALL_COMM_WAITANY) {
+      if (simcall->call_ == simix::Simcall::COMM_WAITANY) {
         comms = simcall_comm_waitany__get__comms(simcall);
         count = simcall_comm_waitany__get__count(simcall);
       } else {
-        /* simcall->call_ == SIMCALL_COMM_TESTANY */
+        /* simcall->call_ == simix::Simcall::COMM_TESTANY */
         comms = simcall_comm_testany__get__comms(simcall);
         count = simcall_comm_testany__get__count(simcall);
       }
index fdc1def..6193dfd 100644 (file)
@@ -51,11 +51,11 @@ void ConditionVariableImpl::signal()
     /* Now transform the cond wait simcall into a mutex lock one */
     smx_simcall_t simcall = &proc.simcall_;
     MutexImpl* simcall_mutex;
-    if (simcall->call_ == SIMCALL_COND_WAIT)
+    if (simcall->call_ == simix::Simcall::COND_WAIT)
       simcall_mutex = simcall_cond_wait__get__mutex(simcall);
     else
       simcall_mutex = simcall_cond_wait_timeout__get__mutex(simcall);
-    simcall->call_ = SIMCALL_MUTEX_LOCK;
+    simcall->call_ = simix::Simcall::MUTEX_LOCK;
 
     simcall_mutex->lock(simcall->issuer_);
   }
index 74129f3..73e6384 100644 (file)
@@ -183,9 +183,9 @@ void ExecImpl::finish()
      * list. Afterwards, get the position of the actual synchro in the waitany list and return it as the result of the
      * simcall */
 
-    if (simcall->call_ == SIMCALL_NONE) // FIXME: maybe a better way to handle this case
+    if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
       continue;                        // if process handling comm is killed
-    if (simcall->call_ == SIMCALL_EXECUTION_WAITANY_FOR) {
+    if (simcall->call_ == simix::Simcall::EXECUTION_WAITANY_FOR) {
       simgrid::kernel::activity::ExecImpl** execs = simcall_execution_waitany_for__get__execs(simcall);
       size_t count                                = simcall_execution_waitany_for__get__count(simcall);
 
index 8ff59c5..f759c7a 100644 (file)
@@ -78,24 +78,24 @@ void RawImpl::finish()
   }
 
   switch (simcall->call_) {
-    case SIMCALL_MUTEX_LOCK:
+    case simix::Simcall::MUTEX_LOCK:
       simcall_mutex_lock__get__mutex(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
-    case SIMCALL_COND_WAIT:
+    case simix::Simcall::COND_WAIT:
       simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
-    case SIMCALL_COND_WAIT_TIMEOUT:
+    case simix::Simcall::COND_WAIT_TIMEOUT:
       simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
       simcall_cond_wait_timeout__set__result(simcall, 1); // signal a timeout
       break;
 
-    case SIMCALL_SEM_ACQUIRE:
+    case simix::Simcall::SEM_ACQUIRE:
       simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
-    case SIMCALL_SEM_ACQUIRE_TIMEOUT:
+    case simix::Simcall::SEM_ACQUIRE_TIMEOUT:
       simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
       simcall_sem_acquire_timeout__set__result(simcall, 1); // signal a timeout
       break;
index fa893bd..33cae24 100644 (file)
@@ -436,8 +436,8 @@ void ActorImpl::simcall_answer()
   if (this != simix_global->maestro_) {
     XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall_.call_), (int)simcall_.call_,
               get_cname(), this);
-    xbt_assert(simcall_.call_ != SIMCALL_NONE);
-    simcall_.call_ = SIMCALL_NONE;
+    xbt_assert(simcall_.call_ != simix::Simcall::NONE);
+    simcall_.call_ = simix::Simcall::NONE;
     xbt_assert(not XBT_LOG_ISENABLED(simix_process, xbt_log_priority_debug) ||
                    std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), this) ==
                        end(simix_global->actors_to_run),
index b586e8c..f644c90 100644 (file)
@@ -253,7 +253,7 @@ std::vector<std::string> LivenessChecker::get_textual_trace() // override
   for (std::shared_ptr<Pair> const& pair : exploration_stack_) {
     int req_num       = pair->graph_state->transition_.argument_;
     smx_simcall_t req = &pair->graph_state->executed_req_;
-    if (req && req->call_ != SIMCALL_NONE)
+    if (req && req->call_ != simix::Simcall::NONE)
       trace.push_back(request_to_string(req, req_num, RequestType::executed));
   }
   return trace;
index 9f9716f..6284972 100644 (file)
@@ -192,7 +192,7 @@ void SafetyChecker::backtrack()
     stack_.pop_back();
     if (reductionMode_ == ReductionMode::dpor) {
       smx_simcall_t req = &state->internal_req_;
-      if (req->call_ == SIMCALL_MUTEX_LOCK || req->call_ == SIMCALL_MUTEX_TRYLOCK)
+      if (req->call_ == simix::Simcall::MUTEX_LOCK || req->call_ == simix::Simcall::MUTEX_TRYLOCK)
         xbt_die("Mutex is currently not supported with DPOR,  use --cfg=model-check/reduction:none");
 
       const kernel::actor::ActorImpl* issuer = MC_smx_simcall_get_issuer(req);
index 2a59567..eba010b 100644 (file)
@@ -44,7 +44,7 @@ void wait_for_requests()
     simix_global->run_all_actors();
     for (smx_actor_t const& process : simix_global->actors_that_ran) {
       const s_smx_simcall* req = &process->simcall_;
-      if (req->call_ != SIMCALL_NONE && not simgrid::mc::request_is_visible(req))
+      if (req->call_ != simix::Simcall::NONE && not simgrid::mc::request_is_visible(req))
         process->simcall_handle(0);
     }
   }
@@ -83,11 +83,12 @@ bool actor_is_enabled(smx_actor_t actor)
   if (req->inspector_ != nullptr)
     return req->inspector_->is_enabled();
 
+  using simix::Simcall;
   switch (req->call_) {
-    case SIMCALL_NONE:
+    case Simcall::NONE:
       return false;
 
-    case SIMCALL_COMM_WAIT: {
+    case Simcall::COMM_WAIT: {
       /* FIXME: check also that src and dst processes are not suspended */
       const kernel::activity::CommImpl* act = simcall_comm_wait__getraw__comm(req);
 
@@ -104,7 +105,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return (act->src_actor_ && act->dst_actor_);
     }
 
-    case SIMCALL_COMM_WAITANY: {
+    case Simcall::COMM_WAITANY: {
       simgrid::kernel::activity::CommImpl** comms = simcall_comm_waitany__get__comms(req);
       size_t count                                = simcall_comm_waitany__get__count(req);
       for (unsigned int index = 0; index < count; ++index) {
@@ -115,7 +116,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return false;
     }
 
-    case SIMCALL_MUTEX_LOCK: {
+    case Simcall::MUTEX_LOCK: {
       const kernel::activity::MutexImpl* mutex = simcall_mutex_lock__get__mutex(req);
 
       if (mutex->get_owner() == nullptr)
@@ -123,7 +124,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return mutex->get_owner()->get_pid() == req->issuer_->get_pid();
     }
 
-    case SIMCALL_SEM_ACQUIRE: {
+    case Simcall::SEM_ACQUIRE: {
       static int warned = 0;
       if (not warned)
         XBT_INFO("Using semaphore in model-checked code is still experimental. Use at your own risk");
@@ -131,7 +132,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return true;
     }
 
-    case SIMCALL_COND_WAIT: {
+    case Simcall::COND_WAIT: {
       static int warned = 0;
       if (not warned)
         XBT_INFO("Using condition variables in model-checked code is still experimental. Use at your own risk");
@@ -154,10 +155,12 @@ bool request_is_visible(const s_smx_simcall* req)
   xbt_assert(mc_model_checker == nullptr, "This should be called from the client side");
 #endif
 
-  return (req->inspector_ != nullptr && req->inspector_->is_visible()) || req->call_ == SIMCALL_COMM_ISEND ||
-         req->call_ == SIMCALL_COMM_IRECV || req->call_ == SIMCALL_COMM_WAIT || req->call_ == SIMCALL_COMM_WAITANY ||
-         req->call_ == SIMCALL_COMM_TEST || req->call_ == SIMCALL_COMM_TESTANY || req->call_ == SIMCALL_MC_RANDOM ||
-         req->call_ == SIMCALL_MUTEX_LOCK || req->call_ == SIMCALL_MUTEX_TRYLOCK || req->call_ == SIMCALL_MUTEX_UNLOCK;
+  using simix::Simcall;
+  return (req->inspector_ != nullptr && req->inspector_->is_visible()) || req->call_ == Simcall::COMM_ISEND ||
+         req->call_ == Simcall::COMM_IRECV || req->call_ == Simcall::COMM_WAIT || req->call_ == Simcall::COMM_WAITANY ||
+         req->call_ == Simcall::COMM_TEST || req->call_ == Simcall::COMM_TESTANY || req->call_ == Simcall::MC_RANDOM ||
+         req->call_ == Simcall::MUTEX_LOCK || req->call_ == Simcall::MUTEX_TRYLOCK ||
+         req->call_ == Simcall::MUTEX_UNLOCK;
 }
 
 }
index 8380321..70e6a30 100644 (file)
@@ -46,14 +46,15 @@ extern XBT_PRIVATE std::vector<std::vector<simgrid::mc::PatternCommunication*>>
 static inline simgrid::mc::CallType MC_get_call_type(const s_smx_simcall* req)
 {
   using simgrid::mc::CallType;
+  using simgrid::simix::Simcall;
   switch (req->call_) {
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       return CallType::SEND;
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       return CallType::RECV;
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       return CallType::WAIT;
-    case SIMCALL_COMM_WAITANY:
+    case Simcall::COMM_WAITANY:
       return CallType::WAITANY;
     default:
       return CallType::NONE;
index bfd5482..3bc9d9e 100644 (file)
@@ -35,7 +35,7 @@ void replay(RecordTrace const& trace)
     if (not process)
       xbt_die("Unexpected process (pid:%d).", transition.pid_);
     const s_smx_simcall* simcall = &(process->simcall_);
-    if (simcall == nullptr || simcall->call_ == SIMCALL_NONE)
+    if (simcall == nullptr || simcall->call_ == simix::Simcall::NONE)
       xbt_die("No simcall for process %d.", transition.pid_);
     if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process))
       xbt_die("Unexpected simcall.");
index 94d0d91..cea6c69 100644 (file)
@@ -13,6 +13,7 @@
 #include <array>
 
 using simgrid::mc::remote;
+using simgrid::simix::Simcall;
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_request, mc, "Logging specific to MC (request)");
 
@@ -22,9 +23,9 @@ static char *buff_size_to_string(size_t size);
 static inline simgrid::kernel::activity::CommImpl* MC_get_comm(smx_simcall_t r)
 {
   switch (r->call_) {
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       return simcall_comm_wait__getraw__comm(r);
-    case SIMCALL_COMM_TEST:
+    case Simcall::COMM_TEST:
       return simcall_comm_test__getraw__comm(r);
     default:
       return nullptr;
@@ -35,9 +36,9 @@ static inline
 smx_mailbox_t MC_get_mbox(smx_simcall_t r)
 {
   switch (r->call_) {
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       return simcall_comm_isend__get__mbox(r);
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       return simcall_comm_irecv__get__mbox(r);
     default:
       return nullptr;
@@ -51,17 +52,17 @@ namespace mc {
 static inline
 bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
 {
-  if (r1->call_ == SIMCALL_COMM_ISEND && r2->call_ == SIMCALL_COMM_IRECV)
+  if (r1->call_ == Simcall::COMM_ISEND && r2->call_ == Simcall::COMM_IRECV)
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_IRECV && r2->call_ == SIMCALL_COMM_ISEND)
+  if (r1->call_ == Simcall::COMM_IRECV && r2->call_ == Simcall::COMM_ISEND)
     return false;
 
   // Those are internal requests, we do not need indirection because those objects are copies:
   const kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
   const kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
 
-  if ((r1->call_ == SIMCALL_COMM_ISEND || r1->call_ == SIMCALL_COMM_IRECV) && r2->call_ == SIMCALL_COMM_WAIT) {
+  if ((r1->call_ == Simcall::COMM_ISEND || r1->call_ == Simcall::COMM_IRECV) && r2->call_ == Simcall::COMM_WAIT) {
     const kernel::activity::MailboxImpl* mbox = MC_get_mbox(r1);
 
     if (mbox != synchro2->mbox_cpy
@@ -72,11 +73,11 @@ bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
         simcall_comm_wait__get__timeout(r2) <= 0)
       return false;
 
-    if ((r1->call_ == SIMCALL_COMM_ISEND) && (synchro2->type_ == kernel::activity::CommImpl::Type::SEND) &&
+    if ((r1->call_ == Simcall::COMM_ISEND) && (synchro2->type_ == kernel::activity::CommImpl::Type::SEND) &&
         (synchro2->src_buff_ != simcall_comm_isend__get__src_buff(r1)) && simcall_comm_wait__get__timeout(r2) <= 0)
       return false;
 
-    if ((r1->call_ == SIMCALL_COMM_IRECV) && (synchro2->type_ == kernel::activity::CommImpl::Type::RECEIVE) &&
+    if ((r1->call_ == Simcall::COMM_IRECV) && (synchro2->type_ == kernel::activity::CommImpl::Type::RECEIVE) &&
         (synchro2->dst_buff_ != simcall_comm_irecv__get__dst_buff(r1)) && simcall_comm_wait__get__timeout(r2) <= 0)
       return false;
   }
@@ -84,24 +85,24 @@ bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
   /* FIXME: the following rule assumes that the result of the isend/irecv call is not stored in a buffer used in the
    * test call. */
 #if 0
-  if((r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
-      &&  r2->call == SIMCALL_COMM_TEST)
+  if((r1->call == Simcall::COMM_ISEND || r1->call == Simcall::COMM_IRECV)
+      &&  r2->call == Simcall::COMM_TEST)
     return false;
 #endif
 
-  if (r1->call_ == SIMCALL_COMM_WAIT && (r2->call_ == SIMCALL_COMM_WAIT || r2->call_ == SIMCALL_COMM_TEST) &&
+  if (r1->call_ == Simcall::COMM_WAIT && (r2->call_ == Simcall::COMM_WAIT || r2->call_ == Simcall::COMM_TEST) &&
       (synchro1->src_actor_.get() == nullptr || synchro1->dst_actor_.get() == nullptr))
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_TEST &&
+  if (r1->call_ == Simcall::COMM_TEST &&
       (simcall_comm_test__get__comm(r1) == nullptr || synchro1->src_buff_ == nullptr || synchro1->dst_buff_ == nullptr))
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_TEST && r2->call_ == SIMCALL_COMM_WAIT && synchro1->src_buff_ == synchro2->src_buff_ &&
-      synchro1->dst_buff_ == synchro2->dst_buff_)
+  if (r1->call_ == Simcall::COMM_TEST && r2->call_ == Simcall::COMM_WAIT &&
+      synchro1->src_buff_ == synchro2->src_buff_ && synchro1->dst_buff_ == synchro2->dst_buff_)
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_WAIT && r2->call_ == SIMCALL_COMM_TEST && synchro1->src_buff_ != nullptr &&
+  if (r1->call_ == Simcall::COMM_WAIT && r2->call_ == Simcall::COMM_TEST && synchro1->src_buff_ != nullptr &&
       synchro1->dst_buff_ != nullptr && synchro2->src_buff_ != nullptr && synchro2->dst_buff_ != nullptr &&
       synchro1->dst_buff_ != synchro2->src_buff_ && synchro1->dst_buff_ != synchro2->dst_buff_ &&
       synchro2->dst_buff_ != synchro1->src_buff_)
@@ -117,8 +118,8 @@ bool request_depend(smx_simcall_t req1, smx_simcall_t req2)
     return false;
 
   /* Wait with timeout transitions are not considered by the independence theorem, thus we consider them as dependent with all other transitions */
-  if ((req1->call_ == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(req1) > 0) ||
-      (req2->call_ == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(req2) > 0))
+  if ((req1->call_ == Simcall::COMM_WAIT && simcall_comm_wait__get__timeout(req1) > 0) ||
+      (req2->call_ == Simcall::COMM_WAIT && simcall_comm_wait__get__timeout(req2) > 0))
     return true;
 
   if (req1->call_ != req2->call_)
@@ -129,11 +130,11 @@ bool request_depend(smx_simcall_t req1, smx_simcall_t req2)
   const kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
 
   switch (req1->call_) {
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       return simcall_comm_isend__get__mbox(req1) == simcall_comm_isend__get__mbox(req2);
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       return simcall_comm_irecv__get__mbox(req1) == simcall_comm_irecv__get__mbox(req2);
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       if (synchro1->src_buff_ == synchro2->src_buff_ && synchro1->dst_buff_ == synchro2->dst_buff_)
         return false;
       if (synchro1->src_buff_ != nullptr && synchro1->dst_buff_ != nullptr && synchro2->src_buff_ != nullptr &&
@@ -192,7 +193,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
   smx_actor_t issuer = MC_smx_simcall_get_issuer(req);
 
   switch (req->call_) {
-    case SIMCALL_COMM_ISEND: {
+    case Simcall::COMM_ISEND: {
       type     = "iSend";
       char* p  = pointer_to_string(simcall_comm_isend__get__src_buff(req));
       char* bs = buff_size_to_string(simcall_comm_isend__get__src_buff_size(req));
@@ -206,7 +207,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_IRECV: {
+    case Simcall::COMM_IRECV: {
       size_t* remote_size = simcall_comm_irecv__get__dst_buff_size(req);
       size_t size         = 0;
       if (remote_size)
@@ -225,7 +226,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_WAIT: {
+    case Simcall::COMM_WAIT: {
       simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_wait__getraw__comm(req);
       char* p;
       if (value == -1) {
@@ -258,7 +259,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_TEST: {
+    case Simcall::COMM_TEST: {
       simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_test__getraw__comm(req);
       simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
       const simgrid::kernel::activity::CommImpl* act;
@@ -289,7 +290,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_WAITANY: {
+    case Simcall::COMM_WAITANY: {
       type         = "WaitAny";
       size_t count = simcall_comm_waitany__get__count(req);
       if (count > 0) {
@@ -304,7 +305,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       if (value == -1) {
         type = "TestAny FALSE";
         args = xbt_strdup("-");
@@ -314,16 +315,16 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       }
       break;
 
-    case SIMCALL_MUTEX_TRYLOCK:
-    case SIMCALL_MUTEX_LOCK: {
-      if (req->call_ == SIMCALL_MUTEX_LOCK)
+    case Simcall::MUTEX_TRYLOCK:
+    case Simcall::MUTEX_LOCK: {
+      if (req->call_ == Simcall::MUTEX_LOCK)
         type = "Mutex LOCK";
       else
         type = "Mutex TRYLOCK";
 
       simgrid::mc::Remote<simgrid::kernel::activity::MutexImpl> mutex;
       mc_model_checker->get_remote_simulation().read_bytes(mutex.get_buffer(), sizeof(mutex),
-                                                           remote(req->call_ == SIMCALL_MUTEX_LOCK
+                                                           remote(req->call_ == Simcall::MUTEX_LOCK
                                                                       ? simcall_mutex_lock__get__mutex(req)
                                                                       : simcall_mutex_trylock__get__mutex(req)));
       args = bprintf("locked = %d, owner = %d, sleeping = n/a", mutex.get_buffer()->is_locked(),
@@ -335,7 +336,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_MC_RANDOM:
+    case Simcall::MC_RANDOM:
       type = "MC_RANDOM";
       args = bprintf("%d", value);
       break;
@@ -364,16 +365,16 @@ bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx)
 {
   kernel::activity::CommImpl* remote_act = nullptr;
   switch (req->call_) {
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       /* FIXME: check also that src and dst processes are not suspended */
       remote_act = simcall_comm_wait__getraw__comm(req);
       break;
 
-    case SIMCALL_COMM_WAITANY:
+    case Simcall::COMM_WAITANY:
       remote_act = mc_model_checker->get_remote_simulation().read(remote(simcall_comm_testany__get__comms(req) + idx));
       break;
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       remote_act = mc_model_checker->get_remote_simulation().read(remote(simcall_comm_testany__get__comms(req) + idx));
       break;
 
@@ -407,21 +408,21 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
   std::string label;
 
   switch (req->call_) {
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] iSend", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
       else
         label = bprintf("[(%ld)] iSend", issuer->get_pid());
       break;
 
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] iRecv", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
       else
         label = xbt::string_printf("[(%ld)] iRecv", issuer->get_pid());
       break;
 
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       if (value == -1) {
         if (issuer->get_host())
           label = xbt::string_printf("[(%ld)%s] WaitTimeout", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
@@ -448,7 +449,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       }
       break;
 
-    case SIMCALL_COMM_TEST: {
+    case Simcall::COMM_TEST: {
       kernel::activity::ActivityImpl* remote_act = simcall_comm_test__getraw__comm(req);
       Remote<simgrid::kernel::activity::CommImpl> temp_comm;
       mc_model_checker->get_remote_simulation().read(temp_comm,
@@ -468,7 +469,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       break;
     }
 
-    case SIMCALL_COMM_WAITANY: {
+    case Simcall::COMM_WAITANY: {
       size_t comms_size = simcall_comm_waitany__get__count(req);
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] WaitAny [%d of %zu]", issuer->get_pid(),
@@ -478,7 +479,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       break;
     }
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       if (value == -1) {
         if (issuer->get_host())
           label = xbt::string_printf("[(%ld)%s] TestAny FALSE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
@@ -495,15 +496,15 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       }
       break;
 
-    case SIMCALL_MUTEX_TRYLOCK:
+    case Simcall::MUTEX_TRYLOCK:
       label = xbt::string_printf("[(%ld)] Mutex TRYLOCK", issuer->get_pid());
       break;
 
-    case SIMCALL_MUTEX_LOCK:
+    case Simcall::MUTEX_LOCK:
       label = xbt::string_printf("[(%ld)] Mutex LOCK", issuer->get_pid());
       break;
 
-    case SIMCALL_MC_RANDOM:
+    case Simcall::MC_RANDOM:
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] MC_RANDOM (%d)", issuer->get_pid(), MC_smx_actor_get_host_name(issuer),
                                    value);
index d5e0c20..de4158b 100644 (file)
@@ -58,18 +58,20 @@ Transition State::get_transition() const
  */
 static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::State* state, smx_actor_t actor)
 {
+  using simgrid::simix::Simcall;
+
   /* reset the outgoing transition */
   simgrid::mc::ActorState* procstate   = &state->actor_states_[actor->get_pid()];
   state->transition_.pid_              = -1;
   state->transition_.argument_         = -1;
-  state->executed_req_.call_           = SIMCALL_NONE;
+  state->executed_req_.call_           = Simcall::NONE;
 
   if (not simgrid::mc::actor_is_enabled(actor))
     return nullptr; // Not executable in the application
 
   smx_simcall_t req = nullptr;
   switch (actor->simcall_.call_) {
-    case SIMCALL_COMM_WAITANY:
+    case Simcall::COMM_WAITANY:
       state->transition_.argument_ = -1;
       while (procstate->times_considered < simcall_comm_waitany__get__count(&actor->simcall_)) {
         if (simgrid::mc::request_is_enabled_by_idx(&actor->simcall_, procstate->times_considered)) {
@@ -86,7 +88,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
         req = &actor->simcall_;
       break;
 
-    case SIMCALL_COMM_TESTANY: {
+    case Simcall::COMM_TESTANY: {
       unsigned start_count       = procstate->times_considered;
       state->transition_.argument_ = -1;
       while (procstate->times_considered < simcall_comm_testany__get__count(&actor->simcall_)) {
@@ -107,7 +109,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
       break;
     }
 
-    case SIMCALL_COMM_WAIT: {
+    case Simcall::COMM_WAIT: {
       simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> remote_act =
           remote(simcall_comm_wait__getraw__comm(&actor->simcall_));
       simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_act;
@@ -125,7 +127,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
       break;
     }
 
-    case SIMCALL_MC_RANDOM: {
+    case Simcall::MC_RANDOM: {
       int min_value                = simcall_mc_random__get__min(&actor->simcall_);
       state->transition_.argument_ = procstate->times_considered + min_value;
       procstate->times_considered++;
@@ -152,8 +154,8 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
   /* The waitany and testany request are transformed into a wait or test request over the corresponding communication
    * action so it can be treated later by the dependence function. */
   switch (req->call_) {
-    case SIMCALL_COMM_WAITANY: {
-      state->internal_req_.call_ = SIMCALL_COMM_WAIT;
+    case Simcall::COMM_WAITANY: {
+      state->internal_req_.call_ = Simcall::COMM_WAIT;
       simgrid::kernel::activity::CommImpl* remote_comm;
       remote_comm = mc_model_checker->get_remote_simulation().read(
           remote(simcall_comm_waitany__get__comms(req) + state->transition_.argument_));
@@ -163,8 +165,8 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
       break;
     }
 
-    case SIMCALL_COMM_TESTANY:
-      state->internal_req_.call_ = SIMCALL_COMM_TEST;
+    case Simcall::COMM_TESTANY:
+      state->internal_req_.call_ = Simcall::COMM_TEST;
 
       if (state->transition_.argument_ > 0) {
         simgrid::kernel::activity::CommImpl* remote_comm = mc_model_checker->get_remote_simulation().read(
@@ -176,14 +178,14 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
       simcall_comm_test__set__result(&state->internal_req_, state->transition_.argument_);
       break;
 
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       mc_model_checker->get_remote_simulation().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
                                                            remote(simcall_comm_wait__getraw__comm(req)));
       simcall_comm_wait__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
       simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
       break;
 
-    case SIMCALL_COMM_TEST:
+    case Simcall::COMM_TEST:
       mc_model_checker->get_remote_simulation().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
                                                            remote(simcall_comm_test__getraw__comm(req)));
       simcall_comm_test__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
index f57f397..54736a5 100644 (file)
@@ -106,8 +106,8 @@ public:
 
   /* Internal translation of the executed_req simcall
    *
-   * SIMCALL_COMM_TESTANY is translated to a SIMCALL_COMM_TEST
-   * and SIMCALL_COMM_WAITANY to a SIMCALL_COMM_WAIT.
+   * Simcall::COMM_TESTANY is translated to a Simcall::COMM_TEST
+   * and Simcall::COMM_WAITANY to a Simcall::COMM_WAIT.
    */
   s_smx_simcall internal_req_;
 
index 4356978..2a0f564 100644 (file)
@@ -368,8 +368,9 @@ int simcall_mc_random(int min, int max) {
 /* ************************************************************************** */
 
 /** @brief returns a printable string representing a simcall */
-const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
-  return simcall_names[kind];
+const char* SIMIX_simcall_name(Simcall kind)
+{
+  return simcall_names[static_cast<int>(kind)];
 }
 
 namespace simgrid {
index c659920..8611fad 100644 (file)
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
+using simgrid::simix::Simcall;
+
 template<class R, class... T>
-inline static R simcall(e_smx_simcall_t call, T const&... t)
+inline static R simcall(Simcall call, T const&... t)
 {
   smx_actor_t self = SIMIX_process_self();
   simgrid::simix::marshal(&self->simcall_, call, t...);
@@ -43,132 +45,132 @@ inline static int simcall_BODY_execution_waitany_for(simgrid::kernel::activity::
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_execution_waitany_for(&SIMIX_process_self()->simcall_, execs, count, timeout);
-  return simcall<int, simgrid::kernel::activity::ExecImpl**, size_t, double>(SIMCALL_EXECUTION_WAITANY_FOR, execs, count, timeout);
+  return simcall<int, simgrid::kernel::activity::ExecImpl**, size_t, double>(Simcall::EXECUTION_WAITANY_FOR, execs, count, timeout);
 }
 
 inline static void simcall_BODY_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_send(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
-  return simcall<void, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_copy_data_func_t, void*, double>(SIMCALL_COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
+  return simcall<void, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_copy_data_func_t, void*, double>(Simcall::COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
 }
 
 inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_isend(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
-  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
+  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(Simcall::COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
 }
 
 inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_recv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
-  return simcall<void, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double, double>(SIMCALL_COMM_RECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
+  return simcall<void, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double, double>(Simcall::COMM_RECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
 }
 
 inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_irecv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
-  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double>(SIMCALL_COMM_IRECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
+  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double>(Simcall::COMM_IRECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
 }
 
 inline static int simcall_BODY_comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_waitany(&SIMIX_process_self()->simcall_, comms, count, timeout);
-  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(SIMCALL_COMM_WAITANY, comms, count, timeout);
+  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(Simcall::COMM_WAITANY, comms, count, timeout);
 }
 
 inline static void simcall_BODY_comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_wait(&SIMIX_process_self()->simcall_, comm, timeout);
-  return simcall<void, simgrid::kernel::activity::CommImpl*, double>(SIMCALL_COMM_WAIT, comm, timeout);
+  return simcall<void, simgrid::kernel::activity::CommImpl*, double>(Simcall::COMM_WAIT, comm, timeout);
 }
 
 inline static bool simcall_BODY_comm_test(simgrid::kernel::activity::CommImpl* comm)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_test(&SIMIX_process_self()->simcall_, comm);
-  return simcall<bool, simgrid::kernel::activity::CommImpl*>(SIMCALL_COMM_TEST, comm);
+  return simcall<bool, simgrid::kernel::activity::CommImpl*>(Simcall::COMM_TEST, comm);
 }
 
 inline static int simcall_BODY_comm_testany(simgrid::kernel::activity::CommImpl** comms, size_t count)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_testany(&SIMIX_process_self()->simcall_, comms, count);
-  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t>(SIMCALL_COMM_TESTANY, comms, count);
+  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t>(Simcall::COMM_TESTANY, comms, count);
 }
 
 inline static void simcall_BODY_mutex_lock(smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mutex_lock(&SIMIX_process_self()->simcall_, mutex);
-  return simcall<void, smx_mutex_t>(SIMCALL_MUTEX_LOCK, mutex);
+  return simcall<void, smx_mutex_t>(Simcall::MUTEX_LOCK, mutex);
 }
 
 inline static int simcall_BODY_mutex_trylock(smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mutex_trylock(&SIMIX_process_self()->simcall_, mutex);
-  return simcall<int, smx_mutex_t>(SIMCALL_MUTEX_TRYLOCK, mutex);
+  return simcall<int, smx_mutex_t>(Simcall::MUTEX_TRYLOCK, mutex);
 }
 
 inline static void simcall_BODY_mutex_unlock(smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mutex_unlock(&SIMIX_process_self()->simcall_, mutex);
-  return simcall<void, smx_mutex_t>(SIMCALL_MUTEX_UNLOCK, mutex);
+  return simcall<void, smx_mutex_t>(Simcall::MUTEX_UNLOCK, mutex);
 }
 
 inline static void simcall_BODY_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_cond_wait(&SIMIX_process_self()->simcall_, cond, mutex);
-  return simcall<void, smx_cond_t, smx_mutex_t>(SIMCALL_COND_WAIT, cond, mutex);
+  return simcall<void, smx_cond_t, smx_mutex_t>(Simcall::COND_WAIT, cond, mutex);
 }
 
 inline static int simcall_BODY_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_cond_wait_timeout(&SIMIX_process_self()->simcall_, cond, mutex, timeout);
-  return simcall<int, smx_cond_t, smx_mutex_t, double>(SIMCALL_COND_WAIT_TIMEOUT, cond, mutex, timeout);
+  return simcall<int, smx_cond_t, smx_mutex_t, double>(Simcall::COND_WAIT_TIMEOUT, cond, mutex, timeout);
 }
 
 inline static void simcall_BODY_sem_acquire(smx_sem_t sem)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_sem_acquire(&SIMIX_process_self()->simcall_, sem);
-  return simcall<void, smx_sem_t>(SIMCALL_SEM_ACQUIRE, sem);
+  return simcall<void, smx_sem_t>(Simcall::SEM_ACQUIRE, sem);
 }
 
 inline static int simcall_BODY_sem_acquire_timeout(smx_sem_t sem, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_sem_acquire_timeout(&SIMIX_process_self()->simcall_, sem, timeout);
-  return simcall<int, smx_sem_t, double>(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout);
+  return simcall<int, smx_sem_t, double>(Simcall::SEM_ACQUIRE_TIMEOUT, sem, timeout);
 }
 
 inline static int simcall_BODY_mc_random(int min, int max)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mc_random(&SIMIX_process_self()->simcall_, min, max);
-  return simcall<int, int, int>(SIMCALL_MC_RANDOM, min, max);
+  return simcall<int, int, int>(Simcall::MC_RANDOM, min, max);
 }
 
 inline static void simcall_BODY_run_kernel(std::function<void()> const* code)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     SIMIX_run_kernel(code);
-  return simcall<void, std::function<void()> const*>(SIMCALL_RUN_KERNEL, code);
+  return simcall<void, std::function<void()> const*>(Simcall::RUN_KERNEL, code);
 }
 
 inline static void simcall_BODY_run_blocking(std::function<void()> const* code)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     SIMIX_run_blocking(code);
-  return simcall<void, std::function<void()> const*>(SIMCALL_RUN_BLOCKING, code);
+  return simcall<void, std::function<void()> const*>(Simcall::RUN_BLOCKING, code);
 }
 /** @endcond */
index a6062b4..99f89af 100644 (file)
  * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :)
  */
 
+namespace simgrid {
+namespace simix {
 /**
  * @brief All possible simcalls.
  */
-enum e_smx_simcall_t {
-  SIMCALL_NONE,
-  SIMCALL_EXECUTION_WAITANY_FOR,
-  SIMCALL_COMM_SEND,
-  SIMCALL_COMM_ISEND,
-  SIMCALL_COMM_RECV,
-  SIMCALL_COMM_IRECV,
-  SIMCALL_COMM_WAITANY,
-  SIMCALL_COMM_WAIT,
-  SIMCALL_COMM_TEST,
-  SIMCALL_COMM_TESTANY,
-  SIMCALL_MUTEX_LOCK,
-  SIMCALL_MUTEX_TRYLOCK,
-  SIMCALL_MUTEX_UNLOCK,
-  SIMCALL_COND_WAIT,
-  SIMCALL_COND_WAIT_TIMEOUT,
-  SIMCALL_SEM_ACQUIRE,
-  SIMCALL_SEM_ACQUIRE_TIMEOUT,
-  SIMCALL_MC_RANDOM,
-  SIMCALL_RUN_KERNEL,
-  SIMCALL_RUN_BLOCKING,
+enum class Simcall {
+  NONE,
+  EXECUTION_WAITANY_FOR,
+  COMM_SEND,
+  COMM_ISEND,
+  COMM_RECV,
+  COMM_IRECV,
+  COMM_WAITANY,
+  COMM_WAIT,
+  COMM_TEST,
+  COMM_TESTANY,
+  MUTEX_LOCK,
+  MUTEX_TRYLOCK,
+  MUTEX_UNLOCK,
+  COND_WAIT,
+  COND_WAIT_TIMEOUT,
+  SEM_ACQUIRE,
+  SEM_ACQUIRE_TIMEOUT,
+  MC_RANDOM,
+  RUN_KERNEL,
+  RUN_BLOCKING,
 };
 
 constexpr int NUM_SIMCALLS = 20;
+} // namespace simix
+} // namespace simgrid
index aa1a849..bb30f86 100644 (file)
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);
 
+using simgrid::simix::Simcall;
 /** @brief Simcalls' names (generated from src/simix/simcalls.in) */
-constexpr std::array<const char*, NUM_SIMCALLS> simcall_names{{
-    "SIMCALL_NONE",
-    "SIMCALL_EXECUTION_WAITANY_FOR",
-    "SIMCALL_COMM_SEND",
-    "SIMCALL_COMM_ISEND",
-    "SIMCALL_COMM_RECV",
-    "SIMCALL_COMM_IRECV",
-    "SIMCALL_COMM_WAITANY",
-    "SIMCALL_COMM_WAIT",
-    "SIMCALL_COMM_TEST",
-    "SIMCALL_COMM_TESTANY",
-    "SIMCALL_MUTEX_LOCK",
-    "SIMCALL_MUTEX_TRYLOCK",
-    "SIMCALL_MUTEX_UNLOCK",
-    "SIMCALL_COND_WAIT",
-    "SIMCALL_COND_WAIT_TIMEOUT",
-    "SIMCALL_SEM_ACQUIRE",
-    "SIMCALL_SEM_ACQUIRE_TIMEOUT",
-    "SIMCALL_MC_RANDOM",
-    "SIMCALL_RUN_KERNEL",
-    "SIMCALL_RUN_BLOCKING",
+constexpr std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names{{
+    "Simcall::NONE",
+    "Simcall::EXECUTION_WAITANY_FOR",
+    "Simcall::COMM_SEND",
+    "Simcall::COMM_ISEND",
+    "Simcall::COMM_RECV",
+    "Simcall::COMM_IRECV",
+    "Simcall::COMM_WAITANY",
+    "Simcall::COMM_WAIT",
+    "Simcall::COMM_TEST",
+    "Simcall::COMM_TESTANY",
+    "Simcall::MUTEX_LOCK",
+    "Simcall::MUTEX_TRYLOCK",
+    "Simcall::MUTEX_UNLOCK",
+    "Simcall::COND_WAIT",
+    "Simcall::COND_WAIT_TIMEOUT",
+    "Simcall::SEM_ACQUIRE",
+    "Simcall::SEM_ACQUIRE_TIMEOUT",
+    "Simcall::MC_RANDOM",
+    "Simcall::RUN_KERNEL",
+    "Simcall::RUN_BLOCKING",
 }};
 
 /** @private
@@ -59,89 +60,89 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
   if (context_->wannadie())
     return;
   switch (simcall_.call_) {
-    case SIMCALL_EXECUTION_WAITANY_FOR:
+    case Simcall::EXECUTION_WAITANY_FOR:
       simcall_HANDLER_execution_waitany_for(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl**>(simcall_.args_[0]), simgrid::simix::unmarshal<size_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]));
       break;
 
-    case SIMCALL_COMM_SEND:
+    case Simcall::COMM_SEND:
       simcall_HANDLER_comm_send(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]), simgrid::simix::unmarshal<double>(simcall_.args_[3]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[4]), simgrid::simix::unmarshal<size_t>(simcall_.args_[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[6]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[7]), simgrid::simix::unmarshal<void*>(simcall_.args_[8]), simgrid::simix::unmarshal<double>(simcall_.args_[9]));
       break;
 
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall_.result_, simcall_HANDLER_comm_isend(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]), simgrid::simix::unmarshal<double>(simcall_.args_[3]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[4]), simgrid::simix::unmarshal<size_t>(simcall_.args_[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[6]), simgrid::simix::unmarshal<simix_clean_func_t>(simcall_.args_[7]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[8]), simgrid::simix::unmarshal<void*>(simcall_.args_[9]), simgrid::simix::unmarshal<bool>(simcall_.args_[10])));
       simcall_answer();
       break;
 
-    case SIMCALL_COMM_RECV:
+    case Simcall::COMM_RECV:
       simcall_HANDLER_comm_recv(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[2]), simgrid::simix::unmarshal<size_t*>(simcall_.args_[3]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[4]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[5]), simgrid::simix::unmarshal<void*>(simcall_.args_[6]), simgrid::simix::unmarshal<double>(simcall_.args_[7]), simgrid::simix::unmarshal<double>(simcall_.args_[8]));
       break;
 
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall_.result_, simcall_HANDLER_comm_irecv(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[2]), simgrid::simix::unmarshal<size_t*>(simcall_.args_[3]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[4]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[5]), simgrid::simix::unmarshal<void*>(simcall_.args_[6]), simgrid::simix::unmarshal<double>(simcall_.args_[7])));
       simcall_answer();
       break;
 
-    case SIMCALL_COMM_WAITANY:
+    case Simcall::COMM_WAITANY:
       simcall_HANDLER_comm_waitany(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall_.args_[0]), simgrid::simix::unmarshal<size_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]));
       break;
 
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       simcall_HANDLER_comm_wait(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall_.args_[0]), simgrid::simix::unmarshal<double>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_COMM_TEST:
+    case Simcall::COMM_TEST:
       simcall_HANDLER_comm_test(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       simcall_HANDLER_comm_testany(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall_.args_[0]), simgrid::simix::unmarshal<size_t>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_MUTEX_LOCK:
+    case Simcall::MUTEX_LOCK:
       simcall_HANDLER_mutex_lock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_MUTEX_TRYLOCK:
+    case Simcall::MUTEX_TRYLOCK:
       simgrid::simix::marshal<int>(simcall_.result_, simcall_HANDLER_mutex_trylock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0])));
       simcall_answer();
       break;
 
-    case SIMCALL_MUTEX_UNLOCK:
+    case Simcall::MUTEX_UNLOCK:
       simcall_HANDLER_mutex_unlock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0]));
       simcall_answer();
       break;
 
-    case SIMCALL_COND_WAIT:
+    case Simcall::COND_WAIT:
       simcall_HANDLER_cond_wait(&simcall_, simgrid::simix::unmarshal<smx_cond_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_COND_WAIT_TIMEOUT:
+    case Simcall::COND_WAIT_TIMEOUT:
       simcall_HANDLER_cond_wait_timeout(&simcall_, simgrid::simix::unmarshal<smx_cond_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]));
       break;
 
-    case SIMCALL_SEM_ACQUIRE:
+    case Simcall::SEM_ACQUIRE:
       simcall_HANDLER_sem_acquire(&simcall_, simgrid::simix::unmarshal<smx_sem_t>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_SEM_ACQUIRE_TIMEOUT:
+    case Simcall::SEM_ACQUIRE_TIMEOUT:
       simcall_HANDLER_sem_acquire_timeout(&simcall_, simgrid::simix::unmarshal<smx_sem_t>(simcall_.args_[0]), simgrid::simix::unmarshal<double>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_MC_RANDOM:
+    case Simcall::MC_RANDOM:
       simgrid::simix::marshal<int>(simcall_.result_, simcall_HANDLER_mc_random(&simcall_, simgrid::simix::unmarshal<int>(simcall_.args_[0]), simgrid::simix::unmarshal<int>(simcall_.args_[1])));
       simcall_answer();
       break;
 
-    case SIMCALL_RUN_KERNEL:
+    case Simcall::RUN_KERNEL:
       SIMIX_run_kernel(simgrid::simix::unmarshal<std::function<void()> const*>(simcall_.args_[0]));
       simcall_answer();
       break;
 
-    case SIMCALL_RUN_BLOCKING:
+    case Simcall::RUN_BLOCKING:
       SIMIX_run_blocking(simgrid::simix::unmarshal<std::function<void()> const*>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_NONE:
+    case Simcall::NONE:
       throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s",
                                                               get_cname(),
                                                               sg_host_get_name(get_host())));
index d0079a6..a095be6 100644 (file)
@@ -13,9 +13,9 @@
 #include <boost/intrusive_ptr.hpp>
 
 /********************************* Simcalls *********************************/
-#include "popping_enum.hpp" /* Definition of e_smx_simcall_t, with one value per simcall */
+#include "popping_enum.hpp" /* Definition of Simcall, with one value per simcall */
 
-XBT_PUBLIC_DATA const std::array<const char*, NUM_SIMCALLS> simcall_names; /* Name of each simcall */
+XBT_PUBLIC_DATA const std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names; /* Name of each simcall */
 
 using simix_match_func_t     = bool (*)(void*, void*, simgrid::kernel::activity::CommImpl*);
 using simix_copy_data_func_t = void (*)(simgrid::kernel::activity::CommImpl*, void*, size_t);
@@ -44,7 +44,7 @@ union u_smx_scalar {
  * @brief Represents a simcall to the kernel.
  */
 struct s_smx_simcall {
-  e_smx_simcall_t call_                     = SIMCALL_NONE;
+  simgrid::simix::Simcall call_             = simgrid::simix::Simcall::NONE;
   smx_actor_t issuer_                       = nullptr;
   smx_timer_t timeout_cb_                   = nullptr; // Callback to timeouts
   simgrid::mc::SimcallInspector* inspector_ = nullptr; // makes that simcall observable by the MC
@@ -58,7 +58,7 @@ struct s_smx_simcall {
 
 /******************************** General *************************************/
 
-XBT_PRIVATE const char* SIMIX_simcall_name(e_smx_simcall_t kind);
+XBT_PRIVATE const char* SIMIX_simcall_name(simgrid::simix::Simcall kind);
 XBT_PRIVATE void SIMIX_run_kernel(std::function<void()> const* code);
 XBT_PRIVATE void SIMIX_run_blocking(std::function<void()> const* code);
 
@@ -195,7 +195,7 @@ template <std::size_t I, class A, class... B> inline void marshal_args(smx_simca
 }
 
 /** Initialize the simcall */
-template <class... A> inline void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A const&... a)
+template <class... A> inline void marshal(smx_simcall_t simcall, Simcall call, A const&... a)
 {
   simcall->call_ = call;
   memset(&simcall->result_, 0, sizeof simcall->result_);
index 96b621f..51b2b4d 100755 (executable)
@@ -79,10 +79,10 @@ class Simcall(object):
         return True
 
     def enum(self):
-        return '  SIMCALL_%s,' % (self.name.upper())
+        return '  %s,' % (self.name.upper())
 
     def string(self):
-        return '    "SIMCALL_%s",' % self.name.upper()
+        return '    "Simcall::%s",' % self.name.upper()
 
     def accessors(self):
         res = []
@@ -132,7 +132,7 @@ class Simcall(object):
         indent = '    '
         args = ["simgrid::simix::unmarshal<%s>(simcall_.args_[%d])" % (arg.rettype(), i)
                 for i, arg in enumerate(self.args)]
-        res.append(indent + 'case SIMCALL_%s:' % (self.name.upper()))
+        res.append(indent + 'case Simcall::%s:' % (self.name.upper()))
         if self.need_handler:
             call = "simcall_HANDLER_%s(&simcall_%s%s)" % (self.name,
                                                         ", " if args else "",
@@ -163,7 +163,7 @@ class Simcall(object):
         else:
             res.append('    SIMIX_%s(%s);' % (self.name,
                                               ', '.join(arg.name for arg in self.args)))
-        res.append('  return simcall<%s%s>(SIMCALL_%s%s);' % (
+        res.append('  return simcall<%s%s>(Simcall::%s%s);' % (
             self.res.rettype(),
             "".join([", " + arg.rettype() for i, arg in enumerate(self.args)]),
             self.name.upper(),
@@ -295,17 +295,21 @@ if __name__ == '__main__':
     # popping_enum.hpp
     #
     fd = header("popping_enum.hpp")
+    fd.write('namespace simgrid {\n');
+    fd.write('namespace simix {\n');
     fd.write('/**\n')
     fd.write(' * @brief All possible simcalls.\n')
     fd.write(' */\n')
-    fd.write('enum e_smx_simcall_t {\n')
-    fd.write('  SIMCALL_NONE,\n')
+    fd.write('enum class Simcall {\n')
+    fd.write('  NONE,\n')
 
     handle(fd, Simcall.enum, simcalls, simcalls_dict)
 
     fd.write('};\n')
     fd.write('\n')
     fd.write('constexpr int NUM_SIMCALLS = ' + str(1 + len(simcalls)) + ';\n');
+    fd.write('} // namespace simix\n');
+    fd.write('} // namespace simgrid\n');
     fd.close()
 
     #
@@ -325,11 +329,13 @@ if __name__ == '__main__':
     fd.write('\n')
     fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);\n\n')
 
+    fd.write('using simgrid::simix::Simcall;')
+    fd.write('\n')
     fd.write(
         '/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n')
-    fd.write('constexpr std::array<const char*, NUM_SIMCALLS> simcall_names{{\n')
+    fd.write('constexpr std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names{{\n')
 
-    fd.write('    "SIMCALL_NONE",\n')
+    fd.write('    "Simcall::NONE",\n')
     handle(fd, Simcall.string, simcalls, simcalls_dict)
 
     fd.write('}};\n\n')
@@ -352,7 +358,7 @@ if __name__ == '__main__':
 
     handle(fd, Simcall.case, simcalls, simcalls_dict)
 
-    fd.write('    case SIMCALL_NONE:\n')
+    fd.write('    case Simcall::NONE:\n')
     fd.write('      throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s",\n')
     fd.write('                                                              get_cname(),\n')
     fd.write('                                                              sg_host_get_name(get_host())));\n')
@@ -378,8 +384,10 @@ if __name__ == '__main__':
     fd.write('''
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
+using simgrid::simix::Simcall;
+
 template<class R, class... T>
-inline static R simcall(e_smx_simcall_t call, T const&... t)
+inline static R simcall(Simcall call, T const&... t)
 {
   smx_actor_t self = SIMIX_process_self();
   simgrid::simix::marshal(&self->simcall_, call, t...);
index 034e5be..0c95e07 100644 (file)
@@ -499,7 +499,7 @@ void SIMIX_run()
        */
 
       for (auto const& actor : simix_global->actors_that_ran) {
-        if (actor->simcall_.call_ != SIMCALL_NONE) {
+        if (actor->simcall_.call_ != simgrid::simix::Simcall::NONE) {
           actor->simcall_handle(0);
         }
       }