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;
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
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
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);
}
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])));
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);
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)
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);
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_;
}
}
-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 */
*/
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]
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);
}