Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
changing type of offset parameter in file_seek from sg_size_t to the
authorsuter <frederic.suter@cc.in2p3.fr>
Tue, 27 May 2014 08:38:11 +0000 (10:38 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Tue, 27 May 2014 15:06:24 +0000 (17:06 +0200)
newly added sg_offset_t type. This allows users to move backwards in
file as in the real fseek function.

14 files changed:
include/msg/msg.h
include/simgrid/platf.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_io.c
src/simix/simcalls.in
src/simix/simcalls.py
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/surf_c_bindings.cpp
src/surf/workstation_interface.cpp
src/surf/workstation_interface.hpp

index 341afa2..b145614 100644 (file)
@@ -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);
index 4399096..9a86f63 100644 (file)
@@ -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
index 2b0b200..95ee207 100644 (file)
@@ -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);
index 8c10321..fc02148 100644 (file)
@@ -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]
index 5ddba3d..65e40d6 100644 (file)
@@ -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);
index 7d1998e..b415e14 100644 (file)
@@ -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)
index 27d6504..570815e 100755 (executable)
@@ -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')]
index cd48e0a..c00ac6f 100644 (file)
@@ -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);
index 8ddde55..325a09a 100644 (file)
@@ -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);
index ee9131a..b33c06c 100644 (file)
@@ -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;
index 700e2e3..6924126 100644 (file)
@@ -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);
 }
 
index 61cc24e..d5a0cb0 100644 (file)
@@ -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);
 }
 
index 00ecfdf..afdf7f0 100644 (file)
@@ -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:
index b4e2dd7..add4082 100644 (file)
@@ -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*.