From: Frederic Suter Date: Thu, 30 Mar 2017 10:49:54 +0000 (+0200) Subject: modernize two simcalls X-Git-Tag: v3.16~412 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7335dd97eb58110e47e7a1c9d6603093e1d01091 modernize two simcalls and use a third in msg_io --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 506b318b72..5c3cf43d42 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -368,11 +368,7 @@ XBT_PUBLIC(sg_size_t) simcall_file_tell(smx_file_t fd); XBT_PUBLIC(int) simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin); XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath); /***************************** Storage **********************************/ -XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (smx_storage_t storage); -XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (smx_storage_t storage); XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage); -XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage); -XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data); XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage); /************************** MC simcalls **********************************/ diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 3b06812710..0503108b6a 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -479,7 +479,7 @@ const char *MSG_storage_get_name(msg_storage_t storage) { * \return the free space size of the storage element (as a #sg_size_t) */ sg_size_t MSG_storage_get_free_size(msg_storage_t storage){ - return simcall_storage_get_free_size(storage); + return simgrid::simix::kernelImmediate([storage] { return surf_storage_resource_priv(storage)->getFreeSize(); }); } /** \ingroup msg_storage_management @@ -488,7 +488,7 @@ sg_size_t MSG_storage_get_free_size(msg_storage_t storage){ * \return the used space size of the storage element (as a #sg_size_t) */ sg_size_t MSG_storage_get_used_size(msg_storage_t storage){ - return simcall_storage_get_used_size(storage); + return simgrid::simix::kernelImmediate([storage] { return surf_storage_resource_priv(storage)->getUsedSize(); }); } /** \ingroup msg_storage_management @@ -587,7 +587,8 @@ void *MSG_storage_get_data(msg_storage_t storage) */ xbt_dict_t MSG_storage_get_content(msg_storage_t storage) { - std::map* content = surf_storage_resource_priv(storage)->getContent(); + std::map* content = + simgrid::simix::kernelImmediate([storage] { return surf_storage_resource_priv(storage)->getContent(); }); xbt_dict_t content_dict = xbt_dict_new_homogeneous(nullptr); for (auto entry : *content) { diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index 952ec8dec1..53cfb30ce4 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -59,12 +59,12 @@ const char* Storage::host() sg_size_t Storage::sizeFree() { - return simcall_storage_get_free_size(pimpl_); + return simgrid::simix::kernelImmediate([this] { return surf_storage_resource_priv(pimpl_)->getFreeSize(); }); } sg_size_t Storage::sizeUsed() { - return simcall_storage_get_used_size(pimpl_); + return simgrid::simix::kernelImmediate([this] { return surf_storage_resource_priv(pimpl_)->getUsedSize(); }); } sg_size_t Storage::size() { diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 3b63a278b8..098085af98 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -749,26 +749,6 @@ int simcall_file_move(smx_file_t fd, const char* fullpath) return simcall_BODY_file_move(fd, fullpath); } -/** - * \ingroup simix_storage_management - * \brief Returns the free space size on a given storage element. - * \param storage a storage - * \return Return the free space size on a given storage element (as sg_size_t) - */ -sg_size_t simcall_storage_get_free_size (smx_storage_t storage){ - return simcall_BODY_storage_get_free_size(storage); -} - -/** - * \ingroup simix_storage_management - * \brief Returns the used space size on a given storage element. - * \param storage a storage - * \return Return the used space size on a given storage element (as sg_size_t) - */ -sg_size_t simcall_storage_get_used_size (smx_storage_t storage){ - return simcall_BODY_storage_get_used_size(storage); -} - /** * \ingroup simix_storage_management * \brief Returns a dict of the properties assigned to a storage element. diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index a49406a4be..343b8a1ea1 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -978,32 +978,6 @@ static inline void simcall_file_move__set__result(smx_simcall_t simcall, int res simgrid::simix::marshal(simcall->result, result); } -static inline smx_storage_t simcall_storage_get_free_size__get__storage(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline void simcall_storage_get_free_size__set__storage(smx_simcall_t simcall, smx_storage_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_size_t simcall_storage_get_free_size__get__result(smx_simcall_t simcall){ - return simgrid::simix::unmarshal(simcall->result); -} -static inline void simcall_storage_get_free_size__set__result(smx_simcall_t simcall, sg_size_t result){ - simgrid::simix::marshal(simcall->result, result); -} - -static inline smx_storage_t simcall_storage_get_used_size__get__name(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline void simcall_storage_get_used_size__set__name(smx_simcall_t simcall, smx_storage_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_size_t simcall_storage_get_used_size__get__result(smx_simcall_t simcall){ - return simgrid::simix::unmarshal(simcall->result); -} -static inline void simcall_storage_get_used_size__set__result(smx_simcall_t simcall, sg_size_t result){ - simgrid::simix::marshal(simcall->result, result); -} - static inline smx_storage_t simcall_storage_get_properties__get__storage(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); } @@ -1103,6 +1077,4 @@ XBT_PRIVATE sg_size_t simcall_HANDLER_file_tell(smx_simcall_t simcall, smx_file_ XBT_PRIVATE int simcall_HANDLER_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_offset_t offset, int origin); XBT_PRIVATE xbt_dynar_t simcall_HANDLER_file_get_info(smx_simcall_t simcall, smx_file_t fd); XBT_PRIVATE int simcall_HANDLER_file_move(smx_simcall_t simcall, smx_file_t fd, const char* fullpath); -XBT_PRIVATE sg_size_t simcall_HANDLER_storage_get_free_size(smx_simcall_t simcall, smx_storage_t storage); -XBT_PRIVATE sg_size_t simcall_HANDLER_storage_get_used_size(smx_simcall_t simcall, smx_storage_t name); XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max); \ No newline at end of file diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 85dead441d..0268240826 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -347,18 +347,6 @@ inline static int simcall_BODY_file_move(smx_file_t fd, const char* fullpath) { return simcall(SIMCALL_FILE_MOVE, fd, fullpath); } -inline static sg_size_t simcall_BODY_storage_get_free_size(smx_storage_t storage) { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) simcall_HANDLER_storage_get_free_size(&SIMIX_process_self()->simcall, storage); - return simcall(SIMCALL_STORAGE_GET_FREE_SIZE, storage); - } - -inline static sg_size_t simcall_BODY_storage_get_used_size(smx_storage_t name) { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) simcall_HANDLER_storage_get_used_size(&SIMIX_process_self()->simcall, name); - return simcall(SIMCALL_STORAGE_GET_USED_SIZE, name); - } - inline static xbt_dict_t simcall_BODY_storage_get_properties(smx_storage_t storage) { /* Go to that function to follow the code flow through the simcall barrier */ if (0) SIMIX_storage_get_properties(storage); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index d9be9e8c9c..205d92b848 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -70,8 +70,6 @@ typedef enum { SIMCALL_FILE_SEEK, SIMCALL_FILE_GET_INFO, SIMCALL_FILE_MOVE, - SIMCALL_STORAGE_GET_FREE_SIZE, - SIMCALL_STORAGE_GET_USED_SIZE, SIMCALL_STORAGE_GET_PROPERTIES, SIMCALL_MC_RANDOM, SIMCALL_SET_CATEGORY, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index b1259c9d2c..9e477290ff 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -76,8 +76,6 @@ const char* simcall_names[] = { "SIMCALL_FILE_SEEK", "SIMCALL_FILE_GET_INFO", "SIMCALL_FILE_MOVE", - "SIMCALL_STORAGE_GET_FREE_SIZE", - "SIMCALL_STORAGE_GET_USED_SIZE", "SIMCALL_STORAGE_GET_PROPERTIES", "SIMCALL_MC_RANDOM", "SIMCALL_SET_CATEGORY", @@ -337,16 +335,6 @@ case SIMCALL_FILE_MOVE: SIMIX_simcall_answer(simcall); break; -case SIMCALL_STORAGE_GET_FREE_SIZE: - simgrid::simix::marshal(simcall->result, simcall_HANDLER_storage_get_free_size(simcall, simgrid::simix::unmarshal(simcall->args[0]))); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_STORAGE_GET_USED_SIZE: - simgrid::simix::marshal(simcall->result, simcall_HANDLER_storage_get_used_size(simcall, simgrid::simix::unmarshal(simcall->args[0]))); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_STORAGE_GET_PROPERTIES: simgrid::simix::marshal(simcall->result, SIMIX_storage_get_properties(simgrid::simix::unmarshal(simcall->args[0]))); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 4458171f4c..31bc2788e5 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -96,8 +96,6 @@ int file_seek(smx_file_t fd, sg_offset_t offset, int origin); xbt_dynar_t file_get_info(smx_file_t fd); int file_move(smx_file_t fd, const char* fullpath); -sg_size_t storage_get_free_size(smx_storage_t storage); -sg_size_t storage_get_used_size(smx_storage_t name); xbt_dict_t storage_get_properties(smx_storage_t storage) [[nohandler]]; int mc_random(int min, int max);