Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix initialization order.
[simgrid.git] / src / surf / storage.cpp
index d0b2766..bb5ee77 100644 (file)
@@ -2,7 +2,6 @@
 #include "surf_private.h"
 
 #define __STDC_FORMAT_MACROS
-#include <inttypes.h>
 
 extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf,
@@ -90,17 +89,17 @@ static void parse_storage_init(sg_platf_storage_cbarg_t storage)
                                      storage->properties);
 }
 
-static void parse_mstorage_init(sg_platf_mstorage_cbarg_t mstorage)
+static void parse_mstorage_init(sg_platf_mstorage_cbarg_t /*mstorage*/)
 {
   XBT_DEBUG("parse_mstorage_init");
 }
 
-static void parse_storage_type_init(sg_platf_storage_type_cbarg_t storagetype_)
+static void parse_storage_type_init(sg_platf_storage_type_cbarg_t /*storagetype_*/)
 {
   XBT_DEBUG("parse_storage_type_init");
 }
 
-static void parse_mount_init(sg_platf_mount_cbarg_t mount)
+static void parse_mount_init(sg_platf_mount_cbarg_t /*mount*/)
 {
   XBT_DEBUG("parse_mount_init");
 }
@@ -127,43 +126,6 @@ static void storage_parse_storage(sg_platf_storage_cbarg_t storage)
       (void *) xbt_strdup(storage->type_id));
 }
 
