Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the sg_plat_new_host() function public
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 7 Nov 2011 10:41:10 +0000 (11:41 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 7 Nov 2011 10:41:10 +0000 (11:41 +0100)
include/simgrid/platf.h
src/include/simgrid/platf_interface.h
src/surf/sg_platf.c
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index 8014a9b..89df78d 100644 (file)
@@ -20,6 +20,16 @@ typedef enum {
 } e_surf_resource_state_t;
 
 
 } e_surf_resource_state_t;
 
 
+/*
+ * Platform creation functions. Instead of passing 123 arguments to the creation functions
+ * (one for each possible XML attribute), we pass structures containing them all. It removes the
+ * chances of switching arguments by error, and reduce the burden when we add a new attribute:
+ * old models can just continue to ignore it without having to update their headers.
+ *
+ * It shouldn't be too costly at runtime, provided that structures living on the stack are
+ * used, instead of malloced structures.
+ */
+
 typedef struct s_surf_parsing_host_arg {
   char* V_host_id;                          //id
   double V_host_power_peak;                     //power
 typedef struct s_surf_parsing_host_arg {
   char* V_host_id;                          //id
   double V_host_power_peak;                     //power
@@ -35,4 +45,6 @@ typedef struct s_surf_parsing_host_arg {
 XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode);
 XBT_PUBLIC(void) sg_platf_new_AS_close(void);
 
 XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode);
 XBT_PUBLIC(void) sg_platf_new_AS_close(void);
 
+XBT_PUBLIC(void) sg_platf_new_host(surf_parsing_host_arg_t h);
+
 #endif                          /* SG_PLATF_H */
 #endif                          /* SG_PLATF_H */
index a78eb2f..4502cb0 100644 (file)
@@ -20,7 +20,6 @@ void sg_platf_exit(void);
 typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t);
 void surf_parse_host_add_cb(surf_parse_host_fct_t);
 
 typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t);
 void surf_parse_host_add_cb(surf_parse_host_fct_t);
 
-void surf_parse_host(surf_parsing_host_arg_t h);
 
 
 
 
 
 
index 89eff09..f47d406 100644 (file)
@@ -23,7 +23,7 @@ void sg_platf_exit(void) {
   xbt_dynar_free(&surf_parse_host_cb_list);
 }
 
   xbt_dynar_free(&surf_parse_host_cb_list);
 }
 
-void surf_parse_host(surf_parsing_host_arg_t h){
+void sg_platf_new_host(surf_parsing_host_arg_t h){
   unsigned int iterator;
   surf_parse_host_fct_t fun;
   xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
   unsigned int iterator;
   surf_parse_host_fct_t fun;
   xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
index 634b3c7..4a4077e 100644 (file)
@@ -1512,7 +1512,7 @@ static void parse_create_host_link(int i)
        host.V_host_core = struct_cluster->S_cluster_core;
        host.V_host_state_initial = SURF_RESOURCE_ON;
        host.V_host_coord = "";
        host.V_host_core = struct_cluster->S_cluster_core;
        host.V_host_state_initial = SURF_RESOURCE_ON;
        host.V_host_coord = "";
-       surf_parse_host(&host);
+       sg_platf_new_host(&host);
        XBT_DEBUG("</host>");
 
        A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
        XBT_DEBUG("</host>");
 
        A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
@@ -1645,7 +1645,7 @@ void routing_parse_Scluster(void)
                host.V_host_core = struct_cluster->S_cluster_core;
                host.V_host_state_initial = SURF_RESOURCE_ON;
                host.V_host_coord = "";
                host.V_host_core = struct_cluster->S_cluster_core;
                host.V_host_state_initial = SURF_RESOURCE_ON;
                host.V_host_coord = "";
-               surf_parse_host(&host);
+               sg_platf_new_host(&host);
                XBT_DEBUG("</host>");
 
                A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
                XBT_DEBUG("</host>");
 
                A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
@@ -1725,7 +1725,7 @@ void routing_parse_Scluster(void)
                host.V_host_core = struct_cluster->S_cluster_core;
                host.V_host_state_initial = SURF_RESOURCE_ON;
                host.V_host_coord = "";
                host.V_host_core = struct_cluster->S_cluster_core;
                host.V_host_state_initial = SURF_RESOURCE_ON;
                host.V_host_coord = "";
-               surf_parse_host(&host);
+               sg_platf_new_host(&host);
                XBT_DEBUG("</host>");
 
                A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
                XBT_DEBUG("</host>");
 
                A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
index e257345..5b4f63c 100644 (file)
@@ -309,7 +309,7 @@ void STag_surfxml_host(void){
                host.V_host_state_initial = SURF_RESOURCE_OFF;
        host.V_host_coord = xbt_strdup(A_surfxml_host_coordinates);
 
                host.V_host_state_initial = SURF_RESOURCE_OFF;
        host.V_host_coord = xbt_strdup(A_surfxml_host_coordinates);
 
-       surf_parse_host(&host);
+       sg_platf_new_host(&host);
 }
 void ETag_surfxml_host(void){
        surfxml_call_cb_functions(ETag_surfxml_host_cb_list);
 }
 void ETag_surfxml_host(void){
        surfxml_call_cb_functions(ETag_surfxml_host_cb_list);