X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b41c921fc0a6a13f5db4d6cefb9b6955d5f21e3b..7d28d93b90eedd2a49da8b9b990296669e46d05c:/src/simix/popping_private.hpp diff --git a/src/simix/popping_private.hpp b/src/simix/popping_private.hpp index fce643ccda..d0079a6047 100644 --- a/src/simix/popping_private.hpp +++ b/src/simix/popping_private.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2020. 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 #include /********************************* Simcalls *********************************/ -#include "popping_enum.h" /* Definition of e_smx_simcall_t, with one value per simcall */ +#include "popping_enum.hpp" /* Definition of e_smx_simcall_t, with one value per simcall */ -XBT_PUBLIC_DATA const char* simcall_names[]; /* Name of each simcall */ +XBT_PUBLIC_DATA const std::array simcall_names; /* Name of each simcall */ -typedef int (*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 { @@ -48,8 +49,8 @@ struct s_smx_simcall { smx_timer_t timeout_cb_ = nullptr; // Callback to timeouts simgrid::mc::SimcallInspector* inspector_ = nullptr; // makes that simcall observable by the MC 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 args_ = {}; + u_smx_scalar result_ = {}; }; #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall).mc_value_ = (value)) @@ -93,26 +94,26 @@ template struct marshal_t { inline T unmarshal_raw(type, u_smx_scalar const& simcall) \ { /* Exactly same as unmarshal. It differs only for intrusive_ptr */ return simcall.field; } -SIMIX_MARSHAL(bool, b); -SIMIX_MARSHAL(char, c); -SIMIX_MARSHAL(short, s); -SIMIX_MARSHAL(int, i); -SIMIX_MARSHAL(long, l); -SIMIX_MARSHAL(unsigned char, uc); -SIMIX_MARSHAL(unsigned short, us); -SIMIX_MARSHAL(unsigned int, ui); -SIMIX_MARSHAL(unsigned long, ul); -SIMIX_MARSHAL(unsigned long long, ull); -SIMIX_MARSHAL(long long, ll); -SIMIX_MARSHAL(float, d); -SIMIX_MARSHAL(double, d); -SIMIX_MARSHAL(FPtr, fp); - -inline void unmarshal(type, u_smx_scalar const& simcall) +SIMIX_MARSHAL(bool, b) +SIMIX_MARSHAL(char, c) +SIMIX_MARSHAL(short, s) +SIMIX_MARSHAL(int, i) +SIMIX_MARSHAL(long, l) +SIMIX_MARSHAL(unsigned char, uc) +SIMIX_MARSHAL(unsigned short, us) +SIMIX_MARSHAL(unsigned int, ui) +SIMIX_MARSHAL(unsigned long, ul) +SIMIX_MARSHAL(unsigned long long, ull) +SIMIX_MARSHAL(long long, ll) +SIMIX_MARSHAL(float, d) +SIMIX_MARSHAL(double, d) +SIMIX_MARSHAL(FPtr, fp) + +inline void unmarshal(type, u_smx_scalar const& /*simcall*/) { /* Nothing to do for void data */ } -inline void unmarshal_raw(type, u_smx_scalar const& simcall) +inline void unmarshal_raw(type, u_smx_scalar const& /*simcall*/) { /* Nothing to do for void data */ } @@ -177,7 +178,7 @@ template inline typename std::remove_reference::type unmarshal_raw( return unmarshal(type(), simcall); } -template inline void marshal_args(smx_simcall_t simcall) +template inline void marshal_args(const s_smx_simcall* /*simcall*/) { /* Nothing to do when no args */ } @@ -197,8 +198,8 @@ template inline void marshal_args(smx_simca template inline void marshal(smx_simcall_t simcall, e_smx_simcall_t 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...); } }