Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
All hosts types fusion to xbt_dictelm_t
authorPaul Bédaride <paul.bedaride@gmail.com>
Mon, 21 Jan 2013 13:08:04 +0000 (14:08 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Mon, 21 Jan 2013 13:24:17 +0000 (14:24 +0100)
42 files changed:
examples/lua/console/master_slave_bypass.tesh
include/msg/datatypes.h
include/msg/msg.h
include/simdag/datatypes.h
include/simgrid/platf.h
include/simgrid/simix.h
include/xbt/dict.h
include/xbt/lib.h
src/bindings/lua/lua_host.c
src/include/surf/surf.h
src/msg/instr_msg_process.c
src/msg/instr_msg_vm.c
src/msg/msg_environment.c
src/msg/msg_gos.c
src/msg/msg_host.c
src/msg/msg_mailbox.c
src/msg/msg_private.h
src/msg/msg_process.c
src/msg/msg_task.c
src/msg/msg_vm.c
src/simdag/private.h
src/simdag/sd_task.c
src/simdag/sd_workstation.c
src/simix/smx_deployment.c
src/simix/smx_global.c
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_io.c
src/simix/smx_network.c
src/simix/smx_new_api.c
src/simix/smx_process.c
src/simix/smx_synchro.c
src/simix/smx_user.c
src/surf/cpu_cas01.c
src/surf/cpu_ti.c
src/surf/storage.c
src/surf/workstation.c
src/surf/workstation_ptask_L07.c
src/xbt/dict.c
src/xbt/dict_cursor.c
src/xbt/dict_private.h
src/xbt/lib.c

index 7b5044d..9dc9627 100644 (file)
@@ -106,3 +106,4 @@ $ lua master_slave_bypass.lua --log=surf_parse.thres:critical
 > [Ginette:Slave:(4) 480.903871] [lua/INFO] Slave 'slave 3': I'm Done . See You !!
 > [Tremblay:Master:(1) 480.903871] [lua/INFO] Master: Everything's done.
 > [480.903871] [lua/INFO] Simulation's over.See you.
 > [Ginette:Slave:(4) 480.903871] [lua/INFO] Slave 'slave 3': I'm Done . See You !!
 > [Tremblay:Master:(1) 480.903871] [lua/INFO] Master: Everything's done.
 > [480.903871] [lua/INFO] Simulation's over.See you.
+
index cedd660..0536dbb 100644 (file)
@@ -7,6 +7,7 @@
 #define MSG_DATATYPE_H
 #include "xbt/misc.h"
 #include "xbt/file_stat.h"
 #define MSG_DATATYPE_H
 #include "xbt/misc.h"
 #include "xbt/file_stat.h"
+#include "xbt/lib.h"
 #include "simgrid/simix.h"
 #include "simgrid_config.h"     // for HAVE_TRACING
 
 #include "simgrid/simix.h"
 #include "simgrid_config.h"     // for HAVE_TRACING
 
@@ -29,13 +30,7 @@ typedef struct s_smx_rvpoint *msg_mailbox_t;
 
 /* ******************************** Host ************************************ */
 
 
 /* ******************************** Host ************************************ */
 
-typedef struct msg_host {
-  xbt_swag_t vms;
-  smx_host_t smx_host;          /**< SIMIX representation of this host   */
-#ifdef MSG_USE_DEPRECATED
-  msg_mailbox_t *mailboxes;     /**< the channels  */
-#endif
-} s_msg_host_t;
+extern int MSG_HOST_LEVEL;
 
 /** @brief Host datatype.
     @ingroup m_host_management
 
 /** @brief Host datatype.
     @ingroup m_host_management
@@ -47,7 +42,21 @@ typedef struct msg_host {
     some <em>private data</em> that can be only accessed by local
     process.
  */
     some <em>private data</em> that can be only accessed by local
     process.
  */
-typedef struct msg_host *msg_host_t;
+typedef xbt_dictelm_t msg_host_t;
+typedef s_xbt_dictelm_t s_msg_host_t;
+
+typedef struct msg_host_priv {
+  xbt_swag_t vms;
+#ifdef MSG_USE_DEPRECATED
+  msg_mailbox_t *mailboxes;     /**< the channels  */
+#endif
+} s_msg_host_priv_t, *msg_host_priv_t;
+
+static inline msg_host_priv_t MSG_host_priv(msg_host_t host){
+  return xbt_lib_get_level(host, MSG_HOST_LEVEL);
+}
+
+
 
 /* ******************************** Task ************************************ */
 
 
 /* ******************************** Task ************************************ */
 
index afac0e9..d3999e6 100644 (file)
@@ -95,7 +95,7 @@ XBT_PUBLIC(int) MSG_get_host_msgload(msg_host_t host);
 /* int MSG_get_msgload(void); This function lacks specification; discard it */
 XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_avail(msg_host_t h);
 /* int MSG_get_msgload(void); This function lacks specification; discard it */
 XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_avail(msg_host_t h);
-XBT_PUBLIC(void) __MSG_host_destroy(msg_host_t host);
+XBT_PUBLIC(void) __MSG_host_destroy(msg_host_priv_t host);
 
 /*property handlers*/
 XBT_PUBLIC(xbt_dict_t) MSG_host_get_properties(msg_host_t host);
 
 /*property handlers*/
 XBT_PUBLIC(xbt_dict_t) MSG_host_get_properties(msg_host_t host);
index 53a9f1a..40fa48b 100644 (file)
@@ -6,6 +6,7 @@
 
 #ifndef SIMDAG_DATATYPES_H
 #define SIMDAG_DATATYPES_H
 
 #ifndef SIMDAG_DATATYPES_H
 #define SIMDAG_DATATYPES_H
+#include "xbt/dict.h"
 
 /** @brief Workstation datatype
     @ingroup SD_datatypes_management
 
 /** @brief Workstation datatype
     @ingroup SD_datatypes_management
@@ -15,7 +16,7 @@
     resource with computing capabilities</em> and has a <em>name</em>.
 
     @see SD_workstation_management */
     resource with computing capabilities</em> and has a <em>name</em>.
 
     @see SD_workstation_management */
-typedef struct SD_workstation *SD_workstation_t;
+typedef xbt_dictelm_t SD_workstation_t;
 
 /** @brief Workstation access mode
     @ingroup SD_datatypes_management
 
 /** @brief Workstation access mode
     @ingroup SD_datatypes_management
index 677ea14..49ad142 100644 (file)
@@ -70,6 +70,11 @@ XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(c
 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
                                                                            double scale,
                                                                            double shape);
 XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id,
                                                                            double scale,
                                                                            double shape);
+typedef xbt_dictelm_t sg_host_t;
+static inline char* sg_host_name(sg_host_t host) {
+  return host->key;
+}
+
 
 /*
  * Platform creation functions. Instead of passing 123 arguments to the creation functions
 
 /*
  * Platform creation functions. Instead of passing 123 arguments to the creation functions
index cdb0a2a..46763d4 100644 (file)
@@ -34,7 +34,8 @@ typedef union u_smx_scalar u_smx_scalar_t;
 
     \see m_host_management
   @{ */
 
     \see m_host_management
   @{ */
-typedef struct s_smx_host *smx_host_t;
+typedef xbt_dictelm_t smx_host_t;
+typedef struct s_smx_host_priv *smx_host_priv_t;
 typedef enum {
   SIMIX_WAITING,
   SIMIX_READY,
 typedef enum {
   SIMIX_WAITING,
   SIMIX_READY,
index 80c6f80..cf00544 100644 (file)
@@ -45,7 +45,20 @@ SG_BEGIN_DECL()
  */
 
   /** \brief Dictionary data type (opaque structure) */
  */
 
   /** \brief Dictionary data type (opaque structure) */
+
 typedef struct s_xbt_dict *xbt_dict_t;
 typedef struct s_xbt_dict *xbt_dict_t;
+typedef struct s_xbt_dictelm *xbt_dictelm_t;
+typedef struct s_xbt_dictelm s_xbt_dictelm_t;
+typedef struct s_xbt_dictelm {
+  char *key;
+  int key_len;
+  unsigned int hash_code;
+
+  void *content;
+
+  xbt_dictelm_t next;
+} s_xbt_dictelm_t;
+
 XBT_PUBLIC(xbt_dict_t) xbt_dict_new(void);
 XBT_PUBLIC(xbt_dict_t) xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn);
 XBT_PUBLIC(void) xbt_dict_free(xbt_dict_t * dict);
 XBT_PUBLIC(xbt_dict_t) xbt_dict_new(void);
 XBT_PUBLIC(xbt_dict_t) xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn);
 XBT_PUBLIC(void) xbt_dict_free(xbt_dict_t * dict);
@@ -65,6 +78,8 @@ XBT_PUBLIC(void) xbt_dict_set(xbt_dict_t dict, const char *key, void *data,
 XBT_PUBLIC(void *) xbt_dict_get(xbt_dict_t dict, const char *key);
 XBT_PUBLIC(void *) xbt_dict_get_or_null(xbt_dict_t dict, const char *key);
 XBT_PUBLIC(char *) xbt_dict_get_key(xbt_dict_t dict, const void *data);
 XBT_PUBLIC(void *) xbt_dict_get(xbt_dict_t dict, const char *key);
 XBT_PUBLIC(void *) xbt_dict_get_or_null(xbt_dict_t dict, const char *key);
 XBT_PUBLIC(char *) xbt_dict_get_key(xbt_dict_t dict, const void *data);
+XBT_PUBLIC(xbt_dictelm_t) xbt_dict_get_elm(xbt_dict_t dict, const char *key);
+XBT_PUBLIC(xbt_dictelm_t) xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key);
 
 XBT_PUBLIC(void) xbt_dict_remove(xbt_dict_t dict, const char *key);
 XBT_PUBLIC(void) xbt_dict_reset(xbt_dict_t dict);
 
 XBT_PUBLIC(void) xbt_dict_remove(xbt_dict_t dict, const char *key);
 XBT_PUBLIC(void) xbt_dict_reset(xbt_dict_t dict);
@@ -123,13 +138,23 @@ XBT_PUBLIC(void) xbt_dicti_remove(xbt_dict_t dict, uintptr_t key);
  *  @{ */
 
   /** @brief Cursor on dictionaries (opaque type) */
  *  @{ */
 
   /** @brief Cursor on dictionaries (opaque type) */
+struct s_xbt_dict_cursor {
+  xbt_dictelm_t current;
+  int line;
+  xbt_dict_t dict;
+};
 typedef struct s_xbt_dict_cursor *xbt_dict_cursor_t;
 typedef struct s_xbt_dict_cursor *xbt_dict_cursor_t;
+
+static inline xbt_dictelm_t xbt_dict_cursor_get_elm(xbt_dict_cursor_t cursor) {
+  return cursor->current;
+}
+
 XBT_PUBLIC(xbt_dict_cursor_t) xbt_dict_cursor_new(const xbt_dict_t dict);
 XBT_PUBLIC(void) xbt_dict_cursor_free(xbt_dict_cursor_t * cursor);
 
 XBT_PUBLIC(void) xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
 
 XBT_PUBLIC(xbt_dict_cursor_t) xbt_dict_cursor_new(const xbt_dict_t dict);
 XBT_PUBLIC(void) xbt_dict_cursor_free(xbt_dict_cursor_t * cursor);
 
 XBT_PUBLIC(void) xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
 
-
+xbt_dictelm_t xbt_dict_cursor_get_elm(xbt_dict_cursor_t cursor);
 XBT_PUBLIC(char *) xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor);
 XBT_PUBLIC(void *) xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor);
 XBT_PUBLIC(void) xbt_dict_cursor_set_data(xbt_dict_cursor_t cursor,
 XBT_PUBLIC(char *) xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor);
 XBT_PUBLIC(void *) xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor);
 XBT_PUBLIC(void) xbt_dict_cursor_set_data(xbt_dict_cursor_t cursor,
index ec5db54..cdc9fc7 100644 (file)
@@ -28,6 +28,8 @@ XBT_PUBLIC(void) xbt_lib_set(xbt_lib_t lib, const char *name, int level,
                              void *obj);
 XBT_PUBLIC(void *) xbt_lib_get_or_null(xbt_lib_t lib, const char *name,
                                        int level);
                              void *obj);
 XBT_PUBLIC(void *) xbt_lib_get_or_null(xbt_lib_t lib, const char *name,
                                        int level);
+XBT_PUBLIC(xbt_dictelm_t) xbt_lib_get_elm_or_null(xbt_lib_t lib, const char *key);
+XBT_PUBLIC(void *) xbt_lib_get_level(xbt_dictelm_t elm, int level);
 
 #define xbt_lib_length(lib) xbt_dict_length((lib)->dict)
 
 
 #define xbt_lib_length(lib) xbt_dict_length((lib)->dict)
 
index 3090b4b..a862a2a 100644 (file)
@@ -184,7 +184,7 @@ static int l_host_sleep(lua_State *L)
 static int l_host_destroy(lua_State *L)
 {
   msg_host_t ht = sglua_check_host(L, 1);
 static int l_host_destroy(lua_State *L)
 {
   msg_host_t ht = sglua_check_host(L, 1);
-  __MSG_host_destroy(ht);
+  __MSG_host_destroy(MSG_host_priv(ht));
   return 0;
 }
 
   return 0;
 }
 
index 5bb8d19..5a612ac 100644 (file)
@@ -333,14 +333,24 @@ typedef struct surf_model {
 surf_model_t surf_model_init(void);
 void surf_model_exit(surf_model_t model);
 
 surf_model_t surf_model_init(void);
 void surf_model_exit(surf_model_t model);
 
+static inline void *surf_cpu_resource_priv(const void *host) {
+  return xbt_lib_get_level((void *)host, SURF_CPU_LEVEL);
+}
+static inline void *surf_workstation_resource_priv(const void *host){
+  return xbt_lib_get_level((void *)host, SURF_WKS_LEVEL);
+}
+static inline void *surf_storage_resource_priv(const void *host){
+  return xbt_lib_get_level((void *)host, SURF_STORAGE_LEVEL);
+}
+
 static inline void *surf_cpu_resource_by_name(const char *name) {
 static inline void *surf_cpu_resource_by_name(const char *name) {
-  return xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL);
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 static inline void *surf_workstation_resource_by_name(const char *name){
 }
 static inline void *surf_workstation_resource_by_name(const char *name){
-  return xbt_lib_get_or_null(host_lib, name, SURF_WKS_LEVEL);
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 static inline void *surf_storage_resource_by_name(const char *name){
 }
 static inline void *surf_storage_resource_by_name(const char *name){
-    return xbt_lib_get_or_null(storage_lib, name, SURF_STORAGE_LEVEL);
+  return xbt_lib_get_elm_or_null(storage_lib, name);
 }
 
 typedef struct surf_resource {
 }
 
 typedef struct surf_resource {
index dba5b6b..7c6239a 100644 (file)
@@ -66,7 +66,7 @@ void TRACE_msg_process_create (const char *process_name, int process_pid, msg_ho
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t host_container = PJ_container_get (SIMIX_host_get_name(host->smx_host));
+    container_t host_container = PJ_container_get (SIMIX_host_get_name(host));
     PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container);
   }
 }
     PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container);
   }
 }
