/************************** File handling ***********************************/
-XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
-XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream);
+XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb,
+ msg_file_t fd);
+XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb,
+ 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);
XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb,
- smx_file_t stream);
+ smx_file_t fd);
XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size,
- size_t nmemb, smx_file_t stream);
+ size_t nmemb, 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);
#include "jmsg_file.h"
#include "jxbt_utilities.h"
-void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t stream) {
- (*env)->SetLongField(env, jfile, jfile_field_bind, (intptr_t)stream);
+void jfile_bind(JNIEnv *env, jobject jfile, msg_file_t fd) {
+ (*env)->SetLongField(env, jfile, jfile_field_bind, (intptr_t)fd);
}
msg_file_t jfile_get_native(JNIEnv *env, jobject jfile) {
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, double size, size_t nmemb, surf_file_t stream);
- surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*stat) (void *storage, surf_file_t stream);
- surf_action_t(*unlink) (void *storage, surf_file_t stream);
+ surf_action_t(*read) (void *storage, void* ptr, double size, size_t nmemb,
+ surf_file_t fd);
+ surf_action_t(*write) (void *storage, const void* ptr, size_t size,
+ size_t nmemb, surf_file_t fd);
+ surf_action_t(*stat) (void *storage, surf_file_t fd);
+ surf_action_t(*unlink) (void *storage, surf_file_t fd);
surf_action_t(*ls) (void *storage, const char *path);
size_t (*get_size) (void *storage, surf_file_t fd);
} s_surf_model_extension_storage_t;
double rate);
double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */
double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */
- surf_action_t(*open) (void *workstation, const char* storage, const char* path);
+ 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, size_t nmemb, surf_file_t stream);
- surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*stat) (void *workstation, surf_file_t stream);
- surf_action_t(*unlink) (void *workstation, surf_file_t stream);
+ surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb,
+ surf_file_t fd);
+ surf_action_t(*write) (void *workstation, const void* ptr, size_t size,
+ size_t nmemb, surf_file_t fd);
+ surf_action_t(*stat) (void *workstation, surf_file_t fd);
+ surf_action_t(*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);
* \param ptr buffer to where the data is copied
* \param size of each element
* \param nmemb is the number of elements of data to read
- * \param stream to read
+ * \param fd is a the file descriptor
* \return the number of items successfully read
*/
-size_t MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream)
+size_t MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t fd)
{
- return simcall_file_read(ptr, size, nmemb, stream->simdata->smx_file);
+ return simcall_file_read(ptr, size, nmemb, fd->simdata->smx_file);
}
/** \ingroup msg_file_management
* \param ptr buffer from where the data is copied
* \param size of each element
* \param nmemb is the number of elements of data to write
- * \param stream to write
+ * \param fd is a the file descriptor
* \return the number of items successfully write
*/
-size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream)
+size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t fd)
{
- return simcall_file_write(ptr, size, nmemb, stream->simdata->smx_file);
+ return simcall_file_write(ptr, size, nmemb, 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,
- size_t nmemb, smx_file_t stream)
+ size_t nmemb, smx_file_t fd)
{
- smx_action_t action = SIMIX_file_read(simcall->issuer, ptr, size, nmemb, stream);
+ smx_action_t action = SIMIX_file_read(simcall->issuer, ptr, size, nmemb, 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, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size,
+ size_t nmemb, smx_file_t fd)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.read(host, ptr, size, nmemb, stream->surf_file);
+ action->io.surf_io =
+ surf_workstation_model->extension.workstation.read(host, ptr, size, nmemb,
+ fd->surf_file);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
//SIMIX FILE WRITE
void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
- size_t nmemb, smx_file_t stream)
+ size_t nmemb, smx_file_t fd)
{
- smx_action_t action = SIMIX_file_write(simcall->issuer, ptr, size, nmemb, stream);
+ smx_action_t action = SIMIX_file_write(simcall->issuer, ptr, size, nmemb, 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, size_t size, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
+ size_t size, size_t nmemb, smx_file_t fd)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.write(host, ptr, size, nmemb, stream->surf_file);
+ action->io.surf_io =
+ surf_workstation_model->extension.workstation.write(host, ptr, size,
+ nmemb, fd->surf_file);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
#include "smx_smurf_private.h"
void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
- size_t nmemb, smx_file_t stream);
+ size_t nmemb, smx_file_t fd);
void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
- size_t nmemb, smx_file_t strea);
+ size_t nmemb, 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);
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,
- size_t nmemb, smx_file_t stream);
+ size_t nmemb, smx_file_t fd);
smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
- size_t size, size_t nmemb, smx_file_t stream);
+ size_t size, size_t nmemb, 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, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
-ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
+ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(fd, smx_file_t)) sep \
+ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), 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, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
* \ingroup simix_file_management
*
*/
-double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t fd)
{
- return simcall_BODY_file_read(ptr, size, nmemb, stream);
+ return simcall_BODY_file_read(ptr, size, nmemb, fd);
}
/**
* \ingroup simix_file_management
*
*/
-size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb,
+ smx_file_t fd)
{
- return simcall_BODY_file_write(ptr, size, nmemb, stream);
+ return simcall_BODY_file_write(ptr, size, nmemb, fd);
}
/**
return action;
}
-static surf_action_t storage_action_unlink(void *storage, surf_file_t stream)
+static surf_action_t storage_action_unlink(void *storage, surf_file_t fd)
{
surf_action_t action = storage_action_execute(storage,0, UNLINK);
// Add memory to storage
- ((storage_t)storage)->used_size -= stream->size;
+ ((storage_t)storage)->used_size -= fd->size;
// Remove the file from storage
xbt_dict_t content_dict = ((storage_t)storage)->content;
- xbt_dict_remove(content_dict,stream->name);
+ xbt_dict_remove(content_dict,fd->name);
- free(stream->name);
- xbt_free(stream);
+ free(fd->name);
+ xbt_free(fd);
return action;
}
return action;
}
-static surf_action_t storage_action_read(void *storage, void* ptr, double size, size_t nmemb, surf_file_t stream)
+static surf_action_t storage_action_read(void *storage, void* ptr, double size,
+ size_t nmemb, surf_file_t fd)
{
- if(size > stream->size)
- size = stream->size;
+ if(size > fd->size)
+ size = fd->size;
surf_action_t action = storage_action_execute(storage,size,READ);
return action;
}
-static surf_action_t storage_action_write(void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t storage_action_write(void *storage, const void* ptr,
+ size_t size, size_t nmemb,
+ surf_file_t fd)
{
- char *filename = stream->name;
- XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,stream->size);
+ char *filename = fd->name;
+ XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
surf_action_t action = storage_action_execute(storage,size,WRITE);
- action->file = stream;
+ action->file = fd;
// If the storage is full
if(((storage_t)storage)->used_size==((storage_t)storage)->size) {
return model->extension.storage.close(st, fd);
}
-static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size,
+ size_t nmemb, surf_file_t fd)
{
- storage_t st = find_storage_on_mount_list(workstation, stream->storage);
+ 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, (double)size, nmemb, stream);
+ return model->extension.storage.read(st, ptr, (double)size, nmemb, fd);
}
-static surf_action_t ws_action_write(void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t ws_action_write(void *workstation, const void* ptr,
+ size_t size, size_t nmemb, surf_file_t fd)
{
- storage_t st = find_storage_on_mount_list(workstation, stream->storage);
+ 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, nmemb, stream);
+ return model->extension.storage.write(st, ptr, size, nmemb, fd);
}
-static surf_action_t ws_action_stat(void *workstation, surf_file_t stream)
+static surf_action_t ws_action_unlink(void *workstation, surf_file_t fd)
{
- storage_t st = find_storage_on_mount_list(workstation, stream->storage);
- XBT_DEBUG("STAT on disk '%s'",st->generic_resource.name);
- surf_model_t model = st->generic_resource.model;
- return model->extension.storage.stat(st, stream);
-}
-
-static surf_action_t ws_action_unlink(void *workstation, surf_file_t stream)
-{
- storage_t st = find_storage_on_mount_list(workstation, stream->storage);
+ storage_t st = find_storage_on_mount_list(workstation, fd->storage);
XBT_DEBUG("UNLINK on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
- return model->extension.storage.unlink(st, stream);
+ return model->extension.storage.unlink(st, fd);
}
-static surf_action_t ws_action_ls(void *workstation, const char* mount, const char *path)
+static surf_action_t ws_action_ls(void *workstation, const char* mount,
+ const char *path)
{
XBT_DEBUG("LS on mount '%s' and file '%s'",mount, path);
storage_t st = find_storage_on_mount_list(workstation, mount);
return model->extension.storage.ls(st, path);
}
-static size_t ws_file_get_size(void *workstation, surf_file_t stream)
+static size_t ws_file_get_size(void *workstation, surf_file_t fd)
{
- return stream->size;
+ return fd->size;
}
static void surf_workstation_model_init_internal(void)