From: Pierre Veyre Date: Wed, 2 Oct 2013 09:14:07 +0000 (+0200) Subject: Change parameters order for msg_file_read, msg_file_write and in all their internal... X-Git-Tag: v3_9_90~46 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fdc1a282a7200e7131298083d6dd41f6aa8beb89?hp=780b6c1ab4d76eb7ee766640f5d654435a13e2ad Change parameters order for msg_file_read, msg_file_write and in all their internal layers --- diff --git a/examples/msg/io/file.c b/examples/msg/io/file.c index 7fe3888e1c..733c24d0e3 100644 --- a/examples/msg/io/file.c +++ b/examples/msg/io/file.c @@ -49,13 +49,13 @@ int host(int argc, char *argv[]) XBT_INFO("\tOpen file '%s'",file->fullname); - read = MSG_file_read(10000000,file); // Read for 10MB + read = MSG_file_read(file, 10000000); // Read for 10MB XBT_INFO("\tHave read %zu on %s",read,file->fullname); - write = MSG_file_write(100000,file); // Write for 100KB + write = MSG_file_write(file, 100000); // Write for 100KB XBT_INFO("\tHave written %zu on %s",write,file->fullname); - read = MSG_file_read(110000,file); // Read for 110KB + read = MSG_file_read(file, 110000); // Read for 110KB XBT_INFO("\tHave read %zu on %s (of size %zu)",read,file->fullname, MSG_file_get_size(file)); diff --git a/examples/msg/io/file_unlink.c b/examples/msg/io/file_unlink.c index ace947f706..a604a18042 100644 --- a/examples/msg/io/file_unlink.c +++ b/examples/msg/io/file_unlink.c @@ -46,7 +46,7 @@ int host(int argc, char *argv[]) file = MSG_file_open(mount,FILENAME1, NULL); // Write into the new file - write = MSG_file_write(100000,file); // Write for 100Ko + write = MSG_file_write(file,100000); // Write for 100Ko XBT_INFO("\tHave written %zu on %s",write,file->fullname); // Close the file diff --git a/include/msg/msg.h b/include/msg/msg.h index 083d34af56..2e6820842f 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -81,8 +81,8 @@ XBT_PUBLIC(const char *) MSG_environment_as_get_model(msg_as_t as); XBT_PUBLIC(xbt_dynar_t) MSG_environment_as_get_hosts(msg_as_t as); /************************** File handling ***********************************/ -XBT_PUBLIC(sg_storage_size_t) MSG_file_read(sg_storage_size_t size, msg_file_t fd); -XBT_PUBLIC(sg_storage_size_t) MSG_file_write(sg_storage_size_t size, msg_file_t fd); +XBT_PUBLIC(sg_storage_size_t) MSG_file_read(msg_file_t fd, sg_storage_size_t size); +XBT_PUBLIC(sg_storage_size_t) MSG_file_write(msg_file_t fd, sg_storage_size_t size); XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path, void* data); XBT_PUBLIC(void*) MSG_file_get_data(msg_file_t fd); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 3dbbba245d..1cce813a1d 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -481,8 +481,8 @@ XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem); /***************************** File **********************************/ XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd); XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data); -XBT_PUBLIC(sg_storage_size_t) simcall_file_read(sg_storage_size_t size, smx_file_t fd); -XBT_PUBLIC(sg_storage_size_t) simcall_file_write(sg_storage_size_t size, smx_file_t fd); +XBT_PUBLIC(sg_storage_size_t) simcall_file_read(smx_file_t fd, sg_storage_size_t size); +XBT_PUBLIC(sg_storage_size_t) simcall_file_write(smx_file_t fd, sg_storage_size_t size); XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path); XBT_PUBLIC(int) simcall_file_close(smx_file_t fd); XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index b1afac9b89..1e34b2c766 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -233,8 +233,8 @@ typedef struct surf_network_model_extension_public { typedef struct surf_storage_model_extension_public { surf_action_t(*open) (void *storage, const char* mount, const char* path); surf_action_t(*close) (void *storage, surf_file_t fd); - surf_action_t(*read) (void *storage, size_t size, surf_file_t fd); - surf_action_t(*write) (void *storage, size_t size, surf_file_t fd); + surf_action_t(*read) (void *storage, surf_file_t fd, sg_storage_size_t size); + surf_action_t(*write) (void *storage, surf_file_t fd, sg_storage_size_t size); surf_action_t(*stat) (void *storage, surf_file_t fd); surf_action_t(*ls) (void *storage, const char *path); xbt_dict_t(*get_properties) (const void *storage); @@ -279,20 +279,20 @@ typedef struct surf_workstation_model_extension_public { surf_action_t(*open) (void *workstation, const char* storage, const char* path); surf_action_t(*close) (void *workstation, surf_file_t fd); - surf_action_t(*read) (void *workstation, size_t size, surf_file_t fd); - surf_action_t(*write) (void *workstation, size_t size, surf_file_t fd); + surf_action_t(*read) (void *workstation, surf_file_t fd, sg_storage_size_t size); + surf_action_t(*write) (void *workstation, surf_file_t fd, sg_storage_size_t size); surf_action_t(*stat) (void *workstation, surf_file_t fd); int(*unlink) (void *workstation, surf_file_t fd); surf_action_t(*ls) (void *workstation, const char* mount, const char *path); - size_t (*get_size) (void *workstation, surf_file_t fd); + sg_storage_size_t (*get_size) (void *workstation, surf_file_t fd); xbt_dynar_t (*get_info) (void *workstation, surf_file_t fd); int (*link_shared) (const void *link); xbt_dict_t(*get_properties) (const void *resource); void (*add_traces) (void); - size_t (*get_free_size) (void *workstation,const char* name); - size_t (*get_used_size) (void *workstation,const char* name); + sg_storage_size_t (*get_free_size) (void *workstation,const char* name); + sg_storage_size_t (*get_used_size) (void *workstation,const char* name); xbt_dict_t (*get_storage_list) (void *workstation); } s_surf_model_extension_workstation_t; diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 69a18e21da..1d4c19e05c 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -85,9 +85,9 @@ void MSG_file_dump (msg_file_t fd){ * \param fd is a the file descriptor * \return the number of bytes successfully read */ -sg_storage_size_t MSG_file_read(sg_storage_size_t size, msg_file_t fd) +sg_storage_size_t MSG_file_read(msg_file_t fd, sg_storage_size_t size) { - return simcall_file_read(size, fd->simdata->smx_file); + return simcall_file_read(fd->simdata->smx_file, size); } /** \ingroup msg_file_management @@ -97,9 +97,9 @@ sg_storage_size_t MSG_file_read(sg_storage_size_t size, msg_file_t fd) * \param fd is a the file descriptor * \return the number of bytes successfully write */ -sg_storage_size_t MSG_file_write(sg_storage_size_t size, msg_file_t fd) +sg_storage_size_t MSG_file_write(msg_file_t fd, sg_storage_size_t size) { - return simcall_file_write(size, fd->simdata->smx_file); + return simcall_file_write(fd->simdata->smx_file, size); } /** \ingroup msg_file_management diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index a657e1b4fc..aee5550b9a 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -55,16 +55,14 @@ void SIMIX_file_set_data(smx_file_t fd, void *data){ } //SIMIX FILE READ -void SIMIX_pre_file_read(smx_simcall_t simcall, sg_storage_size_t size, - smx_file_t fd) +void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_storage_size_t size) { - smx_action_t action = SIMIX_file_read(simcall->issuer, size, fd); + smx_action_t action = SIMIX_file_read(simcall->issuer, fd, size); xbt_fifo_push(action->simcalls, simcall); simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_read(smx_process_t process, sg_storage_size_t size, - smx_file_t fd) +smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_storage_size_t size) { smx_action_t action; smx_host_t host = process->smx_host; @@ -85,8 +83,7 @@ smx_action_t SIMIX_file_read(smx_process_t process, sg_storage_size_t size, action->io.host = host; action->io.surf_io = - surf_workstation_model->extension.workstation.read(host, size, - fd->surf_file); + surf_workstation_model->extension.workstation.read(host, fd->surf_file, size); surf_workstation_model->action_data_set(action->io.surf_io, action); XBT_DEBUG("Create io action %p", action); @@ -95,16 +92,14 @@ smx_action_t SIMIX_file_read(smx_process_t process, sg_storage_size_t size, } //SIMIX FILE WRITE -void SIMIX_pre_file_write(smx_simcall_t simcall, sg_storage_size_t size, - smx_file_t fd) +void SIMIX_pre_file_write(smx_simcall_t simcall, smx_file_t fd, sg_storage_size_t size) { - smx_action_t action = SIMIX_file_write(simcall->issuer, size, fd); + smx_action_t action = SIMIX_file_write(simcall->issuer, fd, size); xbt_fifo_push(action->simcalls, simcall); simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_write(smx_process_t process, - sg_storage_size_t size, smx_file_t fd) +smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_storage_size_t size) { smx_action_t action; smx_host_t host = process->smx_host; @@ -125,8 +120,7 @@ smx_action_t SIMIX_file_write(smx_process_t process, action->io.host = host; action->io.surf_io = - surf_workstation_model->extension.workstation.write(host, size, - fd->surf_file); + surf_workstation_model->extension.workstation.write(host, fd->surf_file, size); surf_workstation_model->action_data_set(action->io.surf_io, action); XBT_DEBUG("Create io action %p", action); diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index c6032e417f..3cc035679b 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -23,8 +23,8 @@ static inline smx_storage_priv_t SIMIX_storage_priv(smx_storage_t storage){ smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data); void* SIMIX_pre_file_get_data(smx_simcall_t simcall,smx_file_t fd); void SIMIX_pre_file_set_data(smx_simcall_t simcall, smx_file_t fd, void *data); -void SIMIX_pre_file_read(smx_simcall_t simcall, sg_storage_size_t size, smx_file_t fd); -void SIMIX_pre_file_write(smx_simcall_t simcall, sg_storage_size_t size, smx_file_t fd); +void SIMIX_pre_file_read(smx_simcall_t simcall, smx_file_t fd, sg_storage_size_t size); +void SIMIX_pre_file_write(smx_simcall_t simcall,smx_file_t fd, sg_storage_size_t size); void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount, const char* path); void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd); @@ -36,10 +36,8 @@ xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd); void* SIMIX_file_get_data(smx_file_t fd); void SIMIX_file_set_data(smx_file_t fd, void *data); -smx_action_t SIMIX_file_read(smx_process_t process, sg_storage_size_t size, - smx_file_t fd); -smx_action_t SIMIX_file_write(smx_process_t process, sg_storage_size_t size, - smx_file_t fd); +smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_storage_size_t size); +smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_storage_size_t size); smx_action_t SIMIX_file_open(smx_process_t process, const char* storage, const char* path); smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 0b57815dc4..1e191f71e4 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -349,8 +349,8 @@ ACTION(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem_acquire_timeout, WITHOUT_ANSWER, TVOID(r ACTION(SIMCALL_SEM_GET_CAPACITY, sem_get_capacity, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \ ACTION(SIMCALL_FILE_GET_DATA, file_get_data, WITH_ANSWER, TPTR(result), TSPEC(fd, smx_file_t)) sep \ ACTION(SIMCALL_FILE_SET_DATA, file_set_data, WITH_ANSWER, TVOID(result), TSPEC(fd, smx_file_t), TPTR(data)) sep \ -ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TSIZE(result), TSIZE(size), TSPEC(fd, smx_file_t)) sep \ -ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TSIZE(size), TSPEC(fd, smx_file_t)) sep \ +ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TSIZE(result), TSPEC(fd, smx_file_t), TSIZE(size)) sep \ +ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TSPEC(fd, smx_file_t), TSIZE(size)) sep \ ACTION(SIMCALL_FILE_OPEN, file_open, WITHOUT_ANSWER, TSPEC(result, smx_file_t), TSTRING(mount), TSTRING(path)) sep \ ACTION(SIMCALL_FILE_CLOSE, file_close, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \ ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITH_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 1492cddfb0..bcc6ba83c1 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1203,18 +1203,18 @@ void simcall_file_set_data(smx_file_t fd, void *data) * \ingroup simix_file_management * */ -sg_storage_size_t simcall_file_read(sg_storage_size_t size, smx_file_t fd) +sg_storage_size_t simcall_file_read(smx_file_t fd, sg_storage_size_t size) { - return simcall_BODY_file_read(size, fd); + return simcall_BODY_file_read(fd, size); } /** * \ingroup simix_file_management * */ -sg_storage_size_t simcall_file_write(sg_storage_size_t size, smx_file_t fd) +sg_storage_size_t simcall_file_write(smx_file_t fd, sg_storage_size_t size) { - return simcall_BODY_file_write(size, fd); + return simcall_BODY_file_write(fd, size); } /** diff --git a/src/surf/storage.c b/src/surf/storage.c index 971b778b04..c36d8e68b4 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -125,8 +125,7 @@ static surf_action_t storage_action_close(void *storage, surf_file_t fd) return action; } -static surf_action_t storage_action_read(void *storage, sg_storage_size_t size, - surf_file_t fd) +static surf_action_t storage_action_read(void *storage, surf_file_t fd, sg_storage_size_t size) { if(size > fd->size) size = fd->size; @@ -134,8 +133,7 @@ static surf_action_t storage_action_read(void *storage, sg_storage_size_t size, return action; } -static surf_action_t storage_action_write(void *storage, sg_storage_size_t size, - surf_file_t fd) +static surf_action_t storage_action_write(void *storage, surf_file_t fd, sg_storage_size_t size) { char *filename = fd->name; XBT_DEBUG("\tWrite file '%s' size '%" PRIu64 "/%" PRIu64 "'", diff --git a/src/surf/workstation.c b/src/surf/workstation.c index a9497169ed..bbd96645e6 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -400,22 +400,20 @@ static surf_action_t ws_action_close(void *workstation, surf_file_t fd) return model->extension.storage.close(st, fd); } -static surf_action_t ws_action_read(void *workstation, sg_storage_size_t size, - surf_file_t fd) +static surf_action_t ws_action_read(void *workstation, surf_file_t fd, sg_storage_size_t size) { storage_t st = find_storage_on_mount_list(workstation, fd->mount); XBT_DEBUG("READ on disk '%s'",st->generic_resource.name); surf_model_t model = st->generic_resource.model; - return model->extension.storage.read(st, size, fd); + return model->extension.storage.read(st, fd, size); } -static surf_action_t ws_action_write(void *workstation, sg_storage_size_t size, - surf_file_t fd) +static surf_action_t ws_action_write(void *workstation, surf_file_t fd, sg_storage_size_t size) { storage_t st = find_storage_on_mount_list(workstation, fd->mount); XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name); surf_model_t model = st->generic_resource.model; - return model->extension.storage.write(st, size, fd); + return model->extension.storage.write(st, fd, size); } static int ws_file_unlink(void *workstation, surf_file_t fd)