From: Frederic Suter Date: Tue, 4 Jul 2017 09:16:46 +0000 (+0200) Subject: get rid of smx_file_t X-Git-Tag: v3_17~483 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/62a32394d08487c948e60b95817e03d81f1af91d?ds=sidebyside get rid of smx_file_t --- diff --git a/include/simgrid/s4u/File.hpp b/include/simgrid/s4u/File.hpp index 75050dd680..189c70331a 100644 --- a/include/simgrid/s4u/File.hpp +++ b/include/simgrid/s4u/File.hpp @@ -76,10 +76,10 @@ public: int desc_id = 0; private: - smx_file_t pimpl_ = nullptr; - const char* path_ = nullptr; - void* userdata_ = nullptr; - sg_host_t host_ = nullptr; + surf_file_t pimpl_ = nullptr; + const char* path_ = nullptr; + void* userdata_ = nullptr; + sg_host_t host_ = nullptr; }; } } // namespace simgrid::s4u diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 45d1ab2867..4fab7f88f1 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -8,10 +8,10 @@ #include "simgrid/datatypes.h" #include "simgrid/host.h" +#include "surf/surf.h" #include "xbt/ex.h" #include "xbt/parmap.h" - /* ******************************** Host ************************************ */ /** @brief Host datatype @ingroup simix_host_management @@ -52,9 +52,6 @@ typedef struct s_smx_cond *smx_cond_t; */ typedef struct s_smx_sem *smx_sem_t; -/********************************** File *************************************/ -typedef struct s_smx_file *smx_file_t; - /* ****************************** Process *********************************** */ typedef enum { @@ -298,17 +295,17 @@ XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration) XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem); /***************************** File **********************************/ -XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd); -XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data); -XBT_PUBLIC(sg_size_t) simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host); -XBT_PUBLIC(sg_size_t) simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host); -XBT_PUBLIC(smx_file_t) simcall_file_open(const char* mount, const char* path, sg_storage_t st); -XBT_PUBLIC(int) simcall_file_close(smx_file_t fd, sg_host_t host); -XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd, sg_host_t host); -XBT_PUBLIC(sg_size_t) simcall_file_get_size(smx_file_t fd); -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); +XBT_PUBLIC(void*) simcall_file_get_data(surf_file_t fd); +XBT_PUBLIC(void) simcall_file_set_data(surf_file_t fd, void* data); +XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host); +XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host); +XBT_PUBLIC(surf_file_t) simcall_file_open(const char* mount, const char* path, sg_storage_t st); +XBT_PUBLIC(int) simcall_file_close(surf_file_t fd, sg_host_t host); +XBT_PUBLIC(int) simcall_file_unlink(surf_file_t fd, sg_host_t host); +XBT_PUBLIC(sg_size_t) simcall_file_get_size(surf_file_t fd); +XBT_PUBLIC(sg_size_t) simcall_file_tell(surf_file_t fd); +XBT_PUBLIC(int) simcall_file_seek(surf_file_t fd, sg_offset_t offset, int origin); +XBT_PUBLIC(int) simcall_file_move(surf_file_t fd, const char* fullpath); /************************** MC simcalls **********************************/ XBT_PUBLIC(int) simcall_mc_random(int min, int max); diff --git a/src/kernel/activity/SynchroIo.cpp b/src/kernel/activity/SynchroIo.cpp index 012165b614..30e5cdd119 100644 --- a/src/kernel/activity/SynchroIo.cpp +++ b/src/kernel/activity/SynchroIo.cpp @@ -4,8 +4,9 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/activity/SynchroIo.hpp" -#include "src/surf/surf_interface.hpp" #include "src/simix/smx_private.h" +#include "src/surf/FileImpl.hpp" +#include "src/surf/surf_interface.hpp" void simgrid::kernel::activity::IoImpl::suspend() { @@ -24,13 +25,12 @@ void simgrid::kernel::activity::IoImpl::post() for (smx_simcall_t simcall : simcalls) { switch (simcall->call) { case SIMCALL_FILE_OPEN: { - smx_file_t tmp = xbt_new(s_smx_file_t,1); - tmp->surf_file = surf_storage_action_get_file(surf_io); + surf_file_t tmp = surf_storage_action_get_file(surf_io); simcall_file_open__set__result(simcall, tmp); break; } case SIMCALL_FILE_CLOSE: - xbt_free(simcall_file_close__get__fd(simcall)); + delete simcall_file_close__get__fd(simcall); simcall_file_close__set__result(simcall, 0); break; case SIMCALL_FILE_WRITE: diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index e3f98d88da..fb2ae08db2 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -62,11 +62,6 @@ private: void reportMultipleUse() const; } s_simdata_task_t; -/********************************* File **************************************/ -typedef struct simdata_file { - smx_file_t smx_file; -} s_simdata_file_t; - /******************************* Process *************************************/ namespace simgrid { diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index cbb5bbb2e7..4f93445a4b 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -657,7 +657,7 @@ int simcall_sem_get_capacity(smx_sem_t sem) * \ingroup simix_file_management * */ -sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) +sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host) { return simcall_BODY_file_read(fd, size, host); } @@ -666,7 +666,7 @@ sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) * \ingroup simix_file_management * */ -sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host) +sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host) { return simcall_BODY_file_write(fd, size, host); } @@ -675,7 +675,7 @@ sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host) * \ingroup simix_file_management * \brief */ -smx_file_t simcall_file_open(const char* mount, const char* path, sg_storage_t st) +surf_file_t simcall_file_open(const char* mount, const char* path, sg_storage_t st) { return simcall_BODY_file_open(mount, path, st); } @@ -684,7 +684,7 @@ smx_file_t simcall_file_open(const char* mount, const char* path, sg_storage_t s * \ingroup simix_file_management * */ -int simcall_file_close(smx_file_t fd, sg_host_t host) +int simcall_file_close(surf_file_t fd, sg_host_t host) { return simcall_BODY_file_close(fd, host); } @@ -693,7 +693,7 @@ int simcall_file_close(smx_file_t fd, sg_host_t host) * \ingroup simix_file_management * */ -int simcall_file_unlink(smx_file_t fd, sg_host_t host) +int simcall_file_unlink(surf_file_t fd, sg_host_t host) { return simcall_BODY_file_unlink(fd, host); } @@ -702,7 +702,8 @@ int simcall_file_unlink(smx_file_t fd, sg_host_t host) * \ingroup simix_file_management * */ -sg_size_t simcall_file_get_size(smx_file_t fd){ +sg_size_t simcall_file_get_size(surf_file_t fd) +{ return simcall_BODY_file_get_size(fd); } @@ -710,7 +711,8 @@ sg_size_t simcall_file_get_size(smx_file_t fd){ * \ingroup simix_file_management * */ -sg_size_t simcall_file_tell(smx_file_t fd){ +sg_size_t simcall_file_tell(surf_file_t fd) +{ return simcall_BODY_file_tell(fd); } @@ -718,7 +720,8 @@ sg_size_t simcall_file_tell(smx_file_t fd){ * \ingroup simix_file_management * */ -int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){ +int simcall_file_seek(surf_file_t fd, sg_offset_t offset, int origin) +{ return simcall_BODY_file_seek(fd, offset, origin); } @@ -727,7 +730,7 @@ int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){ * \brief Move a file to another location on the *same mount point*. * */ -int simcall_file_move(smx_file_t fd, const char* fullpath) +int simcall_file_move(surf_file_t fd, const char* fullpath) { return simcall_BODY_file_move(fd, fullpath); } diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 62328692b5..4e437e480e 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -1542,17 +1542,17 @@ static inline void simcall_sem_get_capacity__set__result(smx_simcall_t simcall, simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_read__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_read__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_read__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_read__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_read__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_read__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline sg_size_t simcall_file_read__get__size(smx_simcall_t simcall) { @@ -1590,17 +1590,17 @@ static inline void simcall_file_read__set__result(smx_simcall_t simcall, sg_size simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_write__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_write__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_write__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_write__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_write__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_write__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline sg_size_t simcall_file_write__get__size(smx_simcall_t simcall) { @@ -1674,29 +1674,30 @@ static inline void simcall_file_open__set__st(smx_simcall_t simcall, sg_storage_ { simgrid::simix::marshal(simcall->args[2], arg); } -static inline smx_file_t simcall_file_open__get__result(smx_simcall_t simcall) +static inline surf_file_t simcall_file_open__get__result(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->result); + return simgrid::simix::unmarshal(simcall->result); } -static inline smx_file_t simcall_file_open__getraw__result(smx_simcall_t simcall) +static inline surf_file_t simcall_file_open__getraw__result(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->result); + return simgrid::simix::unmarshal_raw(simcall->result); } -static inline void simcall_file_open__set__result(smx_simcall_t simcall, smx_file_t result){ - simgrid::simix::marshal(simcall->result, result); +static inline void simcall_file_open__set__result(smx_simcall_t simcall, surf_file_t result) +{ + simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_close__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_close__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_close__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_close__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_close__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_close__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline sg_host_t simcall_file_close__get__host(smx_simcall_t simcall) { @@ -1722,17 +1723,17 @@ static inline void simcall_file_close__set__result(smx_simcall_t simcall, int re simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_unlink__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_unlink__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_unlink__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_unlink__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_unlink__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_unlink__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline sg_host_t simcall_file_unlink__get__host(smx_simcall_t simcall) { @@ -1758,17 +1759,17 @@ static inline void simcall_file_unlink__set__result(smx_simcall_t simcall, int r simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_get_size__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_get_size__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_get_size__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_get_size__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_get_size__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_get_size__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline sg_size_t simcall_file_get_size__get__result(smx_simcall_t simcall) { @@ -1782,17 +1783,17 @@ static inline void simcall_file_get_size__set__result(smx_simcall_t simcall, sg_ simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_tell__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_tell__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_tell__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_tell__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_tell__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_tell__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline sg_size_t simcall_file_tell__get__result(smx_simcall_t simcall) { @@ -1806,17 +1807,17 @@ static inline void simcall_file_tell__set__result(smx_simcall_t simcall, sg_size simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_seek__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_seek__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_seek__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_seek__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_seek__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_seek__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline sg_offset_t simcall_file_seek__get__offset(smx_simcall_t simcall) { @@ -1854,17 +1855,17 @@ static inline void simcall_file_seek__set__result(smx_simcall_t simcall, int res simgrid::simix::marshal(simcall->result, result); } -static inline smx_file_t simcall_file_move__get__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_move__get__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[0]); + return simgrid::simix::unmarshal(simcall->args[0]); } -static inline smx_file_t simcall_file_move__getraw__fd(smx_simcall_t simcall) +static inline surf_file_t simcall_file_move__getraw__fd(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[0]); + return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_file_move__set__fd(smx_simcall_t simcall, smx_file_t arg) +static inline void simcall_file_move__set__fd(smx_simcall_t simcall, surf_file_t arg) { - simgrid::simix::marshal(simcall->args[0], arg); + simgrid::simix::marshal(simcall->args[0], arg); } static inline const char* simcall_file_move__get__fullpath(smx_simcall_t simcall) { @@ -2028,9 +2029,9 @@ XBT_PRIVATE int simcall_HANDLER_sem_would_block(smx_simcall_t simcall, smx_sem_t XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem); XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout); XBT_PRIVATE int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem); -XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host); -XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host); +XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host); +XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host); XBT_PRIVATE void simcall_HANDLER_file_open(smx_simcall_t simcall, const char* mount, const char* path, sg_storage_t st); -XBT_PRIVATE void simcall_HANDLER_file_close(smx_simcall_t simcall, smx_file_t fd, sg_host_t host); -XBT_PRIVATE int simcall_HANDLER_file_move(smx_simcall_t simcall, smx_file_t fd, const char* fullpath); +XBT_PRIVATE void simcall_HANDLER_file_close(smx_simcall_t simcall, surf_file_t fd, sg_host_t host); +XBT_PRIVATE int simcall_HANDLER_file_move(smx_simcall_t simcall, surf_file_t fd, const char* fullpath); 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 79a6d320b1..534c966ac0 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -331,63 +331,71 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) { return simcall(SIMCALL_SEM_GET_CAPACITY, sem); } -inline static sg_size_t simcall_BODY_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) { + inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size, sg_host_t host) + { /* Go to that function to follow the code flow through the simcall barrier */ if (0) simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size, host); - return simcall(SIMCALL_FILE_READ, fd, size, host); + return simcall(SIMCALL_FILE_READ, fd, size, host); } -inline static sg_size_t simcall_BODY_file_write(smx_file_t fd, sg_size_t size, sg_host_t host) { + inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size, sg_host_t host) + { /* Go to that function to follow the code flow through the simcall barrier */ if (0) simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size, host); - return simcall(SIMCALL_FILE_WRITE, fd, size, host); + return simcall(SIMCALL_FILE_WRITE, fd, size, host); } - inline static smx_file_t simcall_BODY_file_open(const char* mount, const char* path, sg_storage_t st) + inline static surf_file_t simcall_BODY_file_open(const char* mount, const char* path, sg_storage_t st) { /* Go to that function to follow the code flow through the simcall barrier */ if (0) simcall_HANDLER_file_open(&SIMIX_process_self()->simcall, mount, path, st); - return simcall(SIMCALL_FILE_OPEN, mount, path, st); + return simcall(SIMCALL_FILE_OPEN, mount, path, st); } -inline static int simcall_BODY_file_close(smx_file_t fd, sg_host_t host) { + inline static int simcall_BODY_file_close(surf_file_t fd, sg_host_t host) + { /* Go to that function to follow the code flow through the simcall barrier */ if (0) simcall_HANDLER_file_close(&SIMIX_process_self()->simcall, fd, host); - return simcall(SIMCALL_FILE_CLOSE, fd, host); + return simcall(SIMCALL_FILE_CLOSE, fd, host); } -inline static int simcall_BODY_file_unlink(smx_file_t fd, sg_host_t host) { + inline static int simcall_BODY_file_unlink(surf_file_t fd, sg_host_t host) + { /* Go to that function to follow the code flow through the simcall barrier */ if (0) SIMIX_file_unlink(fd, host); - return simcall(SIMCALL_FILE_UNLINK, fd, host); + return simcall(SIMCALL_FILE_UNLINK, fd, host); } -inline static sg_size_t simcall_BODY_file_get_size(smx_file_t fd) { + 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); + return simcall(SIMCALL_FILE_GET_SIZE, fd); } -inline static sg_size_t simcall_BODY_file_tell(smx_file_t 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); + return simcall(SIMCALL_FILE_TELL, fd); } -inline static int simcall_BODY_file_seek(smx_file_t fd, sg_offset_t offset, int origin) { + 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); + return simcall(SIMCALL_FILE_SEEK, fd, offset, origin); } -inline static int simcall_BODY_file_move(smx_file_t fd, const char* fullpath) { + 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 */ if (0) simcall_HANDLER_file_move(&SIMIX_process_self()->simcall, fd, fullpath); - return simcall(SIMCALL_FILE_MOVE, fd, fullpath); + return simcall(SIMCALL_FILE_MOVE, fd, fullpath); } inline static int simcall_BODY_mc_random(int min, int max) { diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 3837fc88ca..b9971508c9 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -339,12 +339,16 @@ case SIMCALL_SEM_GET_CAPACITY: break; case SIMCALL_FILE_READ: - simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2])); - break; + simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1]), + simgrid::simix::unmarshal(simcall->args[2])); + break; case SIMCALL_FILE_WRITE: - simcall_HANDLER_file_write(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2])); - break; + simcall_HANDLER_file_write(simcall, simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1]), + simgrid::simix::unmarshal(simcall->args[2])); + break; case SIMCALL_FILE_OPEN: simcall_HANDLER_file_open(simcall, simgrid::simix::unmarshal(simcall->args[0]), @@ -353,38 +357,43 @@ case SIMCALL_FILE_OPEN: break; case SIMCALL_FILE_CLOSE: - simcall_HANDLER_file_close(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); - break; + simcall_HANDLER_file_close(simcall, simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1])); + break; case SIMCALL_FILE_UNLINK: - simgrid::simix::marshal(simcall->result, SIMIX_file_unlink(simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]))); - SIMIX_simcall_answer(simcall); - break; + simgrid::simix::marshal(simcall->result, + SIMIX_file_unlink(simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1]))); + 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_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_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]), + 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]), simgrid::simix::unmarshal(simcall->args[1]))); - SIMIX_simcall_answer(simcall); - break; + simgrid::simix::marshal( + simcall->result, simcall_HANDLER_file_move(simcall, simgrid::simix::unmarshal(simcall->args[0]), + simgrid::simix::unmarshal(simcall->args[1]))); + SIMIX_simcall_answer(simcall); + break; case SIMCALL_MC_RANDOM: simgrid::simix::marshal(simcall->result, simcall_HANDLER_mc_random(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]))); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 469e761bbf..b74022207a 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -85,15 +85,15 @@ void sem_acquire(smx_sem_t sem) [[block]]; void sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]]; int sem_get_capacity(smx_sem_t sem); -sg_size_t file_read(smx_file_t fd, sg_size_t size, sg_host_t host) [[block]]; -sg_size_t file_write(smx_file_t fd, sg_size_t size, sg_host_t host) [[block]]; -smx_file_t file_open(const char* mount, const char* path, sg_storage_t st) [[block]]; -int file_close(smx_file_t fd, sg_host_t host) [[block]]; -int file_unlink(smx_file_t fd, sg_host_t host) [[nohandler]]; -sg_size_t file_get_size(smx_file_t fd) [[nohandler]]; -sg_size_t file_tell(smx_file_t fd) [[nohandler]]; -int file_seek(smx_file_t fd, sg_offset_t offset, int origin) [[nohandler]]; -int file_move(smx_file_t fd, const char* fullpath); +sg_size_t file_read(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]]; +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); void set_category(boost::intrusive_ptr synchro, const char* category) [[nohandler]]; diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index 91690a9836..5f40cb95bb 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -12,6 +12,7 @@ #include "simgrid/s4u/Storage.hpp" #include "src/surf/FileImpl.hpp" #include "src/surf/StorageImpl.hpp" +#include "surf/surf.h" #include @@ -23,14 +24,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)"); //SIMIX FILE READ -void simcall_HANDLER_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host) +void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host) { smx_activity_t synchro = SIMIX_file_read(fd, size, host); synchro->simcalls.push_back(simcall); simcall->issuer->waiting_synchro = synchro; } -smx_activity_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) +smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size, sg_host_t host) { /* check if the host is active */ if (host->isOff()) @@ -38,7 +39,7 @@ smx_activity_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl(); synchro->host = host; - synchro->surf_io = surf_host_read(host, fd->surf_file, size); + synchro->surf_io = surf_host_read(host, file, size); synchro->surf_io->setData(synchro); XBT_DEBUG("Create io synchro %p", synchro); @@ -47,21 +48,21 @@ smx_activity_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) } //SIMIX FILE WRITE -void simcall_HANDLER_file_write(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host) +void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host) { smx_activity_t synchro = SIMIX_file_write(fd, size, host); synchro->simcalls.push_back(simcall); simcall->issuer->waiting_synchro = synchro; } -smx_activity_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host) +smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size, sg_host_t host) { if (host->isOff()) THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname()); simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl(); synchro->host = host; - synchro->surf_io = surf_host_write(host, fd->surf_file, size); + synchro->surf_io = surf_host_write(host, file, size); synchro->surf_io->setData(synchro); XBT_DEBUG("Create io synchro %p", synchro); @@ -91,21 +92,21 @@ smx_activity_t SIMIX_file_open(const char* mount, const char* path, sg_storage_t } //SIMIX FILE CLOSE -void simcall_HANDLER_file_close(smx_simcall_t simcall, smx_file_t fd, sg_host_t host) +void simcall_HANDLER_file_close(smx_simcall_t simcall, surf_file_t fd, sg_host_t host) { smx_activity_t synchro = SIMIX_file_close(fd, host); synchro->simcalls.push_back(simcall); simcall->issuer->waiting_synchro = synchro; } -smx_activity_t SIMIX_file_close(smx_file_t fd, sg_host_t host) +smx_activity_t SIMIX_file_close(surf_file_t file, sg_host_t host) { if (host->isOff()) THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname()); simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl(); synchro->host = host; - synchro->surf_io = surf_host_close(host, fd->surf_file); + synchro->surf_io = surf_host_close(host, file); synchro->surf_io->setData(synchro); XBT_DEBUG("Create io synchro %p", synchro); @@ -113,38 +114,38 @@ smx_activity_t SIMIX_file_close(smx_file_t fd, sg_host_t host) } //SIMIX FILE UNLINK -int SIMIX_file_unlink(smx_file_t fd, sg_host_t host) +int SIMIX_file_unlink(surf_file_t file, sg_host_t host) { if (host->isOff()) THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname()); - return surf_host_unlink(host, fd->surf_file); + return surf_host_unlink(host, file); } -sg_size_t SIMIX_file_get_size(smx_file_t fd) +sg_size_t SIMIX_file_get_size(surf_file_t fd) { - return fd->surf_file->size(); + return fd->size(); } -sg_size_t SIMIX_file_tell(smx_file_t fd) +sg_size_t SIMIX_file_tell(surf_file_t fd) { - return fd->surf_file->tell(); + return fd->tell(); } -int SIMIX_file_seek(smx_file_t fd, sg_offset_t offset, int origin) +int SIMIX_file_seek(surf_file_t fd, sg_offset_t offset, int origin) { - return fd->surf_file->seek(offset, origin); + return fd->seek(offset, origin); } -int simcall_HANDLER_file_move(smx_simcall_t simcall, smx_file_t file, const char* fullpath) +int simcall_HANDLER_file_move(smx_simcall_t simcall, surf_file_t file, const char* fullpath) { return SIMIX_file_move(simcall->issuer, file, fullpath); } -int SIMIX_file_move(smx_actor_t process, smx_file_t file, const char* fullpath) +int SIMIX_file_move(smx_actor_t process, surf_file_t file, const char* fullpath) { sg_host_t host = process->host; - return surf_host_file_move(host, file->surf_file, fullpath); + return surf_host_file_move(host, file, fullpath); } void SIMIX_io_destroy(smx_activity_t synchro) diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index a63e7e14e6..f862638020 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -11,15 +11,15 @@ #include "simgrid/simix.h" #include "popping_private.h" -XBT_PRIVATE smx_activity_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host); -XBT_PRIVATE smx_activity_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host); +XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size, sg_host_t host); +XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size, sg_host_t host); 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(smx_file_t fd, sg_host_t host); -XBT_PRIVATE int SIMIX_file_unlink(smx_file_t fd, sg_host_t host); -XBT_PRIVATE sg_size_t SIMIX_file_get_size(smx_file_t fd); -XBT_PRIVATE sg_size_t SIMIX_file_tell(smx_file_t fd); -XBT_PRIVATE int SIMIX_file_seek(smx_file_t fd, sg_offset_t offset, int origin); -XBT_PRIVATE int SIMIX_file_move(smx_actor_t process, smx_file_t fd, const char* fullpath); +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); XBT_PRIVATE void SIMIX_io_finish(smx_activity_t synchro); diff --git a/src/simix/smx_private.h b/src/simix/smx_private.h index 85d91076b5..a0c713eba7 100644 --- a/src/simix/smx_private.h +++ b/src/simix/smx_private.h @@ -76,11 +76,6 @@ XBT_PUBLIC(void) SIMIX_clean(); _smx_throw_issuer->exception = std::make_exception_ptr(e); \ } else ((void)0) -typedef struct s_smx_file { - surf_file_t surf_file; -} s_smx_file_t; - - SG_END_DECL() #endif diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 579ea96a7c..dfe6fcc769 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -183,7 +183,6 @@ StorageAction *StorageN11::close(surf_file_t fd) ++it; } } - delete fd; StorageAction* action = new StorageN11Action(model(), 0, isOff(), this, CLOSE); return action; }