Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Deprecated simcall_mc_random.
[simgrid.git] / src / simix / popping_private.hpp
index ad153fd..6300263 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. 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. */
@@ -9,17 +9,18 @@
 #include "simgrid/forward.h"
 #include "src/kernel/activity/ActivityImpl.hpp"
 
+#include <array>
 #include <boost/intrusive_ptr.hpp>
 
 /********************************* Simcalls *********************************/
-#include "popping_enum.h" /* 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 char* simcall_names[]; /* Name of each simcall */
+XBT_PUBLIC_DATA const std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names; /* Name of each simcall */
 
-typedef bool (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*);
-typedef void (*simix_copy_data_func_t)(simgrid::kernel::activity::CommImpl*, void*, size_t);
-typedef void (*simix_clean_func_t)(void*);
-typedef void (*FPtr)(void); // Hide the ugliness
+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);
+using simix_clean_func_t     = void (*)(void*);
+using FPtr                   = void (*)(); // Hide the ugliness
 
 /* Pack all possible scalar types in an union */
 union u_smx_scalar {
@@ -43,13 +44,14 @@ 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
+  unsigned int mc_max_consider_ = 0; // How many times this simcall should be used. If >1, this will be a fork.
   int mc_value_                             = 0;
-  u_smx_scalar args_[11]                    = {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
-  u_smx_scalar result_                      = {0};
+  std::array<u_smx_scalar, 11> args_        = {};
+  u_smx_scalar result_                      = {};
 };
 
 #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall).mc_value_ = (value))
@@ -57,7 +59,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);
 
@@ -108,11 +110,11 @@ SIMIX_MARSHAL(float, d)
 SIMIX_MARSHAL(double, d)
 SIMIX_MARSHAL(FPtr, fp)
 
-inline void unmarshal(type<void>, u_smx_scalar const& simcall)
+inline void unmarshal(type<void>, u_smx_scalar const& /*simcall*/)
 {
   /* Nothing to do for void data */
 }
-inline void unmarshal_raw(type<void>, u_smx_scalar const& simcall)
+inline void unmarshal_raw(type<void>, u_smx_scalar const& /*simcall*/)
 {
   /* Nothing to do for void data */
 }
@@ -168,16 +170,16 @@ template <class T> inline void marshal(u_smx_scalar& simcall, T const& value)
 {
   return marshal(type<T>(), simcall, value);
 }
-template <class T> inline typename std::remove_reference<T>::type unmarshal(u_smx_scalar& simcall)
+template <class T> inline typename std::remove_reference_t<T> unmarshal(u_smx_scalar& simcall)
 {
   return unmarshal(type<T>(), simcall);
 }
-template <class T> inline typename std::remove_reference<T>::type unmarshal_raw(u_smx_scalar& simcall)
+template <class T> inline typename std::remove_reference_t<T> unmarshal_raw(u_smx_scalar& simcall)
 {
   return unmarshal(type<T>(), simcall);
 }
 
-template <std::size_t I> inline void marshal_args(smx_simcall_t simcall)
+template <std::size_t I> inline void marshal_args(const s_smx_simcall* /*simcall*/)
 {
   /* Nothing to do when no args */
 }
@@ -194,11 +196,11 @@ 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_));
-  memset(simcall->args_, 0, sizeof(simcall->args_));
+  memset(&simcall->result_, 0, sizeof simcall->result_);
+  memset(simcall->args_.data(), 0, simcall->args_.size() * sizeof simcall->args_[0]);
   marshal_args<0>(simcall, a...);
 }
 }