Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename kernel::activity::Synchro into kernel::activity::ActivityImpl
[simgrid.git] / src / simix / smx_io.cpp
index 41a1ff3..c4eaa4a 100644 (file)
@@ -16,7 +16,7 @@
 #include "src/surf/surf_interface.hpp"
 #include "smx_private.h"
 
-#include "src/simix/SynchroIo.hpp"
+#include "src/kernel/activity/SynchroIo.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
 
@@ -45,7 +45,7 @@ smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data)
  */
 void SIMIX_storage_destroy(void *s)
 {
-  smx_storage_priv_t storage = (smx_storage_priv_t) s;
+  smx_storage_priv_t storage = static_cast<smx_storage_priv_t>(s);
 
   xbt_assert((storage != nullptr), "Invalid parameters");
   if (storage->data)
@@ -70,7 +70,7 @@ smx_synchro_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
 
-  simgrid::simix::Io *synchro = new simgrid::simix::Io();
+  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
   synchro->host = host;
   synchro->surf_io = surf_host_read(host, fd->surf_file, size);
 
@@ -93,7 +93,7 @@ smx_synchro_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
   if (host->isOff())
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
-  simgrid::simix::Io *synchro = new simgrid::simix::Io();
+  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
   synchro->host = host;
   synchro->surf_io = surf_host_write(host, fd->surf_file, size);
   synchro->surf_io->setData(synchro);
@@ -115,7 +115,7 @@ smx_synchro_t SIMIX_file_open(const char* fullpath, sg_host_t host)
   if (host->isOff())
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
-  simgrid::simix::Io *synchro = new simgrid::simix::Io();
+  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
   synchro->host = host;
   synchro->surf_io = surf_host_open(host, fullpath);
   synchro->surf_io->setData(synchro);
@@ -137,7 +137,7 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
   if (host->isOff())
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
-  simgrid::simix::Io *synchro = new simgrid::simix::Io();
+  simgrid::kernel::activity::Io *synchro = new simgrid::kernel::activity::Io();
   synchro->host = host;
   synchro->surf_io = surf_host_close(host, fd->surf_file);
   synchro->surf_io->setData(synchro);
@@ -146,7 +146,6 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
   return synchro;
 }
 
-
 //SIMIX FILE UNLINK
 int SIMIX_file_unlink(smx_file_t fd, sg_host_t host)
 {
@@ -155,7 +154,7 @@ int SIMIX_file_unlink(smx_file_t fd, sg_host_t host)
 
   int res = surf_host_unlink(host, fd->surf_file);
   xbt_free(fd);
-  return !!res;
+  return res;
 }
 
 sg_size_t simcall_HANDLER_file_get_size(smx_simcall_t simcall, smx_file_t fd)
@@ -254,13 +253,9 @@ const char* SIMIX_storage_get_host(smx_storage_t storage){
   return surf_storage_get_host(storage);
 }
 
-void SIMIX_post_io(smx_synchro_t synchro)
-{
-}
-
 void SIMIX_io_destroy(smx_synchro_t synchro)
 {
-  simgrid::simix::Io *io = static_cast<simgrid::simix::Io*>(synchro);
+  simgrid::kernel::activity::Io *io = static_cast<simgrid::kernel::activity::Io*>(synchro);
   XBT_DEBUG("Destroy synchro %p", synchro);
   if (io->surf_io)
     io->surf_io->unref();
@@ -270,24 +265,18 @@ void SIMIX_io_destroy(smx_synchro_t synchro)
 void SIMIX_io_finish(smx_synchro_t synchro)
 {
   for (smx_simcall_t simcall : synchro->simcalls) {
-
     switch (synchro->state) {
-
       case SIMIX_DONE:
         /* do nothing, synchro done */
         break;
-
       case SIMIX_FAILED:
         SMX_EXCEPTION(simcall->issuer, io_error, 0, "IO failed");
         break;
-
       case SIMIX_CANCELED:
         SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled");
         break;
-
       default:
-        xbt_die("Internal error in SIMIX_io_finish: unexpected synchro state %d",
-            (int)synchro->state);
+        xbt_die("Internal error in SIMIX_io_finish: unexpected synchro state %d", static_cast<int>(synchro->state));
     }
 
     if (simcall->issuer->host->isOff()) {