Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 14 Aug 2013 07:31:29 +0000 (09:31 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 14 Aug 2013 07:31:29 +0000 (09:31 +0200)
1  2 
include/msg/datatypes.h
include/msg/msg.h
src/msg/msg_io.c
src/simix/smx_user.c

diff --combined include/msg/datatypes.h
@@@ -113,7 -113,6 +113,6 @@@ typedef struct s_file_info 
  typedef struct msg_file {
    char *fullname;               /**< @brief file full name (path+name)*/
    simdata_file_t simdata;       /**< @brief simulator data  */
-   void *data;                   /**< @brief user data */
    msg_file_info_t info;
  } s_msg_file_t;
  
@@@ -129,8 -128,12 +128,8 @@@ typedef struct msg_file *msg_file_t
  typedef struct simdata_storage *simdata_storage_t;
  
  typedef struct msg_storage {
 -  char *model;
 -  char *content_type;
 -  char *type_id;
 -  size_t size;
 -  xbt_dict_t properties;
 -  simdata_storage_t simdata;                /**< @brief simulator data  */
 +  char *name;
 +  simdata_storage_t simdata;    /**< @brief simulator data  */
    void *data;                   /**< @brief user data */
  } s_msg_storage_t;
  
diff --combined include/msg/msg.h
@@@ -80,7 -80,10 +80,10 @@@ XBT_PUBLIC(xbt_dynar_t) MSG_environment
  /************************** 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(msg_file_t) MSG_file_open(const char* mount, const char* path);
+ 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(void) MSG_file_dump(msg_file_t fd);
@@@ -91,8 -94,6 +94,8 @@@ XBT_PUBLIC(void) __MSG_file_get_info(ms
  /************************** Storage handling ***********************************/
  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(msg_storage_t) MSG_storage_get_by_name(const char *name);
 +XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
  
  /************************** AS Router handling ************************************/
  XBT_PUBLIC(const char *) MSG_as_router_get_property_value(const char* asr, const char *name);
diff --combined src/msg/msg_io.c
@@@ -28,6 -28,33 +28,33 @@@ void __MSG_file_get_info(msg_file_t fd)
  
    xbt_dynar_free_container(&info);
  }
+ /** \ingroup msg_file_management
+  *
+  * \brief Set the user data of a #msg_file_t.
+  *
+  * This functions checks whether some data has already been associated to \a file
+    or not and attach \a data to \a file if it is possible.
+  */
+ msg_error_t MSG_file_set_data(msg_file_t fd, void *data)
+ {
+   SIMIX_file_set_data(fd->simdata->smx_file,data);
+   return MSG_OK;
+ }
+ /** \ingroup msg_file_management
+  *
+  * \brief Return the user data of a #msg_file_t.
+  *
+  * This functions checks whether \a file is a valid pointer or not and return
+    the user data associated to \a file if it is possible.
+  */
+ void *MSG_file_get_data(msg_file_t fd)
+ {
+   return SIMIX_file_get_data(fd->simdata->smx_file);
+ }
  /** \ingroup msg_file_management
   * \brief Display information related to a file descriptor
   *
@@@ -74,16 -101,19 +101,19 @@@ size_t MSG_file_write(size_t size, msg_
   *
   * \param mount is the mount point where find the file is located
   * \param fullname is the file location on the storage
+  * \param data user data to attach to the file
   *
   * \return An #msg_file_t associated to the file
   */
- msg_file_t MSG_file_open(const char* mount, const char* fullname)
+ msg_file_t MSG_file_open(const char* mount, const char* fullname, void* data)
  {
    msg_file_t file = xbt_new(s_msg_file_t,1);
    file->fullname = xbt_strdup(fullname);
    file->simdata = xbt_new0(s_simdata_file_t,1);
    file->info = xbt_new0(s_file_info_t,1);
    file->simdata->smx_file = simcall_file_open(mount, fullname);
+   SIMIX_file_set_data(file->simdata->smx_file, data);
    return file;
  }
  
@@@ -149,8 -179,6 +179,8 @@@ xbt_dict_t MSG_file_ls(const char *moun
    return simcall_file_ls(mount, path);
  }
  
 +/********************************* Storage **************************************/
 +
  /** \ingroup msg_storage_management
   * \brief Return the free space size of a storage element
   * \param the storage name (#char*)
@@@ -168,45 -196,3 +198,45 @@@ size_t MSG_storage_get_free_size(const 
  size_t MSG_storage_get_used_size(const char* name){
    return simcall_storage_get_used_size(name);
  }
 +
 +/** \ingroup msg_storage_management
 + * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this storage
 + * \param storage a storage
 + * \return a dict containing the properties
 + */
 +xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
 +{
 +  xbt_assert((storage != NULL), "Invalid parameters (storage is NULL)");
 +
 +  xbt_die( "Not implemented yet");
 +  return xbt_dict_new();
 +  //return (simcall_host_get_properties(storage));
 +}
 +
 +/** \ingroup msg_storage_management
 + * \brief Finds a msg_storage_t using its name.
 + * \param name the name of a storage.
 + * \return the corresponding storage
 + */
 +msg_storage_t MSG_storage_get_by_name(const char *name)
 +{
 +  return (msg_storage_t) xbt_lib_get_elm_or_null(host_lib,name);
 +}
 +
 +/** \ingroup msg_storage_management
 + * \brief Return a dynar containing all the storages declared at a given point of time
 + */
 +xbt_dynar_t MSG_storages_as_dynar(void) {
 +  xbt_lib_cursor_t cursor;
 +  char *key;
 +  void **data;
 +  xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),NULL);
 +
 +  xbt_lib_foreach(host_lib, cursor, key, data) {
 +    if(routing_get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST) {
 +      xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor);
 +      xbt_dynar_push(res, &elm);
 +    }
 +  }
 +  return res;
 +}
diff --combined src/simix/smx_user.c
@@@ -1174,6 -1174,30 +1174,30 @@@ int simcall_sem_get_capacity(smx_sem_t 
    return simcall_BODY_sem_get_capacity(sem);
  }
  
+ /**
+  * \ingroup simix_file_management
+  * \brief Returns the user data associated to a file.
+  *
+  * \param fd A simix file
+  * \return the user data of this file
+  */
+ void* simcall_file_get_data(smx_file_t fd)
+ {
+   return simcall_BODY_file_get_data(fd);
+ }
+ /**
+  * \ingroup simix_file_management
+  * \brief Sets the user data associated to a file.
+  *
+  * \param fd A SIMIX file
+  * \param data The user data to set
+  */
+ void simcall_file_set_data(smx_file_t fd, void *data)
+ {
+   simcall_file_set_data(fd, data);
+ }
  /**
   * \ingroup simix_file_management
   *
@@@ -1265,7 -1289,7 +1289,7 @@@ size_t simcall_storage_get_used_size (c
  }
  
  /**
 - * \ingroup simix_host_management
 + * \ingroup simix_storage_management
   * \brief Return the list of storages mounted on an host.
   * \param host A SIMIX host
   * \return a dynar containing all storages mounted on the host
@@@ -1287,9 -1311,9 +1311,9 @@@ int simcall_mc_compare_snapshots(void *
    return simcall_BODY_mc_compare_snapshots(s1, s2);
  }
  
- int simcall_mc_random(void)
+ int simcall_mc_random(int min, int max)
  {
-   return simcall_BODY_mc_random();
+   return simcall_BODY_mc_random(min, max);
  }