Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar and simplify simcalls (before killing them)
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 28 Jun 2017 08:51:54 +0000 (10:51 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 28 Jun 2017 08:51:54 +0000 (10:51 +0200)
src/include/surf/surf.h
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/simix/smx_io.cpp
src/simix/smx_io_private.h
src/surf/FileImpl.hpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/surf_c_bindings.cpp

index 144c096..30066f4 100644 (file)
@@ -52,7 +52,6 @@ typedef simgrid::surf::NetworkModel surf_NetworkModel;
 typedef simgrid::surf::StorageImpl surf_Storage;
 typedef simgrid::surf::StorageModel surf_StorageModel;
 typedef simgrid::surf::Resource surf_Resource;
-typedef simgrid::surf::HostImpl surf_Host;
 typedef simgrid::surf::Action surf_Action;
 typedef simgrid::surf::FileImpl surf_File;
 
@@ -83,7 +82,6 @@ typedef surf_CpuModel *surf_cpu_model_t;
 typedef surf_HostModel *surf_host_model_t;
 typedef surf_NetworkModel *surf_network_model_t;
 typedef surf_StorageModel *surf_storage_model_t;
-typedef surf_Storage* surf_storage_t;
 typedef surf_File* surf_file_t;
 
 /** @ingroup SURF_c_bindings
index 1b5db25..e89a565 100644 (file)
@@ -1772,8 +1772,5 @@ XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, smx_file_t fd,
 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_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 sg_size_t simcall_HANDLER_file_get_size(smx_simcall_t simcall, smx_file_t fd);
-XBT_PRIVATE sg_size_t simcall_HANDLER_file_tell(smx_simcall_t simcall, smx_file_t fd);
-XBT_PRIVATE int simcall_HANDLER_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_offset_t offset, int origin);
 XBT_PRIVATE int simcall_HANDLER_file_move(smx_simcall_t simcall, smx_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
index 02f679a..79b16f1 100644 (file)
@@ -365,19 +365,22 @@ inline static int simcall_BODY_file_unlink(smx_file_t fd, sg_host_t host) {
 
 inline static sg_size_t simcall_BODY_file_get_size(smx_file_t fd) {
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_file_get_size(&SIMIX_process_self()->simcall, fd);
+    if (0)
+      SIMIX_file_get_size(fd);
     return simcall<sg_size_t, smx_file_t>(SIMCALL_FILE_GET_SIZE, fd);
   }
 
 inline static sg_size_t simcall_BODY_file_tell(smx_file_t fd) {
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_file_tell(&SIMIX_process_self()->simcall, fd);
+    if (0)
+      SIMIX_file_tell(fd);
     return simcall<sg_size_t, smx_file_t>(SIMCALL_FILE_TELL, fd);
   }
 
 inline static int simcall_BODY_file_seek(smx_file_t fd, sg_offset_t offset, int origin) {
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_file_seek(&SIMIX_process_self()->simcall, fd, offset, origin);
+    if (0)
+      SIMIX_file_seek(fd, offset, origin);
     return simcall<int, smx_file_t, sg_offset_t, int>(SIMCALL_FILE_SEEK, fd, offset, origin);
   }
 
index 1fc2e8a..ff4bb38 100644 (file)
@@ -362,19 +362,24 @@ case SIMCALL_FILE_UNLINK:
       break;
 
 case SIMCALL_FILE_GET_SIZE:
-      simgrid::simix::marshal<sg_size_t>(simcall->result, simcall_HANDLER_file_get_size(simcall, simgrid::simix::unmarshal<smx_file_t>(simcall->args[0])));
-      SIMIX_simcall_answer(simcall);
-      break;
+  simgrid::simix::marshal<sg_size_t>(simcall->result,
+                                     SIMIX_file_get_size(simgrid::simix::unmarshal<smx_file_t>(simcall->args[0])));
+  SIMIX_simcall_answer(simcall);
+  break;
 
 case SIMCALL_FILE_TELL:
-      simgrid::simix::marshal<sg_size_t>(simcall->result, simcall_HANDLER_file_tell(simcall, simgrid::simix::unmarshal<smx_file_t>(simcall->args[0])));
-      SIMIX_simcall_answer(simcall);
-      break;
+  simgrid::simix::marshal<sg_size_t>(simcall->result,
+                                     SIMIX_file_tell(simgrid::simix::unmarshal<smx_file_t>(simcall->args[0])));
+  SIMIX_simcall_answer(simcall);
+  break;
 
 case SIMCALL_FILE_SEEK:
-      simgrid::simix::marshal<int>(simcall->result, simcall_HANDLER_file_seek(simcall, simgrid::simix::unmarshal<smx_file_t>(simcall->args[0]), simgrid::simix::unmarshal<sg_offset_t>(simcall->args[1]), simgrid::simix::unmarshal<int>(simcall->args[2])));
-      SIMIX_simcall_answer(simcall);
-      break;
+  simgrid::simix::marshal<int>(simcall->result,
+                               SIMIX_file_seek(simgrid::simix::unmarshal<smx_file_t>(simcall->args[0]),
+                                               simgrid::simix::unmarshal<sg_offset_t>(simcall->args[1]),
+                                               simgrid::simix::unmarshal<int>(simcall->args[2])));
+  SIMIX_simcall_answer(simcall);
+  break;
 
 case SIMCALL_FILE_MOVE:
       simgrid::simix::marshal<int>(simcall->result, simcall_HANDLER_file_move(simcall, simgrid::simix::unmarshal<smx_file_t>(simcall->args[0]), simgrid::simix::unmarshal<const char*>(simcall->args[1])));
index a7879aa..fe851a0 100644 (file)
@@ -90,9 +90,9 @@ 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);
-sg_size_t   file_tell(smx_file_t fd);
-int         file_seek(smx_file_t fd, sg_offset_t offset, int origin);
+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);
 
 int        mc_random(int min, int max);
index ee23b9d..91690a9 100644 (file)
@@ -121,35 +121,19 @@ int SIMIX_file_unlink(smx_file_t fd, sg_host_t host)
   return surf_host_unlink(host, fd->surf_file);
 }
 
-sg_size_t simcall_HANDLER_file_get_size(smx_simcall_t simcall, smx_file_t fd)
-{
-  return SIMIX_file_get_size(simcall->issuer, fd);
-}
-
-sg_size_t SIMIX_file_get_size(smx_actor_t process, smx_file_t fd)
+sg_size_t SIMIX_file_get_size(smx_file_t fd)
 {
   return fd->surf_file->size();
 }
 
-sg_size_t simcall_HANDLER_file_tell(smx_simcall_t simcall, smx_file_t fd)
-{
-  return SIMIX_file_tell(simcall->issuer, fd);
-}
-
-sg_size_t SIMIX_file_tell(smx_actor_t process, smx_file_t fd)
+sg_size_t SIMIX_file_tell(smx_file_t fd)
 {
   return fd->surf_file->tell();
 }
 
-int simcall_HANDLER_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_offset_t offset, int origin)
+int SIMIX_file_seek(smx_file_t fd, sg_offset_t offset, int origin)
 {
-  return SIMIX_file_seek(simcall->issuer, fd, offset, origin);
-}
-
-int SIMIX_file_seek(smx_actor_t process, smx_file_t fd, sg_offset_t offset, int origin)
-{
-  sg_host_t host = process->host;
-  return  surf_host_file_seek(host, fd->surf_file, offset, origin);
+  return fd->surf_file->seek(offset, origin);
 }
 
 int simcall_HANDLER_file_move(smx_simcall_t simcall, smx_file_t file, const char* fullpath)
index 70e553d..a63e7e1 100644 (file)
@@ -16,9 +16,9 @@ XBT_PRIVATE smx_activity_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_ho
 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_actor_t process, smx_file_t fd);
-XBT_PRIVATE sg_size_t SIMIX_file_tell(smx_actor_t process, smx_file_t fd);
-XBT_PRIVATE int SIMIX_file_seek(smx_actor_t process, smx_file_t fd, sg_offset_t offset, int origin);
+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 void SIMIX_io_destroy(smx_activity_t synchro);
index e8ae85b..b50fa8f 100644 (file)
@@ -26,6 +26,23 @@ 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;
+    }
+  }
+
 private:
   std::string path_;
   std::string mount_point_;
index b636340..4867930 100644 (file)
@@ -158,23 +158,6 @@ int HostImpl::unlink(surf_file_t fd)
   }
 }
 
-int HostImpl::fileSeek(surf_file_t fd, sg_offset_t offset, int origin)
-{
-  switch (origin) {
-  case SEEK_SET:
-    fd->setPosition(offset);
-    return 0;
-  case SEEK_CUR:
-    fd->incrPosition(offset);
-    return 0;
-  case SEEK_END:
-    fd->setPosition(fd->size() + offset);
-    return 0;
-  default:
-    return -1;
-  }
-}
-
 int HostImpl::fileMove(surf_file_t fd, const char* fullpath)
 {
   /* Check if the new full path is on the same mount point */
index d57d519..6fe5755 100644 (file)
@@ -107,20 +107,6 @@ public:
    */
   virtual Action* write(surf_file_t fd, sg_size_t size);
 
-  /**
-   * @brief Set the position indicator associated with the file descriptor to a new position
-   * @details [long description]
-   *
-   * @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
-   */
-  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*.
    * @details [long description]
index 9e2e4c5..07be1f9 100644 (file)
@@ -181,11 +181,6 @@ surf_action_t surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size){
   return host->pimpl_->write(fd, size);
 }
 
-int surf_host_file_seek(sg_host_t host, surf_file_t fd,
-                               sg_offset_t offset, int origin){
-  return host->pimpl_->fileSeek(fd, offset, origin);
-}
-
 int surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath){
   return host->pimpl_->fileMove(fd, fullpath);
 }