-/** \file mc_client_api.cpp
- *
- * This is the implementation of the API used by the user simulated program to
- * communicate with the MC (declared in modelchecker.h).
- */
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client_api, mc,
- "Public API for the model-checked application");
-
-// MC_random() is in mc_base.cpp
+int MC_random(int min, int max)
+{
+#if SIMGRID_HAVE_MC
+ xbt_assert(simgrid::mc::model_checking_mode != simgrid::mc::ModelCheckingMode::CHECKER_SIDE,
+ "This should be called from the client side");
+#endif
+ if (not MC_is_active() && not MC_record_replay_is_active()) { // no need to do a simcall in this case
+ static simgrid::xbt::random::XbtRandom prng;
+ return prng.uniform_int(min, max);
+ }
+ simgrid::kernel::actor::RandomSimcall observer{simgrid::kernel::actor::ActorImpl::self(), min, max};
+ return simgrid::kernel::actor::simcall_answered([&observer] { return observer.get_value(); }, &observer);
+}