file contents, no need for a buffer as parameter ...
int host(int argc, char *argv[])
{
msg_file_t file = NULL;
- void *ptr = NULL;
char* mount = xbt_strdup("/home");
size_t read,write;
XBT_INFO("\tOpen file '%s'",file->name);
- read = MSG_file_read(ptr,10000000,file); // Read for 10MB
+ read = MSG_file_read(10000000,file); // Read for 10MB
XBT_INFO("\tHave read %zu on %s",read,file->name);
- write = MSG_file_write(ptr,100000,file); // Write for 100KB
+ write = MSG_file_write(100000,file); // Write for 100KB
XBT_INFO("\tHave written %zu on %s",write,file->name);
- read = MSG_file_read(ptr,110000,file); // Read for 110KB
+ read = MSG_file_read(110000,file); // Read for 110KB
XBT_INFO("\tHave read %zu on %s (of size %zu)",read,file->name,
MSG_file_get_size(file));
int host(int argc, char *argv[])
{
msg_file_t file = NULL;
- void *ptr = NULL;
char* mount = xbt_strdup("/home");
size_t write;
file = MSG_file_open(mount,FILENAME1);
// Write into the new file
- write = MSG_file_write(ptr,100000,file); // Write for 100Ko
+ write = MSG_file_write(100000,file); // Write for 100Ko
XBT_INFO("\tHave written %zu on %s",write,file->name);
// Close the file
XBT_PUBLIC(xbt_dynar_t) MSG_environment_as_get_hosts(msg_as_t as);
/************************** File handling ***********************************/
-XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, msg_file_t fd);
-XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, msg_file_t fd);
+XBT_PUBLIC(size_t) MSG_file_read(size_t size, msg_file_t fd);
+XBT_PUBLIC(size_t) MSG_file_write(size_t size, msg_file_t fd);
XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path);
XBT_PUBLIC(int) MSG_file_close(msg_file_t fd);
XBT_PUBLIC(size_t) MSG_file_get_size(msg_file_t fd);
double max_duration);
XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
-XBT_PUBLIC(size_t) simcall_file_read(void* ptr, size_t size, smx_file_t fd);
-XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size,
- smx_file_t fd);
+XBT_PUBLIC(size_t) simcall_file_read(size_t size, smx_file_t fd);
+XBT_PUBLIC(size_t) simcall_file_write(size_t size, smx_file_t fd);
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);
Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize) {
msg_file_t file = jfile_get_native(env, jfile);
size_t n;
- n = MSG_file_read(NULL,(size_t)jsize, file);
+ n = MSG_file_read((size_t)jsize, file);
return (jlong)n;
}
Java_org_simgrid_msg_File_write(JNIEnv *env, jobject jfile, jlong jsize) {
msg_file_t file = jfile_get_native(env, jfile);
size_t n;
- n = MSG_file_write(NULL, (size_t)jsize, file);
+ n = MSG_file_write((size_t)jsize, file);
return (jlong)n;
}
JNIEXPORT void JNICALL
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, void* ptr, size_t size,
- surf_file_t fd);
- surf_action_t(*write) (void *storage, const void* ptr, size_t size,
- 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(*stat) (void *storage, surf_file_t fd);
surf_action_t(*ls) (void *storage, const char *path);
} s_surf_model_extension_storage_t;
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, void* ptr, size_t size,
- surf_file_t fd);
- surf_action_t(*write) (void *workstation, const void* ptr, size_t size,
- 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(*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);
/********************************* File **************************************/
/** \ingroup msg_file_management
- * \brief Read elements of a file
+ * \brief Read a file
*
- * \param ptr buffer to where the data is copied
* \param size of the file to read
* \param fd is a the file descriptor
- * \return the number of items successfully read
+ * \return the number of bytes successfully read
*/
-size_t MSG_file_read(void* ptr, size_t size, msg_file_t fd)
+size_t MSG_file_read(size_t size, msg_file_t fd)
{
- return simcall_file_read(ptr, size, fd->simdata->smx_file);
+ return simcall_file_read(size, fd->simdata->smx_file);
}
/** \ingroup msg_file_management
- * \brief Write elements into a file
+ * \brief Write into a file
*
- * \param ptr buffer from where the data is copied
* \param size of the file to write
* \param fd is a the file descriptor
- * \return the number of items successfully write
+ * \return the number of bytes successfully write
*/
-size_t MSG_file_write(const void* ptr, size_t size, msg_file_t fd)
+size_t MSG_file_write(size_t size, msg_file_t fd)
{
- return simcall_file_write(ptr, size, fd->simdata->smx_file);
+ return simcall_file_write(size, fd->simdata->smx_file);
}
/** \ingroup msg_file_management
//SIMIX FILE READ
-void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
+void SIMIX_pre_file_read(smx_simcall_t simcall, size_t size,
smx_file_t fd)
{
- smx_action_t action = SIMIX_file_read(simcall->issuer, ptr, size, fd);
+ smx_action_t action = SIMIX_file_read(simcall->issuer, size, fd);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size,
+smx_action_t SIMIX_file_read(smx_process_t process, size_t size,
smx_file_t fd)
{
smx_action_t action;
action->io.host = host;
action->io.surf_io =
- surf_workstation_model->extension.workstation.read(host, ptr, size,
+ surf_workstation_model->extension.workstation.read(host, size,
fd->surf_file);
surf_workstation_model->action_data_set(action->io.surf_io, action);
}
//SIMIX FILE WRITE
-void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
+void SIMIX_pre_file_write(smx_simcall_t simcall, size_t size,
smx_file_t fd)
{
- smx_action_t action = SIMIX_file_write(simcall->issuer, ptr, size, fd);
+ smx_action_t action = SIMIX_file_write(simcall->issuer, size, fd);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
+smx_action_t SIMIX_file_write(smx_process_t process,
size_t size, smx_file_t fd)
{
smx_action_t action;
action->io.host = host;
action->io.surf_io =
- surf_workstation_model->extension.workstation.write(host, ptr, size,
+ surf_workstation_model->extension.workstation.write(host, size,
fd->surf_file);
surf_workstation_model->action_data_set(action->io.surf_io, action);
#include "simgrid/simix.h"
#include "smx_smurf_private.h"
-void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
- smx_file_t fd);
-void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
- smx_file_t fd);
+void SIMIX_pre_file_read(smx_simcall_t simcall, size_t size, smx_file_t fd);
+void SIMIX_pre_file_write(smx_simcall_t simcall, size_t size, smx_file_t fd);
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);
const char* mount, const char* path);
size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
-smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size,
+smx_action_t SIMIX_file_read(smx_process_t process, size_t size,
smx_file_t fd);
-smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
- size_t size, smx_file_t fd);
+smx_action_t SIMIX_file_write(smx_process_t process, size_t size,
+ smx_file_t fd);
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);
ACTION(SIMCALL_SEM_ACQUIRE, sem_acquire, WITHOUT_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t)) sep \
ACTION(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem_acquire_timeout, WITHOUT_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t), TDOUBLE(timeout)) sep \
ACTION(SIMCALL_SEM_GET_CAPACITY, sem_get_capacity, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \
-ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TSIZE(result), TPTR(ptr), TSIZE(size), TSPEC(fd, smx_file_t)) sep \
-ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSPEC(fd, smx_file_t)) 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_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 \
* \ingroup simix_file_management
*
*/
-size_t simcall_file_read(void* ptr, size_t size, smx_file_t fd)
+size_t simcall_file_read(size_t size, smx_file_t fd)
{
- return simcall_BODY_file_read(ptr, size, fd);
+ return simcall_BODY_file_read(size, fd);
}
/**
* \ingroup simix_file_management
*
*/
-size_t simcall_file_write(const void* ptr, size_t size,
- smx_file_t fd)
+size_t simcall_file_write(size_t size, smx_file_t fd)
{
- return simcall_BODY_file_write(ptr, size, fd);
+ return simcall_BODY_file_write(size, fd);
}
/**
return action;
}
-static surf_action_t storage_action_read(void *storage, void* ptr,
- size_t size, surf_file_t fd)
+static surf_action_t storage_action_read(void *storage, size_t size,
+ surf_file_t fd)
{
if(size > fd->size)
size = fd->size;
return action;
}
-static surf_action_t storage_action_write(void *storage, const void* ptr,
- size_t size, surf_file_t fd)
+static surf_action_t storage_action_write(void *storage, size_t size,
+ surf_file_t fd)
{
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
return model->extension.storage.close(st, fd);
}
-static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size,
+static surf_action_t ws_action_read(void *workstation, size_t size,
surf_file_t fd)
{
storage_t st = find_storage_on_mount_list(workstation, fd->storage);
XBT_DEBUG("READ on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
- return model->extension.storage.read(st, ptr, size, fd);
+ return model->extension.storage.read(st, size, fd);
}
-static surf_action_t ws_action_write(void *workstation, const void* ptr,
- size_t size, surf_file_t fd)
+static surf_action_t ws_action_write(void *workstation, size_t size,
+ surf_file_t fd)
{
storage_t st = find_storage_on_mount_list(workstation, fd->storage);
XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
- return model->extension.storage.write(st, ptr, size, fd);
+ return model->extension.storage.write(st, size, fd);
}
static int ws_file_unlink(void *workstation, surf_file_t fd)