From: suter Date: Tue, 27 May 2014 08:38:11 +0000 (+0200) Subject: changing type of offset parameter in file_seek from sg_size_t to the X-Git-Tag: v3_11~32 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0e543d081879517e1b52c18b6cb38f43ad229bdd changing type of offset parameter in file_seek from sg_size_t to the newly added sg_offset_t type. This allows users to move backwards in file as in the real fseek function. --- diff --git a/include/msg/msg.h b/include/msg/msg.h index 341afa20d8..b145614b7e 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -91,7 +91,7 @@ XBT_PUBLIC(int) MSG_file_close(msg_file_t fd); XBT_PUBLIC(sg_size_t) MSG_file_get_size(msg_file_t fd); XBT_PUBLIC(void) MSG_file_dump(msg_file_t fd); XBT_PUBLIC(msg_error_t) MSG_file_unlink(msg_file_t fd); -XBT_PUBLIC(msg_error_t) MSG_file_seek(msg_file_t fd, sg_size_t offset, int origin); +XBT_PUBLIC(msg_error_t) MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin); XBT_PUBLIC(sg_size_t) MSG_file_tell (msg_file_t fd); XBT_PUBLIC(void) __MSG_file_get_info(msg_file_t fd); XBT_PUBLIC(void) __MSG_file_priv_free(msg_file_priv_t priv); diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 4399096299..9a86f63676 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -95,6 +95,11 @@ static inline char* sg_storage_name(sg_storage_t storage) { */ typedef unsigned long long sg_size_t; +/** @ingroup m_datatypes_management_details + * @brief Type for any simgrid offset + */ +typedef long long sg_offset_t; + /* * Platform creation functions. Instead of passing 123 arguments to the creation functions * (one for each possible XML attribute), we pass structures containing them all. It removes the diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 2b0b20007f..95ee207081 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -505,7 +505,7 @@ XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd); XBT_PUBLIC(sg_size_t) simcall_file_get_size(smx_file_t fd); XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(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_size_t offset, int origin); +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); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 8c10321c38..fc0214886f 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -708,7 +708,9 @@ XBT_PUBLIC(int) surf_workstation_file_move(surf_resource_t workstation, surf_fil * - SEEK_END: end of the file * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED */ -XBT_PUBLIC(int) surf_workstation_file_seek(surf_resource_t workstation, surf_file_t fd, sg_size_t offset, int origin); +XBT_PUBLIC(int) surf_workstation_file_seek(surf_resource_t workstation, + surf_file_t fd, sg_offset_t offset, + int origin); /** * @brief [brief description] diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 5ddba3db34..65e40d693e 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -266,7 +266,7 @@ sg_size_t MSG_file_get_size(msg_file_t fd){ * MSG_TASK_CANCELED (=8). * */ -msg_error_t MSG_file_seek(msg_file_t fd, sg_size_t offset, int origin) +msg_error_t MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin) { msg_file_priv_t priv = MSG_file_priv(fd); return simcall_file_seek(priv->simdata->smx_file, offset, origin); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 7d1998e12f..b415e1413e 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -116,7 +116,7 @@ file_close False (int) (fd, void*, smx_file_t) (host, void*, smx_host_t) file_unlink True (int) (fd, void*, smx_file_t) file_get_size True (sg_size_t) (fd, void*, smx_file_t) file_tell True (sg_size_t) (fd, void*, smx_file_t) -file_seek True (int) (fd, void*, smx_file_t) (offset, sg_size_t) (origin, int) +file_seek True (int) (fd, void*, smx_file_t) (offset, sg_offset_t) (origin, int) file_get_info True (void*, xbt_dynar_t) (fd, void*, smx_file_t) file_move True (int) (fd, void*, smx_file_t) (fullpath, const char*) storage_get_free_size True (sg_size_t) (storage, void*, smx_storage_t) diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 27d6504986..570815e057 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -24,6 +24,7 @@ types = [('TCHAR', 'char', 'c') ,('TCPTR', 'const void*', 'cp') ,('TSIZE', 'size_t', 'sz') ,('TSGSIZE', 'sg_size_t', 'sgsz') + ,('TSGOFF', 'sg_offset_t', 'sgoff') ,('TVOID', 'void', '') ,('TDSPEC', 'void*', 'dp') ,('TFSPEC', 'FPtr', 'fp')] diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index cd48e0acf7..c00ac6fd78 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -240,12 +240,12 @@ xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd) return surf_workstation_get_info(host, fd->surf_file); } -int SIMIX_pre_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_size_t offset, int origin) +int SIMIX_pre_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_offset_t offset, int origin) { return SIMIX_file_seek(simcall->issuer, fd, offset, origin); } -int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_size_t offset, int origin) +int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_offset_t offset, int origin) { smx_host_t host = process->smx_host; return surf_workstation_file_seek(host, fd->surf_file, offset, origin); diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index 8ddde551c6..325a09ab4c 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -30,7 +30,7 @@ int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd); sg_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd); sg_size_t SIMIX_pre_file_tell(smx_simcall_t simcall, smx_file_t fd); xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd); -int SIMIX_pre_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_size_t offset, int origin); +int SIMIX_pre_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_offset_t offset, int origin); int SIMIX_pre_file_move(smx_simcall_t simcall, smx_file_t fd, const char* fullpath); smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host); smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t size, smx_host_t host); @@ -40,7 +40,7 @@ int SIMIX_file_unlink(smx_process_t process, smx_file_t fd); sg_size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd); sg_size_t SIMIX_file_tell(smx_process_t process, smx_file_t fd); xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd); -int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_size_t offset, int origin); +int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_offset_t offset, int origin); int SIMIX_file_move(smx_process_t process, smx_file_t fd, const char* fullpath); sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,smx_storage_t storage); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index ee9131a899..b33c06c557 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -48,6 +48,7 @@ union u_smx_scalar { double d; size_t sz; sg_size_t sgsz; + sg_offset_t sgoff; void* dp; FPtr fp; const void* cp; diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 700e2e3c4b..6924126788 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1397,7 +1397,7 @@ xbt_dynar_t simcall_file_get_info(smx_file_t fd) * \ingroup simix_file_management * */ -int simcall_file_seek(smx_file_t fd, sg_size_t offset, int origin){ +int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){ return simcall_BODY_file_seek(fd, offset, origin); } diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 61cc24ecb4..d5a0cb088e 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -392,7 +392,8 @@ size_t surf_workstation_file_tell(surf_resource_t workstation, surf_file_t fd){ return get_casted_workstation(workstation)->fileTell(fd); } -int surf_workstation_file_seek(surf_resource_t workstation, surf_file_t fd, sg_size_t offset, int origin){ +int surf_workstation_file_seek(surf_resource_t workstation, surf_file_t fd, + sg_offset_t offset, int origin){ return get_casted_workstation(workstation)->fileSeek(fd, offset, origin); } diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index 00ecfdf261..afdf7f0470 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -325,7 +325,7 @@ sg_size_t Workstation::fileTell(surf_file_t fd){ return fd->current_position; } -int Workstation::fileSeek(surf_file_t fd, sg_size_t offset, int origin){ +int Workstation::fileSeek(surf_file_t fd, sg_offset_t offset, int origin){ switch (origin) { case SEEK_SET: diff --git a/src/surf/workstation_interface.hpp b/src/surf/workstation_interface.hpp index b4e2dd7b0b..add4082eca 100644 --- a/src/surf/workstation_interface.hpp +++ b/src/surf/workstation_interface.hpp @@ -346,7 +346,7 @@ public: * - SEEK_END: end of the file * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED */ - virtual int fileSeek(surf_file_t fd, sg_size_t offset, int origin); + virtual int fileSeek(surf_file_t fd, sg_offset_t offset, int origin); /** * @brief Move a file to another location on the *same mount point*.