From: Frederic Suter Date: Wed, 5 Jul 2017 12:16:29 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_17~471 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d6a677eea07bbb917ebf8aef3d281f37049c5254?hp=268fb240b28aeba1e066b2163cad6ba0016e545f Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/examples/s4u/actor-daemon/s4u_actor-daemon.cpp b/examples/s4u/actor-daemon/s4u_actor-daemon.cpp index 5ef84f6116..bc075a6ca5 100644 --- a/examples/s4u/actor-daemon/s4u_actor-daemon.cpp +++ b/examples/s4u/actor-daemon/s4u_actor-daemon.cpp @@ -39,5 +39,7 @@ int main(int argc, char* argv[]) e->run(); + delete e; + return 0; } diff --git a/include/simgrid/s4u/File.hpp b/include/simgrid/s4u/File.hpp index e3b644b75b..d6cd734f67 100644 --- a/include/simgrid/s4u/File.hpp +++ b/include/simgrid/s4u/File.hpp @@ -64,8 +64,8 @@ public: void move(const char* fullpath); /** Remove a file from disk */ - void unlink(); - void unlink(sg_host_t host); + int unlink(); + int unlink(sg_host_t host); /* FIXME: add these to the S4U API: XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t file); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 30066f40af..d691b543ed 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -147,16 +147,6 @@ XBT_PUBLIC(surf_action_t) surf_host_read(sg_host_t host, surf_file_t fd, sg_size /** @brief Create a file writing action on the given host */ XBT_PUBLIC(surf_action_t) surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size); -/** - * @brief Unlink a file descriptor - * - * @param host The surf host - * @param fd The file descriptor - * - * @return 0 if failed to unlink, 1 otherwise - */ -XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd); - /** * @brief Move a file to another location on the *same mount point*. * @details [long description] @@ -169,21 +159,6 @@ XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd); */ XBT_PUBLIC(int) surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath); -/** - * @brief Set the position indictator assiociated with the file descriptor to a new position - * @details [long description] - * - * @param host The surf host - * @param fd The file descriptor - * @param offset The offset from the origin - * @param origin Position used as a reference for the offset - * - SEEK_SET: beginning of the file - * - SEEK_CUR: current position indicator - * - SEEK_END: end of the file - * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED - */ -XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host, surf_file_t fd, sg_offset_t offset, int origin); - /** * @brief [brief description] * @details [long description] diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index 25595a9212..7f9a7d5b3a 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -93,14 +93,14 @@ void File::move(const char* fullpath) simcall_file_move(pimpl_,fullpath); } -void File::unlink() +int File::unlink() { - simcall_file_unlink(pimpl_, Host::current()); + return simgrid::simix::kernelImmediate([this] { return pimpl_->unlink(Host::current()); }); } -void File::unlink(sg_host_t host) +int File::unlink(sg_host_t host) { - simcall_file_unlink(pimpl_, host); + return simgrid::simix::kernelImmediate([this, host] { return pimpl_->unlink(host); }); } }} // namespace simgrid::s4u diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 55059b5321..b5d9fc0f33 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -689,16 +689,6 @@ int simcall_file_close(surf_file_t fd, sg_host_t host) return simcall_BODY_file_close(fd, host); } -/** - * \ingroup simix_file_management - * - */ -int simcall_file_unlink(surf_file_t fd, sg_host_t host) -{ - return simcall_BODY_file_unlink(fd, host); -} - - /** * \ingroup simix_file_management * \brief Move a file to another location on the *same mount point*. diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 7d414e68bf..617d35b663 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -1723,42 +1723,6 @@ static inline void simcall_file_close__set__result(smx_simcall_t simcall, int re simgrid::simix::marshal(simcall->result, result); } -static inline surf_file_t simcall_file_unlink__get__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline surf_file_t simcall_file_unlink__getraw__fd(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_file_unlink__set__fd(smx_simcall_t simcall, surf_file_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_host_t simcall_file_unlink__get__host(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline sg_host_t simcall_file_unlink__getraw__host(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_file_unlink__set__host(smx_simcall_t simcall, sg_host_t arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} -static inline int simcall_file_unlink__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline int simcall_file_unlink__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_file_unlink__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 0833c323b0..538c0631e9 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -360,13 +360,6 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) { return simcall(SIMCALL_FILE_CLOSE, fd, 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); - } - 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 e9a0bd4041..a0c7fd9c4a 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -65,7 +65,6 @@ typedef enum { SIMCALL_FILE_WRITE, SIMCALL_FILE_OPEN, SIMCALL_FILE_CLOSE, - SIMCALL_FILE_UNLINK, SIMCALL_FILE_MOVE, SIMCALL_MC_RANDOM, SIMCALL_SET_CATEGORY, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 69c9e26b71..84ed2a89bb 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -71,7 +71,6 @@ const char* simcall_names[] = { "SIMCALL_FILE_WRITE", "SIMCALL_FILE_OPEN", "SIMCALL_FILE_CLOSE", - "SIMCALL_FILE_UNLINK", "SIMCALL_FILE_MOVE", "SIMCALL_MC_RANDOM", "SIMCALL_SET_CATEGORY", @@ -358,13 +357,6 @@ case SIMCALL_FILE_CLOSE: 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; - 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 68ad25d980..8eb36595d6 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -89,7 +89,6 @@ 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]]; 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 f106155ce6..f303ed6e5c 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -113,15 +113,6 @@ smx_activity_t SIMIX_file_close(surf_file_t file, sg_host_t host) return synchro; } -//SIMIX FILE UNLINK -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, file); -} - 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/surf/FileImpl.hpp b/src/surf/FileImpl.hpp index eea45fccd2..0150b5cb74 100644 --- a/src/surf/FileImpl.hpp +++ b/src/surf/FileImpl.hpp @@ -26,22 +26,8 @@ public: void setPosition(sg_size_t size) { current_position_ = size; } void incrPosition(sg_size_t incr) { current_position_ += incr; } sg_size_t tell() { return current_position_; } - int seek(sg_offset_t offset, int origin) - { - switch (origin) { - case SEEK_SET: - current_position_ = offset; - return 0; - case SEEK_CUR: - current_position_ += offset; - return 0; - case SEEK_END: - current_position_ = size_ + offset; - return 0; - default: - return -1; - } - } + int seek(sg_offset_t offset, int origin); + int unlink(sg_host_t host); private: std::string path_; diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 66be41d95b..0b5ac06d5c 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -137,30 +137,6 @@ Action* HostImpl::write(surf_file_t fd, sg_size_t size) return st->write(fd, size); } -int HostImpl::unlink(surf_file_t fd) -{ - if (not fd) { - XBT_WARN("No such file descriptor. Impossible to unlink"); - return -1; - } else { - - simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount()); - /* Check if the file is on this storage */ - if (st->content_->find(fd->cname()) == st->content_->end()) { - XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->cname(), st->cname()); - return -1; - } else { - XBT_DEBUG("UNLINK %s on disk '%s'", fd->cname(), st->cname()); - st->usedSize_ -= fd->size(); - - // Remove the file from storage - st->content_->erase(fd->cname()); - - return 0; - } - } -} - int HostImpl::fileMove(surf_file_t fd, const char* fullpath) { /* Check if the new full path is on the same mount point */ diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 6fe57552f2..fd170decc3 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -80,15 +80,6 @@ public: */ virtual Action* close(surf_file_t fd); - /** - * @brief Unlink a file - * @details [long description] - * - * @param fd [description] - * @return [description] - */ - virtual int unlink(surf_file_t fd); - /** * @brief Read a file * diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 07be1f94a8..300d1ad0d7 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -169,10 +169,6 @@ surf_action_t surf_host_close(sg_host_t host, surf_file_t fd){ return host->pimpl_->close(fd); } -int surf_host_unlink(sg_host_t host, surf_file_t fd){ - return host->pimpl_->unlink(fd); -} - surf_action_t surf_host_read(sg_host_t host, surf_file_t fd, sg_size_t size){ return host->pimpl_->read(fd, size); } diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index f4d5b0f7cf..dd2b085502 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -325,6 +325,7 @@ set(SURF_SRC src/surf/cpu_interface.cpp src/surf/cpu_ti.cpp src/surf/fair_bottleneck.cpp + src/surf/FileImpl.cpp src/surf/instr_routing.cpp src/surf/instr_surf.cpp src/surf/lagrange.cpp