From 5991e068e19c81bce114d7ba8ae9d9a6afb729f1 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 4 Jul 2017 11:41:55 +0200 Subject: [PATCH] modernize some simcalls --- src/s4u/s4u_file.cpp | 8 +-- src/simix/libsmx.cpp | 26 --------- src/simix/popping_accessors.h | 96 --------------------------------- src/simix/popping_bodies.cpp | 24 --------- src/simix/popping_enum.h | 3 -- src/simix/popping_generated.cpp | 23 -------- src/simix/simcalls.in | 3 -- src/simix/smx_io.cpp | 15 ------ src/simix/smx_io_private.h | 3 -- 9 files changed, 5 insertions(+), 196 deletions(-) diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index 3296ba1dd0..5eaf55c82d 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -8,6 +8,8 @@ #include "simgrid/s4u/File.hpp" #include "simgrid/s4u/Host.hpp" #include "simgrid/s4u/Storage.hpp" +#include "simgrid/simix.hpp" +#include "src/surf/FileImpl.hpp" #include "src/surf/HostImpl.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files"); @@ -68,17 +70,17 @@ sg_size_t File::write(sg_size_t size, sg_host_t host) sg_size_t File::size() { - return simcall_file_get_size(pimpl_); + return simgrid::simix::kernelImmediate([this] { return pimpl_->size(); }); } void File::seek(sg_size_t pos) { - simcall_file_seek(pimpl_,pos,SEEK_SET); + simgrid::simix::kernelImmediate([this, pos] { pimpl_->seek(pos, SEEK_SET); }); } sg_size_t File::tell() { - return simcall_file_tell(pimpl_); + return simgrid::simix::kernelImmediate([this] { return pimpl_->tell(); }); } void File::move(const char* fullpath) diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 4f93445a4b..55059b5321 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -698,32 +698,6 @@ int simcall_file_unlink(surf_file_t fd, sg_host_t host) return simcall_BODY_file_unlink(fd, host); } -/** - * \ingroup simix_file_management - * - */ -sg_size_t simcall_file_get_size(surf_file_t fd) -{ - return simcall_BODY_file_get_size(fd); -} - -/** - * \ingroup simix_file_management - * - */ -sg_size_t simcall_file_tell(surf_file_t fd) -{ - return simcall_BODY_file_tell(fd); -} - -/** - * \ingroup simix_file_management - * - */ -int simcall_file_seek(surf_file_t fd, sg_offset_t offset, int origin) -{ - return simcall_BODY_file_seek(fd, offset, origin); -} /** * \ingroup simix_file_management diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 4e437e480e..7d414e68bf 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -1759,102 +1759,6 @@ static inline void simcall_file_unlink__set__result(smx_simcall_t simcall, int r simgrid::simix::marshal(simcall->result, result); } -static inline surf_file_t simcall_file_get_size__get__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline surf_file_t simcall_file_get_size__getraw__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_file_get_size__set__fd(smx_simcall_t simcall, surf_file_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_size_t simcall_file_get_size__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline sg_size_t simcall_file_get_size__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_file_get_size__set__result(smx_simcall_t simcall, sg_size_t result){ - simgrid::simix::marshal(simcall->result, result); -} - -static inline surf_file_t simcall_file_tell__get__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline surf_file_t simcall_file_tell__getraw__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_file_tell__set__fd(smx_simcall_t simcall, surf_file_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_size_t simcall_file_tell__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline sg_size_t simcall_file_tell__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_file_tell__set__result(smx_simcall_t simcall, sg_size_t result){ - simgrid::simix::marshal(simcall->result, result); -} - -static inline surf_file_t simcall_file_seek__get__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline surf_file_t simcall_file_seek__getraw__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_file_seek__set__fd(smx_simcall_t simcall, surf_file_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_offset_t simcall_file_seek__get__offset(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline sg_offset_t simcall_file_seek__getraw__offset(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_file_seek__set__offset(smx_simcall_t simcall, sg_offset_t arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} -static inline int simcall_file_seek__get__origin(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[2]); -} -static inline int simcall_file_seek__getraw__origin(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[2]); -} -static inline void simcall_file_seek__set__origin(smx_simcall_t simcall, int arg) -{ - simgrid::simix::marshal(simcall->args[2], arg); -} -static inline int simcall_file_seek__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline int simcall_file_seek__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_file_seek__set__result(smx_simcall_t simcall, int result){ - simgrid::simix::marshal(simcall->result, result); -} - static inline surf_file_t simcall_file_move__get__fd(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 534c966ac0..0833c323b0 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -367,30 +367,6 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) { return simcall(SIMCALL_FILE_UNLINK, fd, host); } - inline static sg_size_t simcall_BODY_file_get_size(surf_file_t fd) - { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) - SIMIX_file_get_size(fd); - return simcall(SIMCALL_FILE_GET_SIZE, fd); - } - - inline static sg_size_t simcall_BODY_file_tell(surf_file_t fd) - { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) - SIMIX_file_tell(fd); - return simcall(SIMCALL_FILE_TELL, fd); - } - - inline static int simcall_BODY_file_seek(surf_file_t fd, sg_offset_t offset, int origin) - { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) - SIMIX_file_seek(fd, offset, origin); - return simcall(SIMCALL_FILE_SEEK, fd, offset, origin); - } - inline static int simcall_BODY_file_move(surf_file_t fd, const char* fullpath) { /* Go to that function to follow the code flow through the simcall barrier */ diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 1a6d2d71ca..e9a0bd4041 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -66,9 +66,6 @@ typedef enum { SIMCALL_FILE_OPEN, SIMCALL_FILE_CLOSE, SIMCALL_FILE_UNLINK, - SIMCALL_FILE_GET_SIZE, - SIMCALL_FILE_TELL, - SIMCALL_FILE_SEEK, SIMCALL_FILE_MOVE, SIMCALL_MC_RANDOM, SIMCALL_SET_CATEGORY, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index b9971508c9..69c9e26b71 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -72,9 +72,6 @@ const char* simcall_names[] = { "SIMCALL_FILE_OPEN", "SIMCALL_FILE_CLOSE", "SIMCALL_FILE_UNLINK", - "SIMCALL_FILE_GET_SIZE", - "SIMCALL_FILE_TELL", - "SIMCALL_FILE_SEEK", "SIMCALL_FILE_MOVE", "SIMCALL_MC_RANDOM", "SIMCALL_SET_CATEGORY", @@ -368,26 +365,6 @@ case SIMCALL_FILE_UNLINK: SIMIX_simcall_answer(simcall); break; -case SIMCALL_FILE_GET_SIZE: - simgrid::simix::marshal(simcall->result, - SIMIX_file_get_size(simgrid::simix::unmarshal(simcall->args[0]))); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_FILE_TELL: - simgrid::simix::marshal(simcall->result, - SIMIX_file_tell(simgrid::simix::unmarshal(simcall->args[0]))); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_FILE_SEEK: - simgrid::simix::marshal(simcall->result, - SIMIX_file_seek(simgrid::simix::unmarshal(simcall->args[0]), - simgrid::simix::unmarshal(simcall->args[1]), - simgrid::simix::unmarshal(simcall->args[2]))); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_FILE_MOVE: simgrid::simix::marshal( simcall->result, simcall_HANDLER_file_move(simcall, simgrid::simix::unmarshal(simcall->args[0]), diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index b74022207a..68ad25d980 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -90,9 +90,6 @@ sg_size_t file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]] surf_file_t file_open(const char* mount, const char* path, sg_storage_t st) [[block]]; int file_close(surf_file_t fd, sg_host_t host) [[block]]; int file_unlink(surf_file_t fd, sg_host_t host) [[nohandler]]; -sg_size_t file_get_size(surf_file_t fd) [[nohandler]]; -sg_size_t file_tell(surf_file_t fd) [[nohandler]]; -int file_seek(surf_file_t fd, sg_offset_t offset, int origin) [[nohandler]]; int file_move(surf_file_t fd, const char* fullpath); int mc_random(int min, int max); diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index 5f40cb95bb..f106155ce6 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -122,21 +122,6 @@ int SIMIX_file_unlink(surf_file_t file, sg_host_t host) return surf_host_unlink(host, file); } -sg_size_t SIMIX_file_get_size(surf_file_t fd) -{ - return fd->size(); -} - -sg_size_t SIMIX_file_tell(surf_file_t fd) -{ - return fd->tell(); -} - -int SIMIX_file_seek(surf_file_t fd, sg_offset_t offset, int origin) -{ - return fd->seek(offset, origin); -} - int simcall_HANDLER_file_move(smx_simcall_t simcall, surf_file_t file, const char* fullpath) { return SIMIX_file_move(simcall->issuer, file, fullpath); diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index f862638020..13f8145e9b 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -16,9 +16,6 @@ XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size, sg_h XBT_PRIVATE smx_activity_t SIMIX_file_open(const char* mount, const char* path, sg_storage_t st); XBT_PRIVATE smx_activity_t SIMIX_file_close(surf_file_t fd, sg_host_t host); XBT_PRIVATE int SIMIX_file_unlink(surf_file_t fd, sg_host_t host); -XBT_PRIVATE sg_size_t SIMIX_file_get_size(surf_file_t fd); -XBT_PRIVATE sg_size_t SIMIX_file_tell(surf_file_t fd); -XBT_PRIVATE int SIMIX_file_seek(surf_file_t fd, sg_offset_t offset, int origin); XBT_PRIVATE int SIMIX_file_move(smx_actor_t process, surf_file_t fd, const char* fullpath); XBT_PRIVATE void SIMIX_io_destroy(smx_activity_t synchro); -- 2.20.1