index 73581c5..7b7e3e4 100644 (file)
@@ -46,7 +46,7 @@ void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host, msg_host_t new_h
     PJ_container_free(existing_container);
 
     //create new container on the new_host location
     PJ_container_free(existing_container);
 
     //create new container on the new_host location
-    msg = PJ_container_new(instr_vm_id(vm, str, len), INSTR_MSG_VM, PJ_container_get(SIMIX_host_get_name(new_host->smx_host)));
+    msg = PJ_container_new(instr_vm_id(vm, str, len), INSTR_MSG_VM, PJ_container_get(SIMIX_host_get_name(new_host)));
 
     //end link
     msg = PJ_container_get(instr_vm_id(vm, str, len));
 
     //end link
     msg = PJ_container_get(instr_vm_id(vm, str, len));
@@ -61,7 +61,7 @@ void TRACE_msg_vm_create (const char *vm_name, msg_host_t host)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t host_container = PJ_container_get (SIMIX_host_get_name(host->smx_host));
+    container_t host_container = PJ_container_get (SIMIX_host_get_name(host));
     PJ_container_new(instr_vm_id_2(vm_name, str, len), INSTR_MSG_VM, host_container);
   }
 }
     PJ_container_new(instr_vm_id_2(vm_name, str, len), INSTR_MSG_VM, host_container);
   }
 }
index 0eb3952..44ef32c 100644 (file)
@@ -45,7 +45,7 @@ void MSG_post_create_environment(void) {
   /* Initialize MSG hosts */
   xbt_lib_foreach(host_lib, cursor, name, data) {
     if(data[SIMIX_HOST_LEVEL])
   /* Initialize MSG hosts */
   xbt_lib_foreach(host_lib, cursor, name, data) {
     if(data[SIMIX_HOST_LEVEL])
-      __MSG_host_create((smx_host_t)data[SIMIX_HOST_LEVEL]);
+      __MSG_host_create(xbt_dict_cursor_get_elm(cursor));
   }
 }
 
   }
 }
 