-static xbt_dict_t parse_storage_content(char *filename, sg_storage_size_t *used_size)
-{
-  *used_size = 0;
-  if ((!filename) || (strcmp(filename, "") == 0))
-    return NULL;
-
-  xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free);
-  FILE *file = NULL;
-
-  file = surf_fopen(filename, "r");
-  xbt_assert(file != NULL, "Cannot open file '%s' (path=%s)", filename,
-              xbt_str_join(surf_path, ":"));
-
-  char *line = NULL;
-  size_t len = 0;
-  ssize_t read;
-  char path[1024];
-  sg_storage_size_t size;
-
-
-  while ((read = xbt_getline(&line, &len, file)) != -1) {
-    if (read){
-    if(sscanf(line,"%s %" SCNu64, path, &size) == 2) {
-        *used_size += size;
-        sg_storage_size_t *psize = xbt_new(sg_storage_size_t, 1);
-        *psize = size;
-        xbt_dict_set(parse_content,path,psize,NULL);
-      } else {
-        xbt_die("Be sure of passing a good format for content file.\n");
-      }
-    }
-  }
-  free(line);
-  fclose(file);
-  return parse_content;
-}
-
 static void storage_parse_storage_type(sg_platf_storage_type_cbarg_t storage_type)
 {
   xbt_assert(!xbt_lib_get_or_null(storage_type_lib, storage_type->id,ROUTING_STORAGE_TYPE_LEVEL),
@@ -189,7 +151,7 @@ static void storage_parse_storage_type(sg_platf_storage_type_cbarg_t storage_typ
       ROUTING_STORAGE_TYPE_LEVEL,
       (void *) stype);
 }
-static void storage_parse_mstorage(sg_platf_mstorage_cbarg_t mstorage)
+static void storage_parse_mstorage(sg_platf_mstorage_cbarg_t /*mstorage*/)
 {
   THROW_UNIMPLEMENTED;
 //  mount_t mnt = xbt_new0(s_mount_t, 1);
@@ -352,7 +314,7 @@ double StorageModel::shareResources(double now)
   return min_completion;
 }
 
-void StorageModel::updateActionsState(double now, double delta)
+void StorageModel::updateActionsState(double /*now*/, double delta)
 {
   void *_action, *_next_action;
   StorageActionLmmPtr action = NULL;
@@ -366,12 +328,12 @@ void StorageModel::updateActionsState(double now, double delta)
      // For each action of type write
       double rate = lmm_variable_getvalue(action->p_variable);
       /* Hack to avoid rounding differences between x86 and x86_64
-       * (note that the next sizes are of type sg_storage_size_t). */
+       * (note that the next sizes are of type sg_size_t). */
       long incr = delta * rate + MAXMIN_PRECISION;
       action->p_storage->m_usedSize += incr; // disk usage
       action->p_file->size += incr; // file size
 
-      sg_storage_size_t *psize = xbt_new(sg_storage_size_t,1);
+      sg_size_t *psize = xbt_new(sg_size_t,1);
       *psize = action->p_file->size;
 
       xbt_dict_t content_dict = action->p_storage->p_content;
@@ -423,14 +385,14 @@ xbt_dict_t Storage::parseContent(char *filename)
   size_t len = 0;
   ssize_t read;
   char path[1024];
-  sg_storage_size_t size;
+  sg_size_t size;
 
 
   while ((read = xbt_getline(&line, &len, file)) != -1) {
     if (read){
-    if(sscanf(line,"%s %" SCNu64, path, &size) == 2) {
+    if(sscanf(line,"%s %llu", path, &size) == 2) {
         m_usedSize += size;
-        sg_storage_size_t *psize = xbt_new(sg_storage_size_t, 1);
+        sg_size_t *psize = xbt_new(sg_size_t, 1);
         *psize = size;
         xbt_dict_set(parse_content,path,psize,NULL);
       } else {
@@ -478,7 +440,7 @@ bool Storage::isUsed()
   return false;
 }
 
-void Storage::updateState(tmgr_trace_event_t event_type, double value, double date)
+void Storage::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/)
 {
   THROW_UNIMPLEMENTED;
 }
@@ -491,7 +453,7 @@ StorageActionPtr StorageLmm::ls(const char* path)
   xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
 
   char* key;
-  sg_storage_size_t size = 0;
+  sg_size_t size = 0;
   xbt_dict_cursor_t cursor = NULL;
 
   xbt_dynar_t dyn = NULL;
@@ -509,7 +471,7 @@ StorageActionPtr StorageLmm::ls(const char* path)
 
       // file
       if(xbt_dynar_length(dyn) == 1){
-        sg_storage_size_t *psize = xbt_new(sg_storage_size_t, 1);
+        sg_size_t *psize = xbt_new(sg_size_t, 1);
         *psize=size;
         xbt_dict_set(ls_dict, file, psize, NULL);
       }
@@ -531,13 +493,13 @@ StorageActionPtr StorageLmm::ls(const char* path)
 StorageActionPtr StorageLmm::open(const char* mount, const char* path)
 {
   XBT_DEBUG("\tOpen file '%s'",path);
-  sg_storage_size_t size, *psize;
-  psize = (sg_storage_size_t*) xbt_dict_get_or_null(p_content, path);
+  sg_size_t size, *psize;
+  psize = (sg_size_t*) xbt_dict_get_or_null(p_content, path);
   // if file does not exist create an empty file
   if(psize)
     size = *psize;
   else {
-       psize = xbt_new(sg_storage_size_t,1);
+       psize = xbt_new(sg_size_t,1);
     size = 0;
     *psize = size;
     xbt_dict_set(p_content, path, psize, NULL);
@@ -556,7 +518,7 @@ StorageActionPtr StorageLmm::open(const char* mount, const char* path)
 StorageActionPtr StorageLmm::close(surf_file_t fd)
 {
   char *filename = fd->name;
-  XBT_DEBUG("\tClose file '%s' size '%" PRIu64 "'", filename, fd->size);
+  XBT_DEBUG("\tClose file '%s' size '%llu'", filename, fd->size);
   // unref write actions from storage
   StorageActionLmmPtr write_action;
   unsigned int i;
@@ -573,7 +535,7 @@ StorageActionPtr StorageLmm::close(surf_file_t fd)
   return action;
 }
 
-StorageActionPtr StorageLmm::read(surf_file_t fd, sg_storage_size_t size)
+StorageActionPtr StorageLmm::read(surf_file_t fd, sg_size_t size)
 {
   if(size > fd->size)
     size = fd->size;
@@ -581,10 +543,10 @@ StorageActionPtr StorageLmm::read(surf_file_t fd, sg_storage_size_t size)
   return action;
 }
 
-StorageActionPtr StorageLmm::write(surf_file_t fd, sg_storage_size_t size)
+StorageActionPtr StorageLmm::write(surf_file_t fd, sg_size_t size)
 {
   char *filename = fd->name;
-  XBT_DEBUG("\tWrite file '%s' size '%" PRIu64 "/%" PRIu64 "'",filename,size,fd->size);
+  XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
 
   StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
   action->p_file = fd;
@@ -598,14 +560,14 @@ StorageActionPtr StorageLmm::write(surf_file_t fd, sg_storage_size_t size)
 
 void StorageLmm::rename(const char *src, const char *dest)
 {
-  sg_storage_size_t *psize, *new_psize;
-  psize = (sg_storage_size_t*) xbt_dict_get_or_null(p_content,src);
-  new_psize = xbt_new(sg_storage_size_t, 1);
+  sg_size_t *psize, *new_psize;
+  psize = (sg_size_t*) xbt_dict_get_or_null(p_content,src);
+  new_psize = xbt_new(sg_size_t, 1);
   *new_psize = *psize;
   if (psize){// src file exists
     xbt_dict_remove(p_content, src);
     xbt_dict_set(p_content, dest, new_psize,NULL);
-    XBT_DEBUG("Change file name from %s to %s, size '%" PRIu64 "'",src, dest, *psize);
+    XBT_DEBUG("Change file name from %s to %s, size '%llu'",src, dest, *psize);
   }
   else
     XBT_DEBUG("File %s doesn't exist",src);
@@ -619,7 +581,7 @@ xbt_dict_t StorageLmm::getContent()
   xbt_dict_t content_dict = xbt_dict_new_homogeneous(NULL);
   xbt_dict_cursor_t cursor = NULL;
   char *file;
-  sg_storage_size_t *psize;
+  sg_size_t *psize;
 
   xbt_dict_foreach(p_content, cursor, file, psize){
     xbt_dict_set(content_dict,file,psize,NULL);
@@ -627,7 +589,7 @@ xbt_dict_t StorageLmm::getContent()
   return content_dict;
 }
 
-sg_storage_size_t StorageLmm::getSize(){
+sg_size_t StorageLmm::getSize(){
   return m_size;
 }
 
@@ -637,7 +599,7 @@ sg_storage_size_t StorageLmm::getSize(){
 
 StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
   : Action(model, cost, failed), ActionLmm(model, cost, failed), StorageAction(model, cost, failed, storage, type) {
-  XBT_IN("(%s,%" PRIu64, storage->m_name, cost);
+  XBT_IN("(%s,%g", storage->m_name, cost);
   p_variable = lmm_variable_new(p_model->p_maxminSystem, this, 1.0, -1.0 , 3);
 
   // Must be less than the max bandwidth for all actions
@@ -705,12 +667,12 @@ bool StorageActionLmm::isSuspended()
   return m_suspended == 1;
 }
 
-void StorageActionLmm::setMaxDuration(double duration)
+void StorageActionLmm::setMaxDuration(double /*duration*/)
 {
   THROW_UNIMPLEMENTED;
 }
 
-void StorageActionLmm::setPriority(double priority)
+void StorageActionLmm::setPriority(double /*priority*/)
 {
   THROW_UNIMPLEMENTED;
 }