{
msg_file_t file = NULL;
char* mount = xbt_strdup("/home");
- size_t read,write;
+ sg_storage_size_t read,write;
if(!strcmp(MSG_process_get_name(MSG_process_self()),"0")){
file = MSG_file_open(mount,FILENAME1, NULL);
{
msg_file_t file = NULL;
char* mount = xbt_strdup("/home");
- size_t write;
+ sg_storage_size_t write;
// First open
XBT_INFO("\tOpen file '%s'",FILENAME1);
typedef struct simdata_file *simdata_file_t;
typedef struct s_file_info {
- size_t size;
+ sg_storage_size_t size;
char* mount_point;
char* storageId;
char* storage_type;
#include "simgrid/simix.h"
+#include "simgrid/platf.h"
+
SG_BEGIN_DECL()
/** @brief Return code of most MSG functions
XBT_PUBLIC(xbt_dynar_t) MSG_environment_as_get_hosts(msg_as_t as);
/************************** File handling ***********************************/
-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(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(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);
XBT_PUBLIC(msg_error_t) MSG_file_set_data(msg_file_t fd, void * data);
XBT_PUBLIC(int) MSG_file_close(msg_file_t fd);
-XBT_PUBLIC(size_t) MSG_file_get_size(msg_file_t fd);
+XBT_PUBLIC(sg_storage_size_t) MSG_file_get_size(msg_file_t fd);
XBT_PUBLIC(void) MSG_file_dump(msg_file_t fd);
XBT_PUBLIC(int) MSG_file_unlink(msg_file_t fd);
XBT_PUBLIC(xbt_dict_t) MSG_file_ls(const char *mount, const char *path);
/************************** Storage handling ***********************************/
XBT_PUBLIC(msg_host_t) MSG_get_storage_by_name(const char *name);
XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage);
-XBT_PUBLIC(size_t) MSG_storage_get_free_size(const char* name);
-XBT_PUBLIC(size_t) MSG_storage_get_used_size(const char* name);
+XBT_PUBLIC(sg_storage_size_t) MSG_storage_get_free_size(const char* name);
+XBT_PUBLIC(sg_storage_size_t) MSG_storage_get_used_size(const char* name);
XBT_PUBLIC(msg_storage_t) MSG_storage_get_by_name(const char *name);
XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char *name, char *value,void_f_pvoid_t free_ctn);
static inline char* sg_storage_name(sg_storage_t storage) {
return storage->key;
}
+/* Type for any integer storage size */
+typedef uint64_t sg_storage_size_t;
+
/*
* Platform creation functions. Instead of passing 123 arguments to the creation functions
const char* content;
const char* content_type;
xbt_dict_t properties;
- size_t size;
+ sg_storage_size_t size;
} s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
#define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL}
#include "xbt/function_types.h"
#include "xbt/parmap.h"
#include "xbt/swag.h"
+#include "simgrid/platf.h"
SG_BEGIN_DECL()
/***************************** 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(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(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(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);
XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
-XBT_PUBLIC(size_t) simcall_file_get_size(smx_file_t fd);
+XBT_PUBLIC(sg_storage_size_t) simcall_file_get_size(smx_file_t fd);
XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
/***************************** Storage **********************************/
-XBT_PUBLIC(size_t) simcall_storage_get_free_size (const char* name);
-XBT_PUBLIC(size_t) simcall_storage_get_used_size (const char* name);
+XBT_PUBLIC(sg_storage_size_t) simcall_storage_get_free_size (const char* name);
+XBT_PUBLIC(sg_storage_size_t) simcall_storage_get_used_size (const char* name);
XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
fd->info->storage_type = xbt_dynar_pop_as(info, char *);
fd->info->storageId = xbt_dynar_pop_as(info, char *);
fd->info->mount_point = xbt_dynar_pop_as(info, char *);
- fd->info->size = xbt_dynar_pop_as(info, size_t);
+ fd->info->size = xbt_dynar_pop_as(info, sg_storage_size_t);
xbt_dynar_free_container(&info);
}
* \param fd is a the file descriptor
* \return the number of bytes successfully read
*/
-size_t MSG_file_read(size_t size, msg_file_t fd)
+sg_storage_size_t MSG_file_read(sg_storage_size_t size, msg_file_t fd)
{
return simcall_file_read(size, fd->simdata->smx_file);
}
* \param fd is a the file descriptor
* \return the number of bytes successfully write
*/
-size_t MSG_file_write(size_t size, msg_file_t fd)
+sg_storage_size_t MSG_file_write(sg_storage_size_t size, msg_file_t fd)
{
return simcall_file_write(size, fd->simdata->smx_file);
}
* \brief Return the size of a file
*
* \param fd is the file descriptor (#msg_file_t)
- * \return the size of the file (as a size_t)
+ * \return the size of the file (as a sg_storage_size_t)
*/
-
-size_t MSG_file_get_size(msg_file_t fd){
+sg_storage_size_t MSG_file_get_size(msg_file_t fd){
return simcall_file_get_size(fd->simdata->smx_file);
}
/** \ingroup msg_storage_management
* \brief Returns the free space size of a storage element
* \param name the name of a storage
- * \return the free space size of the storage element (as a size_t)
+ * \return the free space size of the storage element (as a sg_storage_size_t)
*/
-size_t MSG_storage_get_free_size(const char* name){
+sg_storage_size_t MSG_storage_get_free_size(const char* name){
return simcall_storage_get_free_size(name);
}
/** \ingroup msg_storage_management
* \brief Returns the used space size of a storage element
* \param name the name of a storage
- * \return the used space size of the storage element (as a size_t)
+ * \return the used space size of the storage element (as a sg_storage_size_t)
*/
-size_t MSG_storage_get_used_size(const char* name){
+sg_storage_size_t MSG_storage_get_used_size(const char* name){
return simcall_storage_get_used_size(name);
}
}
//SIMIX FILE READ
-void SIMIX_pre_file_read(smx_simcall_t simcall, size_t size,
+void SIMIX_pre_file_read(smx_simcall_t simcall, sg_storage_size_t size,
smx_file_t fd)
{
smx_action_t action = SIMIX_file_read(simcall->issuer, size, fd);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_read(smx_process_t process, size_t size,
+smx_action_t SIMIX_file_read(smx_process_t process, sg_storage_size_t size,
smx_file_t fd)
{
smx_action_t action;
}
//SIMIX FILE WRITE
-void SIMIX_pre_file_write(smx_simcall_t simcall, size_t size,
+void SIMIX_pre_file_write(smx_simcall_t simcall, sg_storage_size_t size,
smx_file_t fd)
{
smx_action_t action = SIMIX_file_write(simcall->issuer, size, fd);
}
smx_action_t SIMIX_file_write(smx_process_t process,
- size_t size, smx_file_t fd)
+ sg_storage_size_t size, smx_file_t fd)
{
smx_action_t action;
smx_host_t host = process->smx_host;
return action;
}
-size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd)
+sg_storage_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd)
{
return SIMIX_file_get_size(simcall->issuer, fd);
}
-size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd)
+sg_storage_size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd)
{
smx_host_t host = process->smx_host;
return surf_workstation_model->extension.workstation.get_size(host,
fd->surf_file);
}
-size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name)
+sg_storage_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name)
{
return SIMIX_storage_get_free_size(simcall->issuer, name);
}
-size_t SIMIX_storage_get_free_size(smx_process_t process, const char* name)
+sg_storage_size_t SIMIX_storage_get_free_size(smx_process_t process, const char* name)
{
smx_host_t host = process->smx_host;
return surf_workstation_model->extension.workstation.get_free_size(host,name);
}
-size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall, const char* name)
+sg_storage_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall, const char* name)
{
return SIMIX_storage_get_used_size(simcall->issuer, name);
}
-size_t SIMIX_storage_get_used_size(smx_process_t process, const char* name)
+sg_storage_size_t SIMIX_storage_get_used_size(smx_process_t process, const char* name)
{
smx_host_t host = process->smx_host;
return surf_workstation_model->extension.workstation.get_used_size(host,name);
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, 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_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_open(smx_simcall_t simcall, const char* mount,
const char* path);
void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd);
int SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
void SIMIX_pre_file_ls(smx_simcall_t simcall,
const char* mount, const char* path);
-size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
+sg_storage_size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
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, size_t size,
+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, size_t size,
+smx_action_t SIMIX_file_write(smx_process_t process, sg_storage_size_t size,
smx_file_t fd);
smx_action_t SIMIX_file_open(smx_process_t process, const char* storage,
const char* path);
int SIMIX_file_unlink(smx_process_t process, smx_file_t fd);
smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount,
const char *path);
-size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd);
+sg_storage_size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd);
xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd);
-size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,const char* name);
-size_t SIMIX_storage_get_free_size(smx_process_t process,const char* name);
+sg_storage_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,const char* name);
+sg_storage_size_t SIMIX_storage_get_free_size(smx_process_t process,const char* name);
-size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall,const char* name);
-size_t SIMIX_storage_get_used_size(smx_process_t process,const char* name);
+sg_storage_size_t SIMIX_pre_storage_get_used_size(smx_simcall_t simcall,const char* name);
+sg_storage_size_t SIMIX_storage_get_used_size(smx_process_t process,const char* name);
xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage);
xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t, smx_storage_t);
* \ingroup simix_file_management
*
*/
-size_t simcall_file_read(size_t size, smx_file_t fd)
+sg_storage_size_t simcall_file_read(sg_storage_size_t size, smx_file_t fd)
{
return simcall_BODY_file_read(size, fd);
}
* \ingroup simix_file_management
*
*/
-size_t simcall_file_write(size_t size, smx_file_t fd)
+sg_storage_size_t simcall_file_write(sg_storage_size_t size, smx_file_t fd)
{
return simcall_BODY_file_write(size, fd);
}
* \ingroup simix_file_management
*
*/
-size_t simcall_file_get_size (smx_file_t fd){
+sg_storage_size_t simcall_file_get_size (smx_file_t fd){
return simcall_BODY_file_get_size(fd);
}
* \ingroup simix_storage_management
* \brief Returns the free space size on a given storage element.
* \param storage name
- * \return Return the free space size on a given storage element (as size_t)
+ * \return Return the free space size on a given storage element (as sg_storage_size_t)
*/
-size_t simcall_storage_get_free_size (const char* name){
+sg_storage_size_t simcall_storage_get_free_size (const char* name){
return simcall_BODY_storage_get_free_size(name);
}
* \ingroup simix_storage_management
* \brief Returns the used space size on a given storage element.
* \param storage name
- * \return Return the used space size on a given storage element (as size_t)
+ * \return Return the used space size on a given storage element (as sg_storage_size_t)
*/
-size_t simcall_storage_get_used_size (const char* name){
+sg_storage_size_t simcall_storage_get_used_size (const char* name){
return simcall_BODY_storage_get_used_size(name);
}
#define GENERIC_LMM_ACTION(action) action->generic_lmm_action
#define GENERIC_ACTION(action) GENERIC_LMM_ACTION(action).generic_action
-static xbt_dict_t parse_storage_content(char *filename, size_t *used_size);
+static xbt_dict_t parse_storage_content(char *filename, sg_storage_size_t *used_size);
static int storage_action_unref(surf_action_t action);
static void storage_action_state_set(surf_action_t action, e_surf_action_state_t state);
-static surf_action_t storage_action_execute (void *storage, size_t size, e_surf_action_storage_type_t type);
+static surf_action_t storage_action_execute (void *storage, sg_storage_size_t size, e_surf_action_storage_type_t type);
static surf_action_t storage_action_ls(void *storage, const char* path)
{
xbt_dict_t ls_dict = xbt_dict_new();
char* key;
- size_t size = 0;
+ sg_storage_size_t size = 0;
xbt_dict_cursor_t cursor = NULL;
xbt_dynar_t dyn = NULL;
{
XBT_DEBUG("\tOpen file '%s'",path);
xbt_dict_t content_dict = ((storage_t)storage)->content;
- size_t size = (size_t) xbt_dict_get_or_null(content_dict,path);
+ sg_storage_size_t size = (sg_storage_size_t) xbt_dict_get_or_null(content_dict,path);
// if file does not exist create an empty file
if(!size){
return action;
}
-static surf_action_t storage_action_read(void *storage, size_t size,
+static surf_action_t storage_action_read(void *storage, sg_storage_size_t size,
surf_file_t fd)
{
if(size > fd->size)
return action;
}
-static surf_action_t storage_action_write(void *storage, size_t size,
+static surf_action_t storage_action_write(void *storage, sg_storage_size_t size,
surf_file_t fd)
{
char *filename = fd->name;
return action;
}
-static surf_action_t storage_action_execute (void *storage, size_t size, e_surf_action_storage_type_t type)
+static surf_action_t storage_action_execute (void *storage, sg_storage_size_t size, e_surf_action_storage_type_t type)
{
surf_action_storage_t action = NULL;
storage_t STORAGE = storage;
// Update the storage content (with file size)
double rate = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
/* Hack to avoid rounding differences between x86 and x86_64
- * (note that the next sizes are of type size_t). */
+ * (note that the next sizes are of type sg_storage_size_t). */
long incr = delta * rate + MAXMIN_PRECISION;
((storage_t)(action->storage))->used_size += incr; // disk usage
((surf_action_t)action)->file->size += incr; // file size
(void *) xbt_strdup(storage->type_id));
}
-static xbt_dict_t parse_storage_content(char *filename, size_t *used_size)
+static xbt_dict_t parse_storage_content(char *filename, sg_storage_size_t *used_size)
{
*used_size = 0;
if ((!filename) || (strcmp(filename, "") == 0))
size_t len = 0;
ssize_t read;
char path[1024];
- size_t size;
-
+ sg_storage_size_t size;
while ((read = xbt_getline(&line, &len, file)) != -1) {
if (read){
char *content_type;
char *type_id;
xbt_dict_t properties;
- size_t size;
+ sg_storage_size_t size;
} s_storage_type_t, *storage_type_t;
typedef struct s_mount {
typedef struct surf_file {
char *name;
char *mount;
- size_t size;
+ sg_storage_size_t size;
} s_surf_file_t;
typedef struct surf_storage {
lmm_constraint_t constraint_read; /* Constraint for maximum write bandwidth*/
xbt_dict_t content;
char* content_type;
- size_t size;
- size_t used_size;
+ sg_storage_size_t size;
+ sg_storage_size_t used_size;
char *type_id;
xbt_dynar_t write_actions;
xbt_dict_t properties;
return model->extension.storage.close(st, fd);
}
-static surf_action_t ws_action_read(void *workstation, size_t size,
+static surf_action_t ws_action_read(void *workstation, sg_storage_size_t size,
surf_file_t fd)
{
storage_t st = find_storage_on_mount_list(workstation, fd->mount);
return model->extension.storage.read(st, size, fd);
}
-static surf_action_t ws_action_write(void *workstation, size_t size,
+static surf_action_t ws_action_write(void *workstation, sg_storage_size_t size,
surf_file_t fd)
{
storage_t st = find_storage_on_mount_list(workstation, fd->mount);
return model->extension.storage.ls(st, path);
}
-static size_t ws_file_get_size(void *workstation, surf_file_t fd)
+static sg_storage_size_t ws_file_get_size(void *workstation, surf_file_t fd)
{
return fd->size;
}
return info;
}
-static size_t ws_storage_get_free_size(void *workstation,const char* name)
+static sg_storage_size_t ws_storage_get_free_size(void *workstation,const char* name)
{
storage_t st = find_storage_on_mount_list(workstation, name);
return st->size - st->used_size;
}
-static size_t ws_storage_get_used_size(void *workstation,const char* name)
+static sg_storage_size_t ws_storage_get_used_size(void *workstation,const char* name)
{
storage_t st = find_storage_on_mount_list(workstation, name);
return st->used_size;