+ mc_transition_t trans = NULL;
+ mc_state_t current_state = NULL;
+ if (!mc_replay_mode) {
+ MC_SET_RAW_MEM;
+ trans = MC_trans_wait_new(comm);
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ xbt_setset_set_insert(current_state->created_transitions, trans);
+ xbt_setset_set_insert(current_state->transitions, trans);
+ MC_UNSET_RAW_MEM;
+ }
+ SIMIX_process_yield();
+}
+
+/**
+ * \brief Intercept a Test action
+ * \param comm The communication associated to the Test
+ */
+void MC_trans_intercept_test(smx_comm_t comm)
+{
+ mc_transition_t trans = NULL;
+ mc_state_t current_state = NULL;
+ if (!mc_replay_mode) {
+ MC_SET_RAW_MEM;
+ trans = MC_trans_test_new(comm);
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ xbt_setset_set_insert(current_state->created_transitions, trans);
+ xbt_setset_set_insert(current_state->transitions, trans);
+ MC_UNSET_RAW_MEM;
+ }
+ SIMIX_process_yield();
+}
+
+/**
+ * \brief Intercept a WaitAny action
+ * \param comms The communications associated to the WaitAny
+ */
+void MC_trans_intercept_waitany(xbt_dynar_t comms)
+{
+ unsigned int index = 0;
+ smx_comm_t comm = NULL;
+ mc_transition_t trans = NULL;
+ mc_state_t current_state = NULL;
+ if (!mc_replay_mode) {
+ MC_SET_RAW_MEM;
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ xbt_dynar_foreach(comms, index, comm) {
+ trans = MC_trans_wait_new(comm);
+ xbt_setset_set_insert(current_state->created_transitions, trans);
+ xbt_setset_set_insert(current_state->transitions, trans);
+ }
+ MC_UNSET_RAW_MEM;
+ }
+ SIMIX_process_yield();
+}
+
+/**
+ * \brief Intercept a Random action
+ * \param min The minimum value that can be returned by the Random action
+ * \param max The maximum value that can be returned by the Random action
+ */
+void MC_trans_intercept_random(int min, int max)
+{
+ int i;
+ mc_transition_t trans = NULL;
+ mc_state_t current_state = NULL;
+ if (!mc_replay_mode) {
+ MC_SET_RAW_MEM;
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ for (i = min; i <= max; i++) {
+ trans = MC_trans_random_new(i);
+ xbt_setset_set_insert(current_state->created_transitions, trans);
+ xbt_setset_set_insert(current_state->transitions, trans);
+ }
+ MC_UNSET_RAW_MEM;
+ }
+ SIMIX_process_yield();
+}
+
+/* Compute the subset of enabled transitions of the transition set */
+void MC_trans_compute_enabled(xbt_setset_set_t enabled,
+ xbt_setset_set_t transitions)
+{
+ unsigned int index = 0;
+ smx_comm_t comm = NULL;
+ mc_transition_t trans = NULL;
+ xbt_setset_cursor_t cursor = NULL;
+ xbt_setset_foreach(transitions, cursor, trans) {
+ switch (trans->type) {
+ /* Wait transitions are enabled only if the communication has both a
+ sender and receiver */
+ case mc_wait:
+ if (trans->wait.comm->src_proc && trans->wait.comm->dst_proc) {
+ xbt_setset_set_insert(enabled, trans);
+ DEBUG1("Transition %p is enabled for next state", trans);
+ }
+ break;
+
+ /* WaitAny transitions are enabled if any of it's communications has both
+ a sender and a receiver */
+ case mc_waitany:
+ xbt_dynar_foreach(trans->waitany.comms, index, comm) {
+ if (comm->src_proc && comm->dst_proc) {
+ xbt_setset_set_insert(enabled, trans);
+ DEBUG1("Transition %p is enabled for next state", trans);
+ break;
+ }
+ }
+ break;
+
+ /* The rest of the transitions cannot be disabled */
+ default:
+ xbt_setset_set_insert(enabled, trans);
+ DEBUG1("Transition %p is enabled for next state", trans);
+ break;
+ }