index 38b579d..bcc59e1 100644 (file)
@@ -75,7 +75,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task)
       XBT_DEBUG("Parallel execution action created: %p", simdata->compute);
     } else {
       simdata->compute = simcall_host_execute(task->name,
       XBT_DEBUG("Parallel execution action created: %p", simdata->compute);
     } else {
       simdata->compute = simcall_host_execute(task->name,
-                                              p_simdata->m_host->smx_host,
+                                              p_simdata->m_host,
                                               simdata->computation_amount,
                                               simdata->priority);
 
                                               simdata->computation_amount,
                                               simdata->priority);
 
index a503903..a767553 100644 (file)
@@ -29,10 +29,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg);
 msg_host_t __MSG_host_create(smx_host_t workstation)
 {
   const char *name = SIMIX_host_get_name(workstation);
 msg_host_t __MSG_host_create(smx_host_t workstation)
 {
   const char *name = SIMIX_host_get_name(workstation);
-  msg_host_t host = xbt_new0(s_msg_host_t, 1);
+  msg_host_priv_t host = xbt_new0(s_msg_host_priv_t, 1);
   s_msg_vm_t vm; // simply to compute the offset
 
   s_msg_vm_t vm; // simply to compute the offset
 
-  host->smx_host = workstation;
   host->vms = xbt_swag_new(xbt_swag_offset(vm,host_vms_hookup));
 
 #ifdef MSG_USE_DEPRECATED
   host->vms = xbt_swag_new(xbt_swag_offset(vm,host_vms_hookup));
 
 #ifdef MSG_USE_DEPRECATED
@@ -52,10 +51,11 @@ msg_host_t __MSG_host_create(smx_host_t workstation)
 #endif
 
   xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
 #endif
 
   xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
-
-  return host;
+  
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 }
 
+
 /** \ingroup msg_host_management
  * \brief Finds a msg_host_t using its name.
  *
 /** \ingroup msg_host_management
  * \brief Finds a msg_host_t using its name.
  *
@@ -65,7 +65,7 @@ msg_host_t __MSG_host_create(smx_host_t workstation)
  */
 msg_host_t MSG_get_host_by_name(const char *name)
 {
  */
 msg_host_t MSG_get_host_by_name(const char *name)
 {
-  return (msg_host_t) xbt_lib_get_or_null(host_lib,name,MSG_HOST_LEVEL);
+  return (msg_host_t) xbt_lib_get_elm_or_null(host_lib,name);
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -77,7 +77,7 @@ msg_host_t MSG_get_host_by_name(const char *name)
  */
 msg_error_t MSG_host_set_data(msg_host_t host, void *data)
 {
  */
 msg_error_t MSG_host_set_data(msg_host_t host, void *data)
 {
-  SIMIX_host_set_data(host->smx_host,data);
+  SIMIX_host_set_data(host,data);
 
   return MSG_OK;
 }
 
   return MSG_OK;
 }
@@ -91,7 +91,7 @@ msg_error_t MSG_host_set_data(msg_host_t host, void *data)
  */
 void *MSG_host_get_data(msg_host_t host)
 {
  */
 void *MSG_host_get_data(msg_host_t host)
 {
-  return SIMIX_host_get_data(host->smx_host);
+  return SIMIX_host_get_data(host);
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -102,7 +102,7 @@ void *MSG_host_get_data(msg_host_t host)
    its name.
  */
 const char *MSG_host_get_name(msg_host_t host) {
    its name.
  */
 const char *MSG_host_get_name(msg_host_t host) {
-  return SIMIX_host_get_name(host->smx_host);
+  return SIMIX_host_get_name(host);
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -117,15 +117,14 @@ msg_host_t MSG_host_self(void)
 /*
  * \brief Destroys a host (internal call only)
  */
 /*
  * \brief Destroys a host (internal call only)
  */
-void __MSG_host_destroy(msg_host_t host) {
+void __MSG_host_destroy(msg_host_priv_t host) {
 
 #ifdef MSG_USE_DEPRECATED
   if (msg_global->max_channel > 0)
     free(host->mailboxes);
 #endif
   if (xbt_swag_size(host->vms) > 0 ) {
 
 #ifdef MSG_USE_DEPRECATED
   if (msg_global->max_channel > 0)
     free(host->mailboxes);
 #endif
   if (xbt_swag_size(host->vms) > 0 ) {
-    XBT_VERB("Host %s shut down, but it still hosts %d VMs. They will be leaked.",
-        MSG_host_get_name(host),xbt_swag_size(host->vms));
+    XBT_VERB("Host shut down, but it still hosts %d VMs. They will be leaked.",xbt_swag_size(host->vms));
   }
   xbt_swag_free(host->vms);
   free(host);
   }
   xbt_swag_free(host->vms);
   free(host);
@@ -172,8 +171,10 @@ xbt_dynar_t MSG_hosts_as_dynar(void) {
   xbt_dynar_t res = xbt_dynar_new(sizeof(msg_host_t),NULL);
 
   xbt_lib_foreach(host_lib, cursor, key, data) {
   xbt_dynar_t res = xbt_dynar_new(sizeof(msg_host_t),NULL);
 
   xbt_lib_foreach(host_lib, cursor, key, data) {
-    if(routing_get_network_element_type(key) == SURF_NETWORK_ELEMENT_HOST)
-      xbt_dynar_push(res, data + MSG_HOST_LEVEL);
+    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;
 }
   }
   return res;
 }
@@ -198,7 +199,7 @@ double MSG_get_host_speed(msg_host_t h)
 {
   xbt_assert((h != NULL), "Invalid parameters");
 
 {
   xbt_assert((h != NULL), "Invalid parameters");
 
-  return (simcall_host_get_speed(h->smx_host));
+  return (simcall_host_get_speed(h));
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -223,7 +224,7 @@ xbt_dict_t MSG_host_get_properties(msg_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
 
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
 
-  return (simcall_host_get_properties(host->smx_host));
+  return (simcall_host_get_properties(host));
 }
 
 /** \ingroup m_host_management
 }
 
 /** \ingroup m_host_management
@@ -249,5 +250,5 @@ void MSG_host_set_property_value(msg_host_t host, const char *name, char *value,
 int MSG_host_is_avail(msg_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
 int MSG_host_is_avail(msg_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
-  return (simcall_host_get_state(host->smx_host));
+  return (simcall_host_get_state(host));
 }
 }
index 17504f2..942f332 100644 (file)
@@ -41,8 +41,7 @@ int
 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
                                          msg_host_t host)
 {
 MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
                                          msg_host_t host)
 {
-  return simcall_rdv_comm_count_by_host(mailbox,
-                                      host->smx_host);
+  return simcall_rdv_comm_count_by_host(mailbox, host);
 }
 
 msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
 }
 
 msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
index 7edcb02..b7801c9 100644 (file)
@@ -139,7 +139,7 @@ XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
 #endif
 
 msg_host_t __MSG_host_create(smx_host_t workstation);
 #endif
 
 msg_host_t __MSG_host_create(smx_host_t workstation);
-void __MSG_host_destroy(msg_host_t host);
+void __MSG_host_destroy(msg_host_priv_t host);
 
 void __MSG_display_process_status(void);
 
 
 void __MSG_display_process_status(void);
 
index ddce625..cf7ce52 100644 (file)
@@ -182,7 +182,7 @@ msg_process_t MSG_process_create_with_environment(const char *name,
 #endif
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
 #endif
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
 simcall_process_create(&process, name, code, simdata, SIMIX_host_get_name(host->smx_host), -1,
simcall_process_create(&process, name, code, simdata, sg_host_name(host), -1,
                            argc, argv, properties,0);
 
   if (!process) {
                            argc, argv, properties,0);
 
   if (!process) {
@@ -231,7 +231,7 @@ msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
   msg_host_t now = simdata->m_host;
   TRACE_msg_process_change_host(process, now, host);
 #endif
   msg_host_t now = simdata->m_host;
   TRACE_msg_process_change_host(process, now, host);
 #endif
-  simcall_process_change_host(process, host->smx_host);
+  simcall_process_change_host(process, host);
   return MSG_OK;
 }
 
   return MSG_OK;
 }
 
index 013c4f1..101689c 100644 (file)
@@ -112,7 +112,7 @@ MSG_parallel_task_create(const char *name, int host_nb,
   simdata->comm_amount = communication_amount;
 
   for (i = 0; i < host_nb; i++)
   simdata->comm_amount = communication_amount;
 
   for (i = 0; i < host_nb; i++)
-    simdata->host_list[i] = host_list[i]->smx_host;
+    simdata->host_list[i] = host_list[i];
 
   return task;
 }
 
   return task;
 }
index 426bbb7..c025372 100644 (file)
@@ -28,7 +28,7 @@ msg_vm_t MSG_vm_start(msg_host_t location, const char *name, int coreAmount) {
   res->processes = xbt_dynar_new(sizeof(msg_process_t),NULL);
 
   xbt_swag_insert(res,msg_global->vms);
   res->processes = xbt_dynar_new(sizeof(msg_process_t),NULL);
 
   xbt_swag_insert(res,msg_global->vms);
-  xbt_swag_insert(res,location->vms);
+  xbt_swag_insert(res, MSG_host_priv(location)->vms);
 
   #ifdef HAVE_TRACING
   TRACE_msg_vm_create(name, location);
 
   #ifdef HAVE_TRACING
   TRACE_msg_vm_create(name, location);
@@ -111,8 +111,8 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t destination) {
   xbt_dynar_foreach(vm->processes,cpt,process) {
     MSG_process_migrate(process,destination);
   }
   xbt_dynar_foreach(vm->processes,cpt,process) {
     MSG_process_migrate(process,destination);
   }
-  xbt_swag_remove(vm,vm->location->vms);
-  xbt_swag_insert_at_tail(vm,destination->vms);
+  xbt_swag_remove(vm, MSG_host_priv(vm->location)->vms);
+  xbt_swag_insert_at_tail(vm, MSG_host_priv(destination)->vms);
   
   #ifdef HAVE_TRACING
   TRACE_msg_vm_change_host(vm,vm->location,destination);
   
   #ifdef HAVE_TRACING
   TRACE_msg_vm_change_host(vm,vm->location,destination);
index 1010a54..e4025a3 100644 (file)
@@ -56,14 +56,18 @@ typedef struct SD_link {
 } s_SD_link_t;
 
 /* Workstation */
 } s_SD_link_t;
 
 /* Workstation */
+typedef s_xbt_dictelm_t s_SD_workstation_t;
 typedef struct SD_workstation {
 typedef struct SD_workstation {
-  void *surf_workstation;       /* surf object */
   void *data;                   /* user data */
   e_SD_workstation_access_mode_t access_mode;
 
   xbt_fifo_t task_fifo;         /* only used in sequential mode */
   SD_task_t current_task;       /* only used in sequential mode */
   void *data;                   /* user data */
   e_SD_workstation_access_mode_t access_mode;
 
   xbt_fifo_t task_fifo;         /* only used in sequential mode */
   SD_task_t current_task;       /* only used in sequential mode */
-} s_SD_workstation_t;
+} s_SD_workstation_priv_t, *SD_workstation_priv_t;
+
+static inline SD_workstation_priv_t SD_workstation_priv(SD_workstation_t host){
+  return xbt_lib_get_level(host, SD_HOST_LEVEL);
+}
 
 /* Task */
 typedef struct SD_task {
 
 /* Task */
 typedef struct SD_task {
index ba64864..472e332 100644 (file)
@@ -1050,7 +1050,7 @@ void __SD_task_really_run(SD_task_t task)
   for (i = 0; i < workstation_nb; i++) {
     if (SD_workstation_get_access_mode(task->workstation_list[i]) ==
         SD_WORKSTATION_SEQUENTIAL_ACCESS) {
   for (i = 0; i < workstation_nb; i++) {
     if (SD_workstation_get_access_mode(task->workstation_list[i]) ==
         SD_WORKSTATION_SEQUENTIAL_ACCESS) {
-      task->workstation_list[i]->current_task = task;
+      SD_workstation_priv(task->workstation_list[i])->current_task = task;
       xbt_assert(__SD_workstation_is_busy(task->workstation_list[i]),
                   "The workstation should be busy now");
     }
       xbt_assert(__SD_workstation_is_busy(task->workstation_list[i]),
                   "The workstation should be busy now");
     }
@@ -1066,7 +1066,7 @@ void __SD_task_really_run(SD_task_t task)
   surf_workstations = xbt_new(void *, workstation_nb);
 
   for (i = 0; i < workstation_nb; i++)
   surf_workstations = xbt_new(void *, workstation_nb);
 
   for (i = 0; i < workstation_nb; i++)
-    surf_workstations[i] = task->workstation_list[i]->surf_workstation;
+    surf_workstations[i] = task->workstation_list[i];
 
   double *computation_amount = xbt_new0(double, workstation_nb);
   double *communication_amount = xbt_new0(double, workstation_nb * workstation_nb);
 
   double *computation_amount = xbt_new0(double, workstation_nb);
   double *communication_amount = xbt_new0(double, workstation_nb * workstation_nb);
@@ -1132,11 +1132,11 @@ int __SD_task_try_to_run(SD_task_t task)
   if (!can_start) {             /* if the task cannot start and is not in the FIFOs yet */
     for (i = 0; i < task->workstation_nb; i++) {
       workstation = task->workstation_list[i];
   if (!can_start) {             /* if the task cannot start and is not in the FIFOs yet */
     for (i = 0; i < task->workstation_nb; i++) {
       workstation = task->workstation_list[i];
-      if (workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
+      if (SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
         XBT_DEBUG("Pushing task '%s' in the FIFO of workstation '%s'",
                SD_task_get_name(task),
                SD_workstation_get_name(workstation));
         XBT_DEBUG("Pushing task '%s' in the FIFO of workstation '%s'",
                SD_task_get_name(task),
                SD_workstation_get_name(workstation));
-        xbt_fifo_push(workstation->task_fifo, task);
+        xbt_fifo_push(SD_workstation_priv(workstation)->task_fifo, task);
       }
     }
     __SD_task_set_state(task, SD_IN_FIFO);
       }
     }
     __SD_task_set_state(task, SD_IN_FIFO);
@@ -1186,23 +1186,23 @@ void __SD_task_just_done(SD_task_t task)
   for (i = 0; i < task->workstation_nb; i++) {
     workstation = task->workstation_list[i];
     XBT_DEBUG("Workstation '%s': access_mode = %d",
   for (i = 0; i < task->workstation_nb; i++) {
     workstation = task->workstation_list[i];
     XBT_DEBUG("Workstation '%s': access_mode = %d",
-              SD_workstation_get_name(workstation), (int)workstation->access_mode);
-    if (workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
-      xbt_assert(workstation->task_fifo != NULL,
+              SD_workstation_get_name(workstation), (int)SD_workstation_priv(workstation)->access_mode);
+    if (SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
+      xbt_assert(SD_workstation_priv(workstation)->task_fifo != NULL,
                   "Workstation '%s' has sequential access but no FIFO!",
                   SD_workstation_get_name(workstation));
                   "Workstation '%s' has sequential access but no FIFO!",
                   SD_workstation_get_name(workstation));
-      xbt_assert(workstation->current_task =
+      xbt_assert(SD_workstation_priv(workstation)->current_task =
                   task, "Workstation '%s': current task should be '%s'",
                   SD_workstation_get_name(workstation),
                   SD_task_get_name(task));
 
       /* the task is over so we can release the workstation */
                   task, "Workstation '%s': current task should be '%s'",
                   SD_workstation_get_name(workstation),
                   SD_task_get_name(task));
 
       /* the task is over so we can release the workstation */
-      workstation->current_task = NULL;
+      SD_workstation_priv(workstation)->current_task = NULL;
 
       XBT_DEBUG("Getting candidate in FIFO");
       candidate =
           xbt_fifo_get_item_content(xbt_fifo_get_first_item
 
       XBT_DEBUG("Getting candidate in FIFO");
       candidate =
           xbt_fifo_get_item_content(xbt_fifo_get_first_item
-                                    (workstation->task_fifo));
+                                    (SD_workstation_priv(workstation)->task_fifo));
 
       if (candidate != NULL) {
         XBT_DEBUG("Candidate: '%s'", SD_task_get_name(candidate));
 
       if (candidate != NULL) {
         XBT_DEBUG("Candidate: '%s'", SD_task_get_name(candidate));
@@ -1256,10 +1256,10 @@ void __SD_task_just_done(SD_task_t task)
 
       /* I can start on this workstation if the workstation is shared
          or if I am the first task in the FIFO */
 
       /* I can start on this workstation if the workstation is shared
          or if I am the first task in the FIFO */
-      can_start = workstation->access_mode == SD_WORKSTATION_SHARED_ACCESS
+      can_start = SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SHARED_ACCESS
           || candidate ==
           xbt_fifo_get_item_content(xbt_fifo_get_first_item
           || candidate ==
           xbt_fifo_get_item_content(xbt_fifo_get_first_item
-                                    (workstation->task_fifo));
+                                    (SD_workstation_priv(workstation)->task_fifo));
     }
 
     XBT_DEBUG("Candidate '%s' can start: %d", SD_task_get_name(candidate),
     }
 
     XBT_DEBUG("Candidate '%s' can start: %d", SD_task_get_name(candidate),
@@ -1271,8 +1271,8 @@ void __SD_task_just_done(SD_task_t task)
         workstation = candidate->workstation_list[j];
 
         /* update the FIFO */
         workstation = candidate->workstation_list[j];
 
         /* update the FIFO */
-        if (workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
-          candidate = xbt_fifo_shift(workstation->task_fifo);   /* the return value is stored just for debugging */
+        if (SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
+          candidate = xbt_fifo_shift(SD_workstation_priv(workstation)->task_fifo);   /* the return value is stored just for debugging */
           XBT_DEBUG("Head of the FIFO: '%s'",
                  (candidate !=
                   NULL) ? SD_task_get_name(candidate) : "NULL");
           XBT_DEBUG("Head of the FIFO: '%s'",
                  (candidate !=
                   NULL) ? SD_task_get_name(candidate) : "NULL");
index 1be8d28..f961c7f 100644 (file)
@@ -23,19 +23,18 @@ SD_workstation_t __SD_workstation_create(void *surf_workstation,
                                          void *data)
 {
 
                                          void *data)
 {
 
-  SD_workstation_t workstation;
+  SD_workstation_priv_t workstation;
   const char *name;
 
   const char *name;
 
-  workstation = xbt_new(s_SD_workstation_t, 1);
-  workstation->surf_workstation = surf_workstation;
+  workstation = xbt_new(s_SD_workstation_priv_t, 1);
   workstation->data = data;     /* user data */
   workstation->access_mode = SD_WORKSTATION_SHARED_ACCESS;      /* default mode is shared */
   workstation->task_fifo = NULL;
   workstation->current_task = NULL;
 
   workstation->data = data;     /* user data */
   workstation->access_mode = SD_WORKSTATION_SHARED_ACCESS;      /* default mode is shared */
   workstation->task_fifo = NULL;
   workstation->current_task = NULL;
 
-  name = SD_workstation_get_name(workstation);
+  name = surf_resource_name(surf_workstation);
   xbt_lib_set(host_lib,name,SD_HOST_LEVEL,workstation);
   xbt_lib_set(host_lib,name,SD_HOST_LEVEL,workstation);
-  return workstation;
+  return xbt_lib_get_elm_or_null(host_lib,name);
 }
 
 /**
 }
 
 /**
@@ -48,7 +47,7 @@ SD_workstation_t __SD_workstation_create(void *surf_workstation,
  */
 SD_workstation_t SD_workstation_get_by_name(const char *name)
 {
  */
 SD_workstation_t SD_workstation_get_by_name(const char *name)
 {
-  return xbt_lib_get_or_null(host_lib, name, SD_HOST_LEVEL);
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 /**
 }
 
 /**
@@ -76,7 +75,7 @@ const SD_workstation_t *SD_workstation_get_list(void)
     i = 0;
     xbt_lib_foreach(host_lib, cursor, key, data) {
       if(data[SD_HOST_LEVEL])
     i = 0;
     xbt_lib_foreach(host_lib, cursor, key, data) {
       if(data[SD_HOST_LEVEL])
-        sd_global->workstation_list[i++] = (SD_workstation_t) data[SD_HOST_LEVEL];
+        sd_global->workstation_list[i++] = xbt_dict_cursor_get_elm(cursor);
     }
   }
   return sd_global->workstation_list;
     }
   }
   return sd_global->workstation_list;
@@ -102,7 +101,7 @@ int SD_workstation_get_number(void)
  */
 void *SD_workstation_get_data(SD_workstation_t workstation)
 {
  */
 void *SD_workstation_get_data(SD_workstation_t workstation)
 {
-  return workstation->data;
+  return SD_workstation_priv(workstation)->data;
 }
 
 /**
 }
 
 /**
@@ -117,7 +116,7 @@ void *SD_workstation_get_data(SD_workstation_t workstation)
  */
 void SD_workstation_set_data(SD_workstation_t workstation, void *data)
 {
  */
 void SD_workstation_set_data(SD_workstation_t workstation, void *data)
 {
-  workstation->data = data;
+  SD_workstation_priv(workstation)->data = data;
 }
 
 /**
 }
 
 /**
@@ -128,7 +127,7 @@ void SD_workstation_set_data(SD_workstation_t workstation, void *data)
  */
 const char *SD_workstation_get_name(SD_workstation_t workstation)
 {
  */
 const char *SD_workstation_get_name(SD_workstation_t workstation)
 {
-  return surf_resource_name(workstation->surf_workstation);
+  return sg_host_name(workstation);
 }
 
 /**
 }
 
 /**
@@ -154,8 +153,7 @@ const char *SD_workstation_get_property_value(SD_workstation_t ws,
 xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation)
 {
   return surf_workstation_model->extension.
 xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation)
 {
   return surf_workstation_model->extension.
-      workstation.get_properties(workstation->surf_workstation);
-
+      workstation.get_properties(surf_workstation_resource_priv(workstation));
 }
 
 
 }
 
 
@@ -170,7 +168,7 @@ void SD_workstation_dump(SD_workstation_t ws)
   XBT_INFO("Displaying workstation %s", SD_workstation_get_name(ws));
   XBT_INFO("  - power: %.0f", SD_workstation_get_power(ws));
   XBT_INFO("  - available power: %.2f", SD_workstation_get_available_power(ws));
   XBT_INFO("Displaying workstation %s", SD_workstation_get_name(ws));
   XBT_INFO("  - power: %.0f", SD_workstation_get_power(ws));
   XBT_INFO("  - available power: %.2f", SD_workstation_get_available_power(ws));
-  switch (ws->access_mode){
+  switch (SD_workstation_priv(ws)->access_mode){
   case SD_WORKSTATION_SHARED_ACCESS:
       XBT_INFO("  - access mode: Space shared");
       break;
   case SD_WORKSTATION_SHARED_ACCESS:
       XBT_INFO("  - access mode: Space shared");
       break;
@@ -221,8 +219,8 @@ const SD_link_t *SD_route_get_list(SD_workstation_t src,
     sd_global->recyclable_route = xbt_new(SD_link_t, SD_link_get_number());
   }
 
     sd_global->recyclable_route = xbt_new(SD_link_t, SD_link_get_number());
   }
 
-  surf_src = src->surf_workstation;
-  surf_dst = dst->surf_workstation;
+  surf_src = src;
+  surf_dst = dst;
   surf_route =
       surf_workstation_model->extension.workstation.get_route(surf_src,
                                                               surf_dst);
   surf_route =
       surf_workstation_model->extension.workstation.get_route(surf_src,
                                                               surf_dst);
@@ -246,8 +244,7 @@ const SD_link_t *SD_route_get_list(SD_workstation_t src,
 int SD_route_get_size(SD_workstation_t src, SD_workstation_t dst)
 {
   return xbt_dynar_length(surf_workstation_model->extension.
 int SD_route_get_size(SD_workstation_t src, SD_workstation_t dst)
 {
   return xbt_dynar_length(surf_workstation_model->extension.
-                          workstation.get_route(src->surf_workstation,
-                                                dst->surf_workstation));
+                          workstation.get_route(src, dst));
 }
 
 /**
 }
 
 /**
@@ -260,7 +257,7 @@ int SD_route_get_size(SD_workstation_t src, SD_workstation_t dst)
 double SD_workstation_get_power(SD_workstation_t workstation)
 {
   return surf_workstation_model->extension.workstation.
 double SD_workstation_get_power(SD_workstation_t workstation)
 {
   return surf_workstation_model->extension.workstation.
-      get_speed(workstation->surf_workstation, 1.0);
+      get_speed(workstation, 1.0);
 }
 
 /**
 }
 
 /**
@@ -273,7 +270,7 @@ double SD_workstation_get_power(SD_workstation_t workstation)
 double SD_workstation_get_available_power(SD_workstation_t workstation)
 {
   return surf_workstation_model->extension.
 double SD_workstation_get_available_power(SD_workstation_t workstation)
 {
   return surf_workstation_model->extension.
-      workstation.get_available_speed(workstation->surf_workstation);
+      workstation.get_available_speed(workstation);
 }
 
 /**
 }
 
 /**
@@ -413,7 +410,7 @@ double SD_route_get_communication_time(SD_workstation_t src,
 e_SD_workstation_access_mode_t
 SD_workstation_get_access_mode(SD_workstation_t workstation)
 {
 e_SD_workstation_access_mode_t
 SD_workstation_get_access_mode(SD_workstation_t workstation)
 {
-  return workstation->access_mode;
+  return SD_workstation_priv(workstation)->access_mode;
 }
 
 /**
 }
 
 /**
@@ -439,17 +436,17 @@ void SD_workstation_set_access_mode(SD_workstation_t workstation,
              access_mode != SD_WORKSTATION_SHARED_ACCESS,
              "Trying to set an invalid access mode");
 
              access_mode != SD_WORKSTATION_SHARED_ACCESS,
              "Trying to set an invalid access mode");
 
-  if (access_mode == workstation->access_mode) {
+  if (access_mode == SD_workstation_priv(workstation)->access_mode) {
     return;                     // nothing is changed
   }
 
     return;                     // nothing is changed
   }
 
-  workstation->access_mode = access_mode;
+  SD_workstation_priv(workstation)->access_mode = access_mode;
 
   if (access_mode == SD_WORKSTATION_SHARED_ACCESS) {
 
   if (access_mode == SD_WORKSTATION_SHARED_ACCESS) {
-    xbt_fifo_free(workstation->task_fifo);
-    workstation->task_fifo = NULL;
+    xbt_fifo_free(SD_workstation_priv(workstation)->task_fifo);
+    SD_workstation_priv(workstation)->task_fifo = NULL;
   } else {
   } else {
-    workstation->task_fifo = xbt_fifo_new();
+    SD_workstation_priv(workstation)->task_fifo = xbt_fifo_new();
   }
 }
 
   }
 }
 
@@ -472,17 +469,17 @@ int __SD_workstation_is_busy(SD_workstation_t workstation)
   XBT_DEBUG
       ("Workstation '%s' access mode: '%s', current task: %s, fifo size: %d",
        SD_workstation_get_name(workstation),
   XBT_DEBUG
       ("Workstation '%s' access mode: '%s', current task: %s, fifo size: %d",
        SD_workstation_get_name(workstation),
-       (workstation->access_mode ==
+       (SD_workstation_priv(workstation)->access_mode ==
         SD_WORKSTATION_SHARED_ACCESS) ? "SHARED" : "FIFO",
         SD_WORKSTATION_SHARED_ACCESS) ? "SHARED" : "FIFO",
-       (workstation->current_task ?
-        SD_task_get_name(workstation->current_task)
+       (SD_workstation_priv(workstation)->current_task ?
+        SD_task_get_name(SD_workstation_priv(workstation)->current_task)
         : "none"),
         : "none"),
-       (workstation->task_fifo ? xbt_fifo_size(workstation->task_fifo) :
+       (SD_workstation_priv(workstation)->task_fifo ? xbt_fifo_size(SD_workstation_priv(workstation)->task_fifo) :
         0));
 
         0));
 
-  return workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS &&
-      (workstation->current_task != NULL
-       || xbt_fifo_size(workstation->task_fifo) > 0);
+  return SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS &&
+      (SD_workstation_priv(workstation)->current_task != NULL
+       || xbt_fifo_size(SD_workstation_priv(workstation)->task_fifo) > 0);
 }
 
 /* Destroys a workstation.
 }
 
 /* Destroys a workstation.
@@ -490,11 +487,11 @@ int __SD_workstation_is_busy(SD_workstation_t workstation)
 void __SD_workstation_destroy(void *workstation)
 {
 
 void __SD_workstation_destroy(void *workstation)
 {
 
-  SD_workstation_t w;
+  SD_workstation_priv_t w;
 
   /* workstation->surf_workstation is freed by surf_exit and workstation->data is freed by the user */
 
 
   /* workstation->surf_workstation is freed by surf_exit and workstation->data is freed by the user */
 
-  w = (SD_workstation_t) workstation;
+  w = (SD_workstation_priv_t) workstation;
 
   if (w->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
     xbt_fifo_free(w->task_fifo);
 
   if (w->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
     xbt_fifo_free(w->task_fifo);
@@ -508,11 +505,11 @@ void __SD_workstation_destroy(void *workstation)
  * \param workstation a workstation */
 SD_task_t SD_workstation_get_current_task(SD_workstation_t workstation)
 {
  * \param workstation a workstation */
 SD_task_t SD_workstation_get_current_task(SD_workstation_t workstation)
 {
-  xbt_assert(workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS,
+  xbt_assert(SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS,
               "Access mode must be set to SD_WORKSTATION_SEQUENTIAL_ACCESS"
               " to use this function");
 
               "Access mode must be set to SD_WORKSTATION_SEQUENTIAL_ACCESS"
               " to use this function");
 
-  return (workstation->current_task);
+  return (SD_workstation_priv(workstation)->current_task);
 }
 
 /**
 }
 
 /**
index 766658e..07f130d 100644 (file)
@@ -41,7 +41,7 @@ static void parse_process(sg_platf_process_cbarg_t process)
     arg->name = (char*)(process->argv)[0];
     arg->code = parse_code;
     arg->data = NULL;
     arg->name = (char*)(process->argv)[0];
     arg->code = parse_code;
     arg->data = NULL;
-    arg->hostname = host->name;
+    arg->hostname = sg_host_name(host);
     arg->argc = process->argc;
     arg->argv = (char**)(process->argv);
     arg->kill_time = kill_time;
     arg->argc = process->argc;
     arg->argv = (char**)(process->argv);
     arg->kill_time = kill_time;
@@ -51,21 +51,21 @@ static void parse_process(sg_platf_process_cbarg_t process)
            arg->hostname, start_time);
     SIMIX_timer_set(start_time, &SIMIX_process_create_from_wrapper, arg);
   } else {                      // start_time <= SIMIX_get_clock()
            arg->hostname, start_time);
     SIMIX_timer_set(start_time, &SIMIX_process_create_from_wrapper, arg);
   } else {                      // start_time <= SIMIX_get_clock()
-    XBT_DEBUG("Starting Process %s(%s) right now", process->argv[0], host->name);
+    XBT_DEBUG("Starting Process %s(%s) right now", process->argv[0], sg_host_name(host));
 
     if (simix_global->create_process_function)
       simix_global->create_process_function(&process_created,
                                             (char*)(process->argv)[0],
                                             parse_code,
                                             NULL,
 
     if (simix_global->create_process_function)
       simix_global->create_process_function(&process_created,
                                             (char*)(process->argv)[0],
                                             parse_code,
                                             NULL,
-                                            host->name,
+                                            sg_host_name(host),
                                             kill_time,
                                             process->argc,
                                             (char**)(process->argv),
                                             current_property_set,
                                             auto_restart);
     else
                                             kill_time,
                                             process->argc,
                                             (char**)(process->argv),
                                             current_property_set,
                                             auto_restart);
     else
-      simcall_process_create(&process_created, (char*)(process->argv)[0], parse_code, NULL, host->name, kill_time, process->argc,
+      simcall_process_create(&process_created, (char*)(process->argv)[0], parse_code, NULL, sg_host_name(host), kill_time, process->argc,
           (char**)process->argv, current_property_set,auto_restart);
 
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
           (char**)process->argv, current_property_set,auto_restart);
 
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
@@ -184,7 +184,7 @@ void SIMIX_process_set_function(const char *process_host,
   smx_host_t host = SIMIX_host_get_by_name(process_host);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process_host);
   smx_host_t host = SIMIX_host_get_by_name(process_host);
   if (!host)
     THROWF(arg_error, 0, "Host '%s' unknown", process_host);
-  process.host = host->name;
+  process.host = sg_host_name(host);
 
   process.argc = 1 + xbt_dynar_length(arguments);
   process.argv = (const char**)xbt_new(char *, process.argc + 1);
 
   process.argc = 1 + xbt_dynar_length(arguments);
   process.argv = (const char**)xbt_new(char *, process.argc + 1);
index 3d72dd4..6c0623c 100644 (file)
@@ -457,12 +457,12 @@ void SIMIX_display_process_status(void)
         break;
       }
       XBT_INFO("Process %lu (%s@%s): waiting for %s action %p (%s) in state %d to finish",
         break;
       }
       XBT_INFO("Process %lu (%s@%s): waiting for %s action %p (%s) in state %d to finish",
-          process->pid, process->name, process->smx_host->name,
+          process->pid, process->name, sg_host_name(process->smx_host),
           action_description, process->waiting_action,
           process->waiting_action->name, (int)process->waiting_action->state);
     }
     else {
           action_description, process->waiting_action,
           process->waiting_action->name, (int)process->waiting_action->state);
     }
     else {
-      XBT_INFO("Process %lu (%s@%s)", process->pid, process->name, process->smx_host->name);
+      XBT_INFO("Process %lu (%s@%s)", process->pid, process->name, sg_host_name(process->smx_host));
     }
   }
 }
     }
   }
 }
index f0b1e0d..114e14b 100644 (file)
@@ -24,20 +24,18 @@ static void SIMIX_execution_finish(smx_action_t action);
 smx_host_t SIMIX_host_create(const char *name,
                                void *workstation, void *data)
 {
 smx_host_t SIMIX_host_create(const char *name,
                                void *workstation, void *data)
 {
-  smx_host_t smx_host = xbt_new0(s_smx_host_t, 1);
+  smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
   s_smx_process_t proc;
 
   /* Host structure */
   s_smx_process_t proc;
 
   /* Host structure */
-  smx_host->name = xbt_strdup(name);
   smx_host->data = data;
   smx_host->data = data;
-  smx_host->host = workstation;
   smx_host->process_list =
       xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
 
   /* Update global variables */
   smx_host->process_list =
       xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
 
   /* Update global variables */
-  xbt_lib_set(host_lib,smx_host->name,SIMIX_HOST_LEVEL,smx_host);
-
-  return smx_host;
+  xbt_lib_set(host_lib,name,SIMIX_HOST_LEVEL,smx_host);
+  
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 /**
 }
 
 /**
@@ -47,14 +45,14 @@ smx_host_t SIMIX_host_create(const char *name,
  */
 void SIMIX_host_destroy(void *h)
 {
  */
 void SIMIX_host_destroy(void *h)
 {
-  smx_host_t host = (smx_host_t) h;
+  smx_host_priv_t host = (smx_host_priv_t) h;
 
   xbt_assert((host != NULL), "Invalid parameters");
 
   /* Clean Simulator data */
   if (xbt_swag_size(host->process_list) != 0) {
     char *msg =
 
   xbt_assert((host != NULL), "Invalid parameters");
 
   /* Clean Simulator data */
   if (xbt_swag_size(host->process_list) != 0) {
     char *msg =
-        bprintf("Shutting down host %s, but it's not empty:", host->name);
+        bprintf("Shutting down host, but it's not empty:");
     char *tmp;
     smx_process_t process = NULL;
 
     char *tmp;
     smx_process_t process = NULL;
 
@@ -70,9 +68,7 @@ void SIMIX_host_destroy(void *h)
   xbt_swag_free(host->process_list);
 
   /* Clean host structure */
   xbt_swag_free(host->process_list);
 
   /* Clean host structure */
-  free(host->name);
-  free(host);
-
+  free(host); 
   return;
 }
 
   return;
 }
 
@@ -102,7 +98,7 @@ smx_host_t SIMIX_host_get_by_name(const char *name){
                && (host_lib != NULL)),
               "Environment not set yet");
 
                && (host_lib != NULL)),
               "Environment not set yet");
 
-  return xbt_lib_get_or_null(host_lib, name, SIMIX_HOST_LEVEL);
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 smx_host_t SIMIX_host_self(void)
 }
 
 smx_host_t SIMIX_host_self(void)
@@ -131,7 +127,7 @@ const char* SIMIX_pre_host_get_name(smx_simcall_t simcall, smx_host_t host){
 const char* SIMIX_host_get_name(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters");
 
 const char* SIMIX_host_get_name(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters");
 
-  return host->name;
+  return sg_host_name(host);
 }
 
 xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t simcall, smx_host_t host){
 }
 
 xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t simcall, smx_host_t host){
@@ -140,7 +136,7 @@ xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t simcall, smx_host_t host)
 xbt_dict_t SIMIX_host_get_properties(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
 xbt_dict_t SIMIX_host_get_properties(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
-  return surf_workstation_model->extension.workstation.get_properties(host->host);
+  return surf_workstation_model->extension.workstation.get_properties(host);
 }
 
 double SIMIX_pre_host_get_speed(smx_simcall_t simcall, smx_host_t host){
 }
 
 double SIMIX_pre_host_get_speed(smx_simcall_t simcall, smx_host_t host){
@@ -150,7 +146,7 @@ double SIMIX_host_get_speed(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
-      get_speed(host->host, 1.0);
+      get_speed(host, 1.0);
 }
 
 double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){
 }
 
 double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){
@@ -160,7 +156,7 @@ double SIMIX_host_get_available_speed(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
-      get_available_speed(host->host);
+      get_available_speed(host);
 }
 
 int SIMIX_pre_host_get_state(smx_simcall_t simcall, smx_host_t host){
 }
 
 int SIMIX_pre_host_get_state(smx_simcall_t simcall, smx_host_t host){
@@ -170,7 +166,7 @@ int SIMIX_host_get_state(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
-      get_state(host->host);
+      get_state(host);
 }
 
 void* SIMIX_pre_host_self_get_data(smx_simcall_t simcall){
 }
 
 void* SIMIX_pre_host_self_get_data(smx_simcall_t simcall){
@@ -194,7 +190,7 @@ void* SIMIX_pre_host_get_data(smx_simcall_t simcall,smx_host_t host){
 void* SIMIX_host_get_data(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
 void* SIMIX_host_get_data(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
-  return host->data;
+  return SIMIX_host_priv(host)->data;
 }
 void _SIMIX_host_free_process_arg(void *);
 void _SIMIX_host_free_process_arg(void *data)
 }
 void _SIMIX_host_free_process_arg(void *);
 void _SIMIX_host_free_process_arg(void *data)
@@ -220,8 +216,8 @@ void SIMIX_host_add_auto_restart_process(smx_host_t host,
                                          xbt_dict_t properties,
                                          int auto_restart)
 {
                                          xbt_dict_t properties,
                                          int auto_restart)
 {
-  if (!host->auto_restart_processes) {
-    host->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg);
+  if (!SIMIX_host_priv(host)->auto_restart_processes) {
+    SIMIX_host_priv(host)->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg);
   }
   smx_process_arg_t arg = xbt_new(s_smx_process_arg_t,1);
   arg->name = xbt_strdup(name);
   }
   smx_process_arg_t arg = xbt_new(s_smx_process_arg_t,1);
   arg->name = xbt_strdup(name);
@@ -243,11 +239,11 @@ void SIMIX_host_add_auto_restart_process(smx_host_t host,
   arg->auto_restart = auto_restart;
 
   if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF
   arg->auto_restart = auto_restart;
 
   if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF
-      && !xbt_dict_get_or_null(watched_hosts_lib,host->name)){
-    xbt_dict_set(watched_hosts_lib,host->name,host,NULL);
-    XBT_DEBUG("Have push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",host->name);
+      && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_name(host))){
+    xbt_dict_set(watched_hosts_lib,sg_host_name(host),host,NULL);
+    XBT_DEBUG("Have push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_name(host));
   }
   }
-  xbt_dynar_push_as(host->auto_restart_processes,smx_process_arg_t,arg);
+  xbt_dynar_push_as(SIMIX_host_priv(host)->auto_restart_processes,smx_process_arg_t,arg);
 }
 /**
  * \brief Restart the list of processes that have been registered to the host
 }
 /**
  * \brief Restart the list of processes that have been registered to the host
@@ -256,7 +252,7 @@ void SIMIX_host_restart_processes(smx_host_t host)
 {
   unsigned int cpt;
   smx_process_arg_t arg;
 {
   unsigned int cpt;
   smx_process_arg_t arg;
-  xbt_dynar_foreach(host->auto_restart_processes,cpt,arg) {
+  xbt_dynar_foreach(SIMIX_host_priv(host)->auto_restart_processes,cpt,arg) {
 
     smx_process_t process;
 
 
     smx_process_t process;
 
@@ -287,7 +283,7 @@ void SIMIX_host_restart_processes(smx_host_t host)
 
     }
   }
 
     }
   }
-  xbt_dynar_reset(host->auto_restart_processes);
+  xbt_dynar_reset(SIMIX_host_priv(host)->auto_restart_processes);
 }
 
 void SIMIX_host_autorestart(smx_host_t host)
 }
 
 void SIMIX_host_autorestart(smx_host_t host)
@@ -303,9 +299,9 @@ void SIMIX_pre_host_set_data(smx_simcall_t simcall, smx_host_t host, void *data)
 }
 void SIMIX_host_set_data(smx_host_t host, void *data){
   xbt_assert((host != NULL), "Invalid parameters");
 }
 void SIMIX_host_set_data(smx_host_t host, void *data){
   xbt_assert((host != NULL), "Invalid parameters");
-  xbt_assert((host->data == NULL), "Data already set");
+  xbt_assert((SIMIX_host_priv(host)->data == NULL), "Data already set");
 
 
-  host->data = data;
+  SIMIX_host_priv(host)->data = data;
 }
 
 smx_action_t SIMIX_pre_host_execute(smx_simcall_t simcall,const char *name,
 }
 
 smx_action_t SIMIX_pre_host_execute(smx_simcall_t simcall,const char *name,
@@ -329,7 +325,7 @@ smx_action_t SIMIX_host_execute(const char *name,
   /* set surf's action */
   if (!MC_is_active()) {
     action->execution.surf_exec =
   /* set surf's action */
   if (!MC_is_active()) {
     action->execution.surf_exec =
-      surf_workstation_model->extension.workstation.execute(host->host,
+      surf_workstation_model->extension.workstation.execute(host,
     computation_amount);
     surf_workstation_model->action_data_set(action->execution.surf_exec, action);
     surf_workstation_model->set_priority(action->execution.surf_exec, priority);
     computation_amount);
     surf_workstation_model->action_data_set(action->execution.surf_exec, action);
     surf_workstation_model->set_priority(action->execution.surf_exec, priority);
@@ -369,7 +365,7 @@ smx_action_t SIMIX_host_parallel_execute(const char *name,
   /* set surf's action */
   workstation_list = xbt_new0(void *, host_nb);
   for (i = 0; i < host_nb; i++)
   /* set surf's action */
   workstation_list = xbt_new0(void *, host_nb);
   for (i = 0; i < host_nb; i++)
-    workstation_list[i] = host_list[i]->host;
+    workstation_list[i] = host_list[i];
 
   /* set surf's action */
   if (!MC_is_active()) {
 
   /* set surf's action */
   if (!MC_is_active()) {
@@ -484,7 +480,7 @@ void SIMIX_execution_finish(smx_action_t action)
         break;
 
       case SIMIX_FAILED:
         break;
 
       case SIMIX_FAILED:
-        XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", simcall->issuer->smx_host->name);
+        XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", sg_host_name(simcall->issuer->smx_host));
         simcall->issuer->context->iwannadie = 1;
         //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
         break;
         simcall->issuer->context->iwannadie = 1;
         //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
         break;
@@ -500,7 +496,7 @@ void SIMIX_execution_finish(smx_action_t action)
     }
     /* check if the host is down */
     if (surf_workstation_model->extension.
     }
     /* check if the host is down */
     if (surf_workstation_model->extension.
-        workstation.get_state(simcall->issuer->smx_host->host) != SURF_RESOURCE_ON) {
+        workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
       simcall->issuer->context->iwannadie = 1;
     }
 
@@ -517,7 +513,7 @@ void SIMIX_post_host_execute(smx_action_t action)
 {
   if (action->type == SIMIX_ACTION_EXECUTE && /* FIMXE: handle resource failure
                                                * for parallel tasks too */
 {
   if (action->type == SIMIX_ACTION_EXECUTE && /* FIMXE: handle resource failure
                                                * for parallel tasks too */
-      surf_workstation_model->extension.workstation.get_state(action->execution.host->host) == SURF_RESOURCE_OFF) {
+      surf_workstation_model->extension.workstation.get_state(action->execution.host) == SURF_RESOURCE_OFF) {
     /* If the host running the action failed, notice it so that the asking
      * process can be killed if it runs on that host itself */
     action->state = SIMIX_FAILED;
     /* If the host running the action failed, notice it so that the asking
      * process can be killed if it runs on that host itself */
     action->state = SIMIX_FAILED;
index 6819f61..6b03c17 100644 (file)
 #include "smx_smurf_private.h"
 
 /** @brief Host datatype */
 #include "smx_smurf_private.h"
 
 /** @brief Host datatype */
-typedef struct s_smx_host {
-  char *name;              /**< @brief host name if any */
-  void *host;                   /* SURF modeling */
+typedef struct s_smx_host_priv {
   xbt_swag_t process_list;
   xbt_dynar_t auto_restart_processes;
   void *data;              /**< @brief user data */
   xbt_swag_t process_list;
   xbt_dynar_t auto_restart_processes;
   void *data;              /**< @brief user data */
-} s_smx_host_t;
+} s_smx_host_priv_t;
+
+static inline smx_host_priv_t SIMIX_host_priv(smx_host_t host){
+  return xbt_lib_get_level(host, SIMIX_HOST_LEVEL);
+}
+
 
 smx_host_t SIMIX_host_create(const char *name, void *workstation, void *data);
 void SIMIX_host_destroy(void *host);
 
 smx_host_t SIMIX_host_create(const char *name, void *workstation, void *data);
 void SIMIX_host_destroy(void *host);
index 383510b..f261620 100644 (file)
@@ -30,9 +30,9 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -43,7 +43,7 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, ptr, size, nmemb, stream->surf_file);
+  action->io.surf_io = surf_workstation_model->extension.workstation.read(host, ptr, size, nmemb, stream->surf_file);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -67,9 +67,9 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -80,7 +80,7 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, ptr, size, nmemb, stream->surf_file);
+  action->io.surf_io = surf_workstation_model->extension.workstation.write(host, ptr, size, nmemb, stream->surf_file);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -104,9 +104,9 @@ smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const cha
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -117,7 +117,7 @@ smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const cha
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, mount, path, mode);
+  action->io.surf_io = surf_workstation_model->extension.workstation.open(host, mount, path, mode);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -140,9 +140,9 @@ smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp)
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -153,7 +153,7 @@ smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp)
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, fp->surf_file);
+  action->io.surf_io = surf_workstation_model->extension.workstation.close(host, fp->surf_file);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -175,9 +175,9 @@ smx_action_t SIMIX_file_stat(smx_process_t process, smx_file_t fd, s_file_stat_t
   smx_host_t host = process->smx_host;
   /* check if the host is active */
   if (surf_workstation_model->extension.
   smx_host_t host = process->smx_host;
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -188,7 +188,7 @@ smx_action_t SIMIX_file_stat(smx_process_t process, smx_file_t fd, s_file_stat_t
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, fd->surf_file);
+  action->io.surf_io = surf_workstation_model->extension.workstation.stat(host, fd->surf_file);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -210,9 +210,9 @@ smx_action_t SIMIX_file_unlink(smx_process_t process, smx_file_t fd)
   smx_host_t host = process->smx_host;
   /* check if the host is active */
   if (surf_workstation_model->extension.
   smx_host_t host = process->smx_host;
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -223,7 +223,7 @@ smx_action_t SIMIX_file_unlink(smx_process_t process, smx_file_t fd)
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.unlink(host->host, fd->surf_file);
+  action->io.surf_io = surf_workstation_model->extension.workstation.unlink(host, fd->surf_file);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -244,9 +244,9 @@ smx_action_t SIMIX_file_ls(smx_process_t process, const char* mount, const char
   smx_action_t action;
   smx_host_t host = process->smx_host;
   /* check if the host is active */
   smx_action_t action;
   smx_host_t host = process->smx_host;
   /* check if the host is active */
-  if (surf_workstation_model->extension.workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+  if (surf_workstation_model->extension.workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -257,7 +257,7 @@ smx_action_t SIMIX_file_ls(smx_process_t process, const char* mount, const char
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.ls(host->host,mount,path);
+  action->io.surf_io = surf_workstation_model->extension.workstation.ls(host,mount,path);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
@@ -387,7 +387,7 @@ void SIMIX_io_finish(smx_action_t action)
     }
 
     if (surf_workstation_model->extension.
     }
 
     if (surf_workstation_model->extension.
-        workstation.get_state(simcall->issuer->smx_host->host) != SURF_RESOURCE_ON) {
+        workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
       simcall->issuer->context->iwannadie = 1;
     }
 
index 23600af..48c05f3 100644 (file)
@@ -619,7 +619,7 @@ void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double time
   if (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING) {
     SIMIX_comm_finish(action);
   } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */
   if (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING) {
     SIMIX_comm_finish(action);
   } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */
-    sleep = surf_workstation_model->extension.workstation.sleep(simcall->issuer->smx_host->host, timeout);
+    sleep = surf_workstation_model->extension.workstation.sleep(simcall->issuer->smx_host, timeout);
     surf_workstation_model->action_data_set(sleep, action);
 
     if (simcall->issuer == action->comm.src_proc)
     surf_workstation_model->action_data_set(sleep, action);
 
     if (simcall->issuer == action->comm.src_proc)
@@ -737,7 +737,7 @@ XBT_INLINE void SIMIX_comm_start(smx_action_t action)
               SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver));
 
     action->comm.surf_comm = surf_workstation_model->extension.workstation.
               SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver));
 
     action->comm.surf_comm = surf_workstation_model->extension.workstation.
-      communicate(sender->host, receiver->host, action->comm.task_size, action->comm.rate);
+      communicate(sender, receiver, action->comm.task_size, action->comm.rate);
 
     surf_workstation_model->action_data_set(action->comm.surf_comm, action);
 
 
     surf_workstation_model->action_data_set(action->comm.surf_comm, action);
 
@@ -834,8 +834,8 @@ void SIMIX_comm_finish(smx_action_t action)
     case SIMIX_LINK_FAILURE:
       XBT_DEBUG("Link failure in action %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d",
                 action,
     case SIMIX_LINK_FAILURE:
       XBT_DEBUG("Link failure in action %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d",
                 action,
-                action->comm.src_proc ? action->comm.src_proc->smx_host->name : NULL,
-                action->comm.dst_proc ? action->comm.dst_proc->smx_host->name : NULL,
+                action->comm.src_proc ? sg_host_name(action->comm.src_proc->smx_host) : NULL,
+                action->comm.dst_proc ? sg_host_name(action->comm.dst_proc->smx_host) : NULL,
                 simcall->issuer->name, simcall->issuer, action->comm.detached);
       if (action->comm.src_proc == simcall->issuer) {
         XBT_DEBUG("I'm source");
                 simcall->issuer->name, simcall->issuer, action->comm.detached);
       if (action->comm.src_proc == simcall->issuer) {
         XBT_DEBUG("I'm source");
@@ -871,7 +871,7 @@ void SIMIX_comm_finish(smx_action_t action)
     }
 
     if (surf_workstation_model->extension.
     }
 
     if (surf_workstation_model->extension.
-        workstation.get_state(simcall->issuer->smx_host->host) != SURF_RESOURCE_ON) {
+        workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
       simcall->issuer->context->iwannadie = 1;
     }
 
@@ -1124,9 +1124,9 @@ void SIMIX_comm_copy_data(smx_action_t comm)
 
   XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)",
             comm,
 
   XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)",
             comm,
-            comm->comm.src_proc ? comm->comm.src_proc->smx_host->name : "a finished process",
+            comm->comm.src_proc ? sg_host_name(comm->comm.src_proc->smx_host) : "a finished process",
             comm->comm.src_buff,
             comm->comm.src_buff,
-            comm->comm.dst_proc ? comm->comm.dst_proc->smx_host->name : "a finished process",
+            comm->comm.dst_proc ? sg_host_name(comm->comm.dst_proc->smx_host) : "a finished process",
             comm->comm.dst_buff, buff_size);
 
   /* Copy at most dst_buff_size bytes of the message to receiver's buffer */
             comm->comm.dst_buff, buff_size);
 
   /* Copy at most dst_buff_size bytes of the message to receiver's buffer */
index 7c5498d..acafb0e 100644 (file)
@@ -68,9 +68,9 @@ smx_action_t SIMIX_new_api_fct(smx_process_t process, const char* param1, double
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -124,7 +124,7 @@ void SIMIX_new_api_finish(smx_action_t action)
     }
 
     if (surf_workstation_model->extension.
     }
 
     if (surf_workstation_model->extension.
-        workstation.get_state(simcall->issuer->smx_host->host) != SURF_RESOURCE_ON) {
+        workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
       simcall->issuer->context->iwannadie = 1;
     }
 
index 434f87a..6172807 100644 (file)
@@ -97,7 +97,7 @@ void SIMIX_process_cleanup(smx_process_t process)
 
   /*xbt_swag_remove(process, simix_global->process_to_run);*/
   xbt_swag_remove(process, simix_global->process_list);
 
   /*xbt_swag_remove(process, simix_global->process_to_run);*/
   xbt_swag_remove(process, simix_global->process_list);
-  xbt_swag_remove(process, process->smx_host->process_list);
+  xbt_swag_remove(process, SIMIX_host_priv(process->smx_host)->process_list);
   xbt_swag_insert(process, simix_global->process_to_destroy);
   process->context->iwannadie = 0;
 }
   xbt_swag_insert(process, simix_global->process_to_destroy);
   process->context->iwannadie = 0;
 }
@@ -162,12 +162,12 @@ void SIMIX_process_stop(smx_process_t arg) {
    */
   if (arg->auto_restart && !SIMIX_host_get_state(arg->smx_host)) {
     SIMIX_host_add_auto_restart_process(arg->smx_host,arg->name,arg->code, arg->data,
    */
   if (arg->auto_restart && !SIMIX_host_get_state(arg->smx_host)) {
     SIMIX_host_add_auto_restart_process(arg->smx_host,arg->name,arg->code, arg->data,
-                                        arg->smx_host->name,
+                                        sg_host_name(arg->smx_host),
                                         arg->kill_time,
                                         arg->argc,arg->argv,arg->properties,
                                         arg->auto_restart);
   }
                                         arg->kill_time,
                                         arg->argc,arg->argv,arg->properties,
                                         arg->auto_restart);
   }
-  XBT_DEBUG("Process %s (%s) is dead",arg->name,arg->smx_host->name);
+  XBT_DEBUG("Process %s (%s) is dead",arg->name,sg_host_name(arg->smx_host));
   /* stop the context */
   SIMIX_context_stop(arg->context);
 }
   /* stop the context */
   SIMIX_context_stop(arg->context);
 }
@@ -268,20 +268,20 @@ void SIMIX_process_create(smx_process_t *process,
     (*process)->properties = properties;
 
     /* Add the process to it's host process list */
     (*process)->properties = properties;
 
     /* Add the process to it's host process list */
-    xbt_swag_insert(*process, host->process_list);
+    xbt_swag_insert(*process, SIMIX_host_priv(host)->process_list);
 
     XBT_DEBUG("Start context '%s'", (*process)->name);
 
     /* Now insert it in the global process list and in the process to run list */
     xbt_swag_insert(*process, simix_global->process_list);
 
     XBT_DEBUG("Start context '%s'", (*process)->name);
 
     /* Now insert it in the global process list and in the process to run list */
     xbt_swag_insert(*process, simix_global->process_list);
-    XBT_DEBUG("Inserting %s(%s) in the to_run list", (*process)->name, host->name);
+    XBT_DEBUG("Inserting %s(%s) in the to_run list", (*process)->name, sg_host_name(host));
     xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process);
   }
 
   if (kill_time > SIMIX_get_clock()) {
     if (simix_global->kill_process_function) {
       XBT_DEBUG("Process %s(%s) will be kill at time %f", (*process)->name,
     xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process);
   }
 
   if (kill_time > SIMIX_get_clock()) {
     if (simix_global->kill_process_function) {
       XBT_DEBUG("Process %s(%s) will be kill at time %f", (*process)->name,
-          (*process)->smx_host->name, kill_time);
+          sg_host_name((*process)->smx_host), kill_time);
       SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process);
     }
   }
       SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process);
     }
   }
@@ -320,7 +320,7 @@ void SIMIX_pre_process_kill(smx_simcall_t simcall, smx_process_t process) {
  */
 void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
 
  */
 void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
 
-  XBT_DEBUG("Killing process %s on %s", process->name, process->smx_host->name);
+  XBT_DEBUG("Killing process %s on %s", process->name, sg_host_name(process->smx_host));
 
   process->context->iwannadie = 1;
   process->blocked = 0;
 
   process->context->iwannadie = 1;
   process->blocked = 0;
@@ -401,9 +401,9 @@ void SIMIX_process_change_host(smx_process_t process,
              smx_host_t dest)
 {
   xbt_assert((process != NULL), "Invalid parameters");
              smx_host_t dest)
 {
   xbt_assert((process != NULL), "Invalid parameters");
-  xbt_swag_remove(process, process->smx_host->process_list);
+  xbt_swag_remove(process, SIMIX_host_priv(process->smx_host)->process_list);
   process->smx_host = dest;
   process->smx_host = dest;
-  xbt_swag_insert(process, dest->process_list);
+  xbt_swag_insert(process, SIMIX_host_priv(dest)->process_list);
 }
 
 
 }
 
 
@@ -651,9 +651,9 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
 
   /* check if the host is active */
   if (surf_workstation_model->extension.
-      workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+      workstation.get_state(host) != SURF_RESOURCE_ON) {
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
     THROWF(host_error, 0, "Host %s failed, you cannot call this function",
-           host->name);
+           sg_host_name(host));
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
   }
 
   action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -665,7 +665,7 @@ smx_action_t SIMIX_process_sleep(smx_process_t process, double duration)
 
   action->sleep.host = host;
   action->sleep.surf_sleep =
 
   action->sleep.host = host;
   action->sleep.surf_sleep =
-      surf_workstation_model->extension.workstation.sleep(host->host, duration);
+      surf_workstation_model->extension.workstation.sleep(host, duration);
 
   surf_workstation_model->action_data_set(action->sleep.surf_sleep, action);
   XBT_DEBUG("Create sleep action %p", action);
 
   surf_workstation_model->action_data_set(action->sleep.surf_sleep, action);
   XBT_DEBUG("Create sleep action %p", action);
@@ -695,7 +695,7 @@ void SIMIX_post_process_sleep(smx_action_t action)
         break;
     }
     if (surf_workstation_model->extension.
         break;
     }
     if (surf_workstation_model->extension.
-        workstation.get_state(simcall->issuer->smx_host->host) != SURF_RESOURCE_ON) {
+        workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
     simcall_process_sleep__set__result(simcall, state);
       simcall->issuer->context->iwannadie = 1;
     }
     simcall_process_sleep__set__result(simcall, state);
@@ -867,12 +867,12 @@ smx_process_t SIMIX_pre_process_restart(smx_simcall_t simcall, smx_process_t pro
  * Restart a process, starting it again from the beginning.
  */
 smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) {
  * Restart a process, starting it again from the beginning.
  */
 smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer) {
-  XBT_DEBUG("Restarting process %s on %s", process->name, process->smx_host->name);
+  XBT_DEBUG("Restarting process %s on %s", process->name, sg_host_name(process->smx_host));
   //retrieve the arguments of the old process
   //FIXME: Factorise this with SIMIX_host_add_auto_restart_process ?
   s_smx_process_arg_t arg;
   arg.code = process->code;
   //retrieve the arguments of the old process
   //FIXME: Factorise this with SIMIX_host_add_auto_restart_process ?
   s_smx_process_arg_t arg;
   arg.code = process->code;
-  arg.hostname = process->smx_host->name;
+  arg.hostname = sg_host_name(process->smx_host);
   arg.kill_time = process->kill_time;
   arg.argc = process->argc;
   arg.data = process->data;
   arg.kill_time = process->kill_time;
   arg.argc = process->argc;
   arg.data = process->data;
index 1237446..414b927 100644 (file)
@@ -28,7 +28,7 @@ static smx_action_t SIMIX_synchro_wait(smx_host_t smx_host, double timeout)
   action->type = SIMIX_ACTION_SYNCHRO;
   action->name = xbt_strdup("synchro");
   action->synchro.sleep = 
   action->type = SIMIX_ACTION_SYNCHRO;
   action->name = xbt_strdup("synchro");
   action->synchro.sleep = 
-    surf_workstation_model->extension.workstation.sleep(smx_host->host, timeout);
+    surf_workstation_model->extension.workstation.sleep(smx_host, timeout);
 
   surf_workstation_model->action_data_set(action->synchro.sleep, action);
   XBT_OUT();
 
   surf_workstation_model->action_data_set(action->synchro.sleep, action);
   XBT_OUT();
index cf5caa2..15fca99 100644 (file)
@@ -440,7 +440,7 @@ void simcall_process_set_kill_time(smx_process_t process, double kill_time)
   if (kill_time > SIMIX_get_clock()) {
     if (simix_global->kill_process_function) {
       XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
   if (kill_time > SIMIX_get_clock()) {
     if (simix_global->kill_process_function) {
       XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
-          process->smx_host->name);
+          sg_host_name(process->smx_host));
       SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
     }
   }
       SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
     }
   }
index 79bbc86..b492ee1 100644 (file)
@@ -37,8 +37,6 @@ typedef struct cpu_Cas01 {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
                                 "Logging specific to the SURF CPU IMPROVED module");
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
                                 "Logging specific to the SURF CPU IMPROVED module");
 
-
-
 static xbt_swag_t
     cpu_running_action_set_that_does_not_need_being_checked = NULL;
 
 static xbt_swag_t
     cpu_running_action_set_that_does_not_need_being_checked = NULL;
 
@@ -54,7 +52,7 @@ static void *cpu_create_resource(const char *name, double power_peak,
 {
   cpu_Cas01_t cpu = NULL;
 
 {
   cpu_Cas01_t cpu = NULL;
 
-  xbt_assert(!surf_cpu_resource_by_name(name),
+  xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
              "Host '%s' declared several times in the platform file",
              name);
   cpu = (cpu_Cas01_t) surf_resource_new(sizeof(s_cpu_Cas01_t),
              "Host '%s' declared several times in the platform file",
              name);
   cpu = (cpu_Cas01_t) surf_resource_new(sizeof(s_cpu_Cas01_t),
@@ -81,7 +79,7 @@ static void *cpu_create_resource(const char *name, double power_peak,
 
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
 
 
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
 
-  return cpu;
+  return xbt_lib_get_elm_or_null(host_lib, name);;
 }
 
 
 }
 
 
@@ -229,7 +227,7 @@ static void cpu_update_resource_state(void *id,
 static surf_action_t cpu_execute(void *cpu, double size)
 {
   surf_action_cpu_Cas01_t action = NULL;
 static surf_action_t cpu_execute(void *cpu, double size)
 {
   surf_action_cpu_Cas01_t action = NULL;
-  cpu_Cas01_t CPU = cpu;
+  cpu_Cas01_t CPU = surf_cpu_resource_priv(cpu);
 
   XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
   action =
 
   XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
   action =
@@ -262,7 +260,7 @@ static surf_action_t cpu_action_sleep(void *cpu, double duration)
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
-  XBT_IN("(%s,%g)", surf_resource_name(cpu), duration);
+  XBT_IN("(%s,%g)", surf_resource_name(surf_cpu_resource_priv(cpu)), duration);
   action = (surf_action_cpu_Cas01_t) cpu_execute(cpu, 1.0);
   // FIXME: sleep variables should not consume 1.0 in lmm_expand
   GENERIC_ACTION(action).max_duration = duration;
   action = (surf_action_cpu_Cas01_t) cpu_execute(cpu, 1.0);
   // FIXME: sleep variables should not consume 1.0 in lmm_expand
   GENERIC_ACTION(action).max_duration = duration;
@@ -292,18 +290,18 @@ static surf_action_t cpu_action_sleep(void *cpu, double duration)
 
 static e_surf_resource_state_t cpu_get_state(void *cpu)
 {
 
 static e_surf_resource_state_t cpu_get_state(void *cpu)
 {
-  return ((cpu_Cas01_t) cpu)->state_current;
+  return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->state_current;
 }
 
 static double cpu_get_speed(void *cpu, double load)
 {
 }
 
 static double cpu_get_speed(void *cpu, double load)
 {
-  return load * (((cpu_Cas01_t) cpu)->power_peak);
+  return load * ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak;
 }
 
 static double cpu_get_available_speed(void *cpu)
 {
   /* number between 0 and 1 */
 }
 
 static double cpu_get_available_speed(void *cpu)
 {
   /* number between 0 and 1 */
-  return ((cpu_Cas01_t) cpu)->power_scale;
+  return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_scale;
 }
 
 static void cpu_finalize(void)
 }
 
 static void cpu_finalize(void)
index 30d23f8..b44fd4d 100644 (file)
@@ -155,7 +155,7 @@ static void* cpu_ti_create_resource(const char *name, double power_peak,
   cpu_ti_t cpu = NULL;
   s_surf_action_cpu_ti_t ti_action;
   xbt_assert(core==1,"Multi-core not handled with this model yet");
   cpu_ti_t cpu = NULL;
   s_surf_action_cpu_ti_t ti_action;
   xbt_assert(core==1,"Multi-core not handled with this model yet");
-  xbt_assert(!surf_cpu_resource_by_name(name),
+  xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
               "Host '%s' declared several times in the platform file",
               name);
   xbt_assert(core==1,"Multi-core not handled with this model yet");
               "Host '%s' declared several times in the platform file",
               name);
   xbt_assert(core==1,"Multi-core not handled with this model yet");
@@ -185,7 +185,7 @@ static void* cpu_ti_create_resource(const char *name, double power_peak,
   }
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
 
   }
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
 
-  return cpu;
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 
 }
 
 
@@ -216,7 +216,7 @@ static void add_traces_cpu_ti(void)
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
 /* connect all traces relative to hosts */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_ti_t cpu = surf_cpu_resource_by_name(elm);
+    cpu_ti_t cpu = surf_cpu_resource_priv(surf_cpu_resource_by_name(elm));
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -232,7 +232,7 @@ static void add_traces_cpu_ti(void)
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_ti_t cpu = surf_cpu_resource_by_name(elm);
+    cpu_ti_t cpu = surf_cpu_resource_priv(surf_cpu_resource_by_name(elm));
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -277,11 +277,11 @@ static int cpu_ti_action_unref(surf_action_t action)
   if (!action->refcount) {
     xbt_swag_remove(action, action->state_set);
     /* remove from action_set */
   if (!action->refcount) {
     xbt_swag_remove(action, action->state_set);
     /* remove from action_set */
-    xbt_swag_remove(action, ACTION_GET_CPU(action)->action_set);
+    xbt_swag_remove(action, ((cpu_ti_t)surf_cpu_resource_priv(ACTION_GET_CPU(action)))->action_set);
     /* remove from heap */
     xbt_heap_remove(cpu_ti_action_heap,
                     ((surf_action_cpu_ti_t) action)->index_heap);
     /* remove from heap */
     xbt_heap_remove(cpu_ti_action_heap,
                     ((surf_action_cpu_ti_t) action)->index_heap);
-    xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
+    xbt_swag_insert(((cpu_ti_t)surf_cpu_resource_priv(ACTION_GET_CPU(action))), cpu_ti_modified_cpu);
     surf_action_free(&action);
     return 1;
   }
     surf_action_free(&action);
     return 1;
   }
@@ -293,7 +293,7 @@ static void cpu_ti_action_cancel(surf_action_t action)
   surf_action_state_set(action, SURF_ACTION_FAILED);
   xbt_heap_remove(cpu_ti_action_heap,
                   ((surf_action_cpu_ti_t) action)->index_heap);
   surf_action_state_set(action, SURF_ACTION_FAILED);
   xbt_heap_remove(cpu_ti_action_heap,
                   ((surf_action_cpu_ti_t) action)->index_heap);
-  xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
+  xbt_swag_insert(surf_cpu_resource_priv(ACTION_GET_CPU(action)), cpu_ti_modified_cpu);
   return;
 }
 
   return;
 }
 
@@ -301,7 +301,7 @@ static void cpu_ti_action_state_set(surf_action_t action,
                                     e_surf_action_state_t state)
 {
   surf_action_state_set(action, state);
                                     e_surf_action_state_t state)
 {
   surf_action_state_set(action, state);
-  xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
+  xbt_swag_insert(surf_cpu_resource_priv(ACTION_GET_CPU(action)), cpu_ti_modified_cpu);
   return;
 }
 
   return;
 }
 
@@ -482,7 +482,7 @@ static void cpu_ti_update_actions_state(double now, double delta)
     GENERIC_ACTION(action).remains = 0;
     cpu_ti_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
     /* update remaining amout of all actions */
     GENERIC_ACTION(action).remains = 0;
     cpu_ti_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
     /* update remaining amout of all actions */
-    cpu_ti_update_remaining_amount(action->cpu, surf_get_clock());
+    cpu_ti_update_remaining_amount(surf_cpu_resource_priv(action->cpu), surf_get_clock());
   }
 #undef GENERIC_ACTION
 }
   }
 #undef GENERIC_ACTION
 }
@@ -563,7 +563,7 @@ static void cpu_ti_update_resource_state(void *id,
 static surf_action_t cpu_ti_execute(void *cpu, double size)
 {
   surf_action_cpu_ti_t action = NULL;
 static surf_action_t cpu_ti_execute(void *cpu, double size)
 {
   surf_action_cpu_ti_t action = NULL;
-  cpu_ti_t CPU = cpu;
+  cpu_ti_t CPU = surf_cpu_resource_priv(cpu);
 
   XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
   action =
 
   XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
   action =
@@ -595,7 +595,7 @@ static surf_action_t cpu_ti_action_sleep(void *cpu, double duration)
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
-  XBT_IN("(%s,%g)", surf_resource_name(cpu), duration);
+  XBT_IN("(%s,%g)", surf_resource_name(surf_cpu_resource_priv(cpu)), duration);
   action = (surf_action_cpu_ti_t) cpu_ti_execute(cpu, 1.0);
   action->generic_action.max_duration = duration;
   action->suspended = 2;
   action = (surf_action_cpu_ti_t) cpu_ti_execute(cpu, 1.0);
   action->generic_action.max_duration = duration;
   action->suspended = 2;
@@ -618,7 +618,7 @@ static void cpu_ti_action_suspend(surf_action_t action)
     ((surf_action_cpu_ti_t) action)->suspended = 1;
     xbt_heap_remove(cpu_ti_action_heap,
                     ((surf_action_cpu_ti_t) action)->index_heap);
     ((surf_action_cpu_ti_t) action)->suspended = 1;
     xbt_heap_remove(cpu_ti_action_heap,
                     ((surf_action_cpu_ti_t) action)->index_heap);
-    xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
+    xbt_swag_insert(surf_cpu_resource_priv(ACTION_GET_CPU(action)), cpu_ti_modified_cpu);
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -628,7 +628,7 @@ static void cpu_ti_action_resume(surf_action_t action)
   XBT_IN("(%p)", action);
   if (((surf_action_cpu_ti_t) action)->suspended != 2) {
     ((surf_action_cpu_ti_t) action)->suspended = 0;
   XBT_IN("(%p)", action);
   if (((surf_action_cpu_ti_t) action)->suspended != 2) {
     ((surf_action_cpu_ti_t) action)->suspended = 0;
-    xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
+    xbt_swag_insert(surf_cpu_resource_priv(ACTION_GET_CPU(action)), cpu_ti_modified_cpu);
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -673,7 +673,7 @@ static void cpu_ti_action_set_priority(surf_action_t action,
 {
   XBT_IN("(%p,%g)", action, priority);
   action->priority = priority;
 {
   XBT_IN("(%p,%g)", action, priority);
   action->priority = priority;
-  xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
+  xbt_swag_insert(surf_cpu_resource_priv(ACTION_GET_CPU(action)), cpu_ti_modified_cpu);
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
@@ -689,12 +689,12 @@ static double cpu_ti_action_get_remains(surf_action_t action)
 
 static e_surf_resource_state_t cpu_ti_get_state(void *cpu)
 {
 
 static e_surf_resource_state_t cpu_ti_get_state(void *cpu)
 {
-  return ((cpu_ti_t) cpu)->state_current;
+  return ((cpu_ti_t)surf_cpu_resource_priv(cpu))->state_current;
 }
 
 static double cpu_ti_get_speed(void *cpu, double load)
 {
 }
 
 static double cpu_ti_get_speed(void *cpu, double load)
 {
-  return load * (((cpu_ti_t) cpu)->power_peak);
+  return load * ((cpu_ti_t)surf_cpu_resource_priv(cpu))->power_peak;
 }
 
 /**
 }
 
 /**
@@ -722,7 +722,7 @@ static double surf_cpu_ti_get_power_scale(surf_cpu_ti_tgmr_t trace,
 
 static double cpu_ti_get_available_speed(void *cpu)
 {
 
 static double cpu_ti_get_available_speed(void *cpu)
 {
-  cpu_ti_t CPU = cpu;
+  cpu_ti_t CPU = surf_cpu_resource_priv(cpu);
   CPU->power_scale =
       surf_cpu_ti_get_power_scale(CPU->avail_trace, surf_get_clock());
 /* number between 0 and 1 */
   CPU->power_scale =
       surf_cpu_ti_get_power_scale(CPU->avail_trace, surf_get_clock());
 /* number between 0 and 1 */
index 4d82cd3..ff82779 100644 (file)
@@ -232,7 +232,7 @@ static void* storage_create_resource(const char* id, const char* model,const cha
 {
   storage_t storage = NULL;
 
 {
   storage_t storage = NULL;
 
-  xbt_assert(!surf_storage_resource_by_name(id),
+  xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)),
               "Storage '%s' declared several times in the platform file",
               id);
   storage = (storage_t) surf_resource_new(sizeof(s_storage_t),
               "Storage '%s' declared several times in the platform file",
               id);
   storage = (storage_t) surf_resource_new(sizeof(s_storage_t),
@@ -673,7 +673,7 @@ static void storage_parse_mount(sg_platf_mount_cbarg_t mount)
   XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->id, mount->name);
 
   s_mount_t mnt;
   XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->id, mount->name);
 
   s_mount_t mnt;
-  mnt.id = surf_storage_resource_by_name(mount->id);
+  mnt.id = surf_storage_resource_priv(surf_storage_resource_by_name(mount->id));
   mnt.name = xbt_strdup(mount->name);
 
   if(!mount_list){
   mnt.name = xbt_strdup(mount->name);
 
   if(!mount_list){
index fec50a4..13798ec 100644 (file)
@@ -14,7 +14,6 @@
 
 typedef struct workstation_CLM03 {
   s_surf_resource_t generic_resource;   /* Must remain first to add this to a trace */
 
 typedef struct workstation_CLM03 {
   s_surf_resource_t generic_resource;   /* Must remain first to add this to a trace */
-  void *cpu;
   void *net_elm;
   xbt_dynar_t storage;
 } s_workstation_CLM03_t, *workstation_CLM03_t;
   void *net_elm;
   xbt_dynar_t storage;
 } s_workstation_CLM03_t, *workstation_CLM03_t;
@@ -30,7 +29,6 @@ static void workstation_new(sg_platf_host_cbarg_t host)
 
   workstation->generic_resource.model = surf_workstation_model;
   workstation->generic_resource.name = xbt_strdup(host->id);
 
   workstation->generic_resource.model = surf_workstation_model;
   workstation->generic_resource.name = xbt_strdup(host->id);
-  workstation->cpu = xbt_lib_get_or_null(host_lib, host->id, SURF_CPU_LEVEL);
   workstation->storage = xbt_lib_get_or_null(storage_lib,host->id,ROUTING_STORAGE_HOST_LEVEL);
   workstation->net_elm = xbt_lib_get_or_null(host_lib,host->id,ROUTING_HOST_LEVEL);
   XBT_DEBUG("Create workstation %s with %ld mounted disks",host->id,xbt_dynar_length(workstation->storage));
   workstation->storage = xbt_lib_get_or_null(storage_lib,host->id,ROUTING_STORAGE_HOST_LEVEL);
   workstation->net_elm = xbt_lib_get_or_null(host_lib,host->id,ROUTING_HOST_LEVEL);
   XBT_DEBUG("Create workstation %s with %ld mounted disks",host->id,xbt_dynar_length(workstation->storage));
@@ -113,14 +111,14 @@ static void ws_update_resource_state(void *id,
 
 static surf_action_t ws_execute(void *workstation, double size)
 {
 
 static surf_action_t ws_execute(void *workstation, double size)
 {
-  void *cpu = ((workstation_CLM03_t) workstation)->cpu;
-  return ((surf_resource_t) cpu)->model->extension.cpu.execute(cpu, size);
+  surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
+  return cpu->model->extension.cpu.execute(workstation, size);
 }
 
 static surf_action_t ws_action_sleep(void *workstation, double duration)
 {
   return surf_cpu_model->extension.cpu.
 }
 
 static surf_action_t ws_action_sleep(void *workstation, double duration)
 {
   return surf_cpu_model->extension.cpu.
-      sleep(((workstation_CLM03_t) workstation)->cpu, duration);
+      sleep(workstation, duration);
 }
 
 static void ws_action_suspend(surf_action_t action)
 }
 
 static void ws_action_suspend(surf_action_t action)
@@ -210,8 +208,8 @@ static surf_action_t ws_communicate(void *workstation_src,
                                     void *workstation_dst, double size,
                                     double rate)
 {
                                     void *workstation_dst, double size,
                                     double rate)
 {
-  workstation_CLM03_t src = (workstation_CLM03_t) workstation_src;
-  workstation_CLM03_t dst = (workstation_CLM03_t) workstation_dst;
+  workstation_CLM03_t src = surf_workstation_resource_priv(workstation_src);
+  workstation_CLM03_t dst = surf_workstation_resource_priv(workstation_dst);
   return surf_network_model->extension.network.
       communicate(src->net_elm,
                   dst->net_elm, size, rate);
   return surf_network_model->extension.network.
       communicate(src->net_elm,
                   dst->net_elm, size, rate);
@@ -220,20 +218,19 @@ static surf_action_t ws_communicate(void *workstation_src,
 static e_surf_resource_state_t ws_get_state(void *workstation)
 {
   return surf_cpu_model->extension.cpu.
 static e_surf_resource_state_t ws_get_state(void *workstation)
 {
   return surf_cpu_model->extension.cpu.
-      get_state(((workstation_CLM03_t) workstation)->cpu);
+      get_state(workstation);
 }
 
 static double ws_get_speed(void *workstation, double load)
 {
   return surf_cpu_model->extension.cpu.
 }
 
 static double ws_get_speed(void *workstation, double load)
 {
   return surf_cpu_model->extension.cpu.
-      get_speed(((workstation_CLM03_t) workstation)->cpu, load);
+      get_speed(workstation, load);
 }
 
 static double ws_get_available_speed(void *workstation)
 {
   return surf_cpu_model->extension.cpu.
 }
 
 static double ws_get_available_speed(void *workstation)
 {
   return surf_cpu_model->extension.cpu.
-      get_available_speed(((workstation_CLM03_t)
-                           workstation)->cpu);
+      get_available_speed(workstation);
 }
 
 static surf_action_t ws_execute_parallel_task(int workstation_nb,
 }
 
 static surf_action_t ws_execute_parallel_task(int workstation_nb,
@@ -275,8 +272,8 @@ static surf_action_t ws_execute_parallel_task(int workstation_nb,
 static xbt_dynar_t ws_get_route(void *workstation_src, void *workstation_dst)
 {
   XBT_DEBUG("ws_get_route");
 static xbt_dynar_t ws_get_route(void *workstation_src, void *workstation_dst)
 {
   XBT_DEBUG("ws_get_route");
-  workstation_CLM03_t src = (workstation_CLM03_t) workstation_src;
-  workstation_CLM03_t dst = (workstation_CLM03_t) workstation_dst;
+  workstation_CLM03_t src = surf_workstation_resource_priv(workstation_src);
+  workstation_CLM03_t dst = surf_workstation_resource_priv(workstation_dst);
   return surf_network_model->extension.
       network.get_route(src->net_elm,
                   dst->net_elm);
   return surf_network_model->extension.
       network.get_route(src->net_elm,
                   dst->net_elm);
@@ -305,7 +302,7 @@ static void ws_finalize(void)
 
 static xbt_dict_t ws_get_properties(const void *ws)
 {
 
 static xbt_dict_t ws_get_properties(const void *ws)
 {
-  return surf_resource_properties(((workstation_CLM03_t) ws)->cpu);
+  return surf_resource_properties(surf_cpu_resource_priv(ws));
 }
 
 static storage_t find_storage_on_mount_list(void *workstation,const char* storage)
 }
 
 static storage_t find_storage_on_mount_list(void *workstation,const char* storage)
@@ -313,9 +310,10 @@ static storage_t find_storage_on_mount_list(void *workstation,const char* storag
   storage_t st = NULL;
   s_mount_t mnt;
   unsigned int cursor;
   storage_t st = NULL;
   s_mount_t mnt;
   unsigned int cursor;
-  xbt_dynar_t storage_list = ((workstation_CLM03_t) workstation)->storage;
+  workstation_CLM03_t ws = (workstation_CLM03_t) surf_workstation_resource_priv(workstation);
+  xbt_dynar_t storage_list = ws->storage;
 
 
-  XBT_DEBUG("Search for storage name '%s' on '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+  XBT_DEBUG("Search for storage name '%s' on '%s'",storage,ws->generic_resource.name);
   xbt_dynar_foreach(storage_list,cursor,mnt)
   {
     XBT_DEBUG("See '%s'",mnt.name);
   xbt_dynar_foreach(storage_list,cursor,mnt)
   {
     XBT_DEBUG("See '%s'",mnt.name);
@@ -324,7 +322,7 @@ static storage_t find_storage_on_mount_list(void *workstation,const char* storag
       break;
     }
   }
       break;
     }
   }
-  if(!st) xbt_die("Can't find mount '%s' for '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+  if(!st) xbt_die("Can't find mount '%s' for '%s'",storage,ws->generic_resource.name);
   return st;
 }
 
   return st;
 }
 
index 662b384..183c305 100644 (file)
@@ -96,8 +96,8 @@ static void ptask_update_action_bound(surf_action_workstation_L07_t action)
 
       if (action->communication_amount[i * workstation_nb + j] > 0) {
         double lat = 0.0;
 
       if (action->communication_amount[i * workstation_nb + j] > 0) {
         double lat = 0.0;
-        routing_get_route_and_latency(action->workstation_list[i]->info,
-            action->workstation_list[j]->info,
+        routing_get_route_and_latency(((cpu_L07_t)surf_workstation_resource_priv(action->workstation_list[i]))->info,
+            ((cpu_L07_t)surf_workstation_resource_priv(action->workstation_list[j]))->info,
             &route, &lat);
         lat_current =
             MAX(lat_current,
             &route, &lat);
         lat_current =
             MAX(lat_current,
@@ -430,17 +430,17 @@ static void ptask_finalize(void)
 
 static e_surf_resource_state_t ptask_resource_get_state(void *cpu)
 {
 
 static e_surf_resource_state_t ptask_resource_get_state(void *cpu)
 {
-  return ((cpu_L07_t) cpu)->state_current;
+  return ((cpu_L07_t)surf_workstation_resource_priv(cpu))->state_current;
 }
 
 static double ptask_get_speed(void *cpu, double load)
 {
 }
 
 static double ptask_get_speed(void *cpu, double load)
 {
-  return load * (((cpu_L07_t) cpu)->power_scale);
+  return load * ((cpu_L07_t)surf_workstation_resource_priv(cpu))->power_scale;
 }
 
 static double ptask_get_available_speed(void *cpu)
 {
 }
 
 static double ptask_get_available_speed(void *cpu)
 {
-  return ((cpu_L07_t) cpu)->power_current;
+  return ((cpu_L07_t)surf_workstation_resource_priv(cpu))->power_current;
 }
 
 static surf_action_t ptask_execute_parallel_task(int workstation_nb,
 }
 
 static surf_action_t ptask_execute_parallel_task(int workstation_nb,
@@ -473,8 +473,8 @@ static surf_action_t ptask_execute_parallel_task(int workstation_nb,
         link_L07_t link;
 
         routing_get_route_and_latency(
         link_L07_t link;
 
         routing_get_route_and_latency(
-            ((cpu_L07_t)workstation_list[i])->info,
-            ((cpu_L07_t)workstation_list[j])->info,
+            ((cpu_L07_t)surf_workstation_resource_priv(workstation_list[i]))->info,
+            ((cpu_L07_t)surf_workstation_resource_priv(workstation_list[j]))->info,
             &route,&lat);
         latency = MAX(latency, lat);
 
             &route,&lat);
         latency = MAX(latency, lat);
 
@@ -516,7 +516,7 @@ static surf_action_t ptask_execute_parallel_task(int workstation_nb,
 
   for (i = 0; i < workstation_nb; i++)
     lmm_expand(ptask_maxmin_system,
 
   for (i = 0; i < workstation_nb; i++)
     lmm_expand(ptask_maxmin_system,
-               ((cpu_L07_t) workstation_list[i])->constraint,
+               ((cpu_L07_t)surf_workstation_resource_priv(workstation_list[i]))->constraint,
                action->variable, computation_amount[i]);
 
   for (i = 0; i < workstation_nb; i++) {
                action->variable, computation_amount[i]);
 
   for (i = 0; i < workstation_nb; i++) {
@@ -527,8 +527,8 @@ static surf_action_t ptask_execute_parallel_task(int workstation_nb,
         continue;
 
       routing_get_route_and_latency(
         continue;
 
       routing_get_route_and_latency(
-          ((cpu_L07_t)workstation_list[i])->info,
-          ((cpu_L07_t)workstation_list[j])->info,
+          ((cpu_L07_t)surf_workstation_resource_priv(workstation_list[i]))->info,
+          ((cpu_L07_t)surf_workstation_resource_priv(workstation_list[j]))->info,
           &route,NULL);
 
       xbt_dynar_foreach(route, cpt, link) {
           &route,NULL);
 
       xbt_dynar_foreach(route, cpt, link) {
@@ -600,7 +600,7 @@ static xbt_dynar_t ptask_get_route(void *src, void *dst) // FIXME: kill that cal
 {
   xbt_dynar_t route=NULL;
   routing_get_route_and_latency(
 {
   xbt_dynar_t route=NULL;
   routing_get_route_and_latency(
-      ((cpu_L07_t)src)->info, ((cpu_L07_t)dst)->info,
+      ((cpu_L07_t)surf_workstation_resource_priv(src))->info, ((cpu_L07_t)surf_workstation_resource_priv(dst))->info,
       &route,NULL);
   return route;
 }
       &route,NULL);
   return route;
 }
@@ -632,7 +632,7 @@ static void* ptask_cpu_create_resource(const char *name, double power_scale,
                                xbt_dict_t cpu_properties)
 {
   cpu_L07_t cpu = NULL;
                                xbt_dict_t cpu_properties)
 {
   cpu_L07_t cpu = NULL;
-  xbt_assert(!surf_workstation_resource_by_name(name),
+  xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
               "Host '%s' declared several times in the platform file.",
               name);
 
               "Host '%s' declared several times in the platform file.",
               name);
 
@@ -662,7 +662,7 @@ static void* ptask_cpu_create_resource(const char *name, double power_scale,
 
   xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, cpu);
 
 
   xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, cpu);
 
-  return cpu;
+  return xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
 }
 
 static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
@@ -775,7 +775,7 @@ static void ptask_add_traces(void)
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
   /* Connect traces relative to cpu */
   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_L07_t host = surf_workstation_resource_by_name(elm);
+    cpu_L07_t host = surf_workstation_resource_priv(surf_workstation_resource_by_name(elm));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
@@ -786,7 +786,7 @@ static void ptask_add_traces(void)
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
 
   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
-    cpu_L07_t host = surf_workstation_resource_by_name(elm);
+    cpu_L07_t host = surf_workstation_resource_priv(surf_workstation_resource_by_name(elm));
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
     xbt_assert(host, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
index f52f98b..80c8a6c 100644 (file)
@@ -316,27 +316,45 @@ char *xbt_dict_get_key(xbt_dict_t dict, const void *data)
  */
 XBT_INLINE void *xbt_dict_get(xbt_dict_t dict, const char *key)
 {
  */
 XBT_INLINE void *xbt_dict_get(xbt_dict_t dict, const char *key)
 {
-
-  unsigned int hash_code = xbt_str_hash(key);
-  xbt_dictelm_t current;
-
-  xbt_assert(dict);
-
-  current = dict->table[hash_code & dict->table_size];
-  while (current != NULL
-         && (hash_code != current->hash_code || strcmp(key, current->key)))
-    current = current->next;
+  return xbt_dict_get_elm(dict, key)->content;
+}
+/**
+ * \brief Retrieve element from the dict (null-terminated key)
+ *
+ * \param dict the dealer of data
+ * \param key the key to find data
+ * \return the s_xbt_dictelm_t that we are looking for
+ *
+ * Search the given \a key. Throws not_found_error when not found.
+ * Check xbt_dict_get_or_null() for a version returning NULL without exception when
+ * not found.
+ */
+XBT_INLINE xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
+{
+  xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
 
   if (current == NULL)
     THROWF(not_found_error, 0, "key %s not found", key);
 
 
   if (current == NULL)
     THROWF(not_found_error, 0, "key %s not found", key);
 
-  return current->content;
+  return current;
 }
 
 /**
  * \brief like xbt_dict_get(), but returning NULL when not found
  */
 XBT_INLINE void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
 }
 
 /**
  * \brief like xbt_dict_get(), but returning NULL when not found
  */
 XBT_INLINE void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
+{
+  xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
+  
+  if (current == NULL)
+    return NULL;
+
+  return current->content;
+}
+/**
+ * \brief like xbt_dict_get_elm(), but returning NULL when not found
+ */
+XBT_INLINE xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
 {
   unsigned int hash_code = xbt_str_hash(key);
   xbt_dictelm_t current;
 {
   unsigned int hash_code = xbt_str_hash(key);
   xbt_dictelm_t current;
@@ -347,11 +365,7 @@ XBT_INLINE void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
   while (current != NULL &&
          (hash_code != current->hash_code || strcmp(key, current->key)))
     current = current->next;
   while (current != NULL &&
          (hash_code != current->hash_code || strcmp(key, current->key)))
     current = current->next;
-
-  if (current == NULL)
-    return NULL;
-
-  return current->content;
+  return current;
 }
 
 
 }
 
 
index 7141a17..cd7e189 100644 (file)
@@ -20,11 +20,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict_cursor, xbt_dict,
 /* To traverse (simple) dicts                                               */
 /* Don't add or remove entries to the dict while traversing !!!             */
 /*###########################################################################*/
 /* To traverse (simple) dicts                                               */
 /* Don't add or remove entries to the dict while traversing !!!             */
 /*###########################################################################*/
-struct s_xbt_dict_cursor {
-  xbt_dictelm_t current;
-  int line;
-  xbt_dict_t dict;
-};
 
 #undef xbt_dict_CURSOR_DEBUG
 /*#define xbt_dict_CURSOR_DEBUG 1*/
 
 #undef xbt_dict_CURSOR_DEBUG
 /*#define xbt_dict_CURSOR_DEBUG 1*/
index 490fe38..77292d1 100644 (file)
 #include "xbt/dict.h"
 #include "xbt/mallocator.h"
 
 #include "xbt/dict.h"
 #include "xbt/mallocator.h"
 
-typedef struct s_xbt_dictelm *xbt_dictelm_t;
-
 #define MAX_FILL_PERCENT 80
 
 #define MAX_FILL_PERCENT 80
 
-typedef struct s_xbt_dictelm {
-  char *key;
-  int key_len;
-  unsigned int hash_code;
-
-  void *content;
-
-  xbt_dictelm_t next;
-} s_xbt_dictelm_t;
 
 typedef struct s_xbt_het_dictelm {
   s_xbt_dictelm_t element;
 
 typedef struct s_xbt_het_dictelm {
   s_xbt_dictelm_t element;
index 163c0de..ccb1e0e 100644 (file)
@@ -75,3 +75,13 @@ void *xbt_lib_get_or_null(xbt_lib_t lib, const char *key, int level)
   void **elts = xbt_dict_get_or_null(lib->dict, key);
   return elts ? elts[level] : NULL;
 }
   void **elts = xbt_dict_get_or_null(lib->dict, key);
   return elts ? elts[level] : NULL;
 }
+
+xbt_dictelm_t xbt_lib_get_elm_or_null(xbt_lib_t lib, const char *key)
+{
+  return xbt_dict_get_elm_or_null(lib->dict, key);
+}
+
+void *xbt_lib_get_level(xbt_dictelm_t elm, int level){
+  void **elts = elm->content;
+  return elts ? elts[level] : NULL;
